Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts datasource" Watch "Struts datasource" New topic
Author

Struts datasource

Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
I have this datasource set up in my struts config, running JBoss 4.0.4, and on starting the server I am getting the below error.

From what I can see from the error I might have the details of the datasource incorrect, so can someone tell me what is supposed to go where? I am on Oracle 9i.

This property should it be host :p ort atabase?

This property would be my service name in Oracle
<set-property property="username" value="BIZZ_COOP" />





Thanks for reading

cheers
Martin
[ June 23, 2006: Message edited by: Martin Thorpe ]
Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
Ok after a lot of googling and messing around I got it to work like below.

This is a connection to a remote database, the main thing is using directly the connection string.

I am running JBoss 4.0.4 and in the server statup it shows that it is setting the servlet to not available because the connection to the database was refused.

Now the main problem with me was connecting remotley and my Oracle TNS not configured correctly, it is corrupt locally so having real problems with that.

The way it was sorted in the end was using a connection string to directly connect to Oracle

This is my struts-config datasource, the URL property is where all the action is:


Also make sure you have these classes visible to the server; I have mine in the WEB-INF/lib directory:

The last 2 are Oracle specific I think.

commons-pool-1.3.jar
commons-collections-3.2.jar
jdbc2_0-stdext.jar
classes12.jar
[ June 23, 2006: Message edited by: Martin Thorpe ]
Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
Hello no I did not configure the oracle-ds.xml file where is this file found? All the connection information is in the string in the struts datasource.

What is happening that it is not working, any error? And what have you got set up in these properties in your struts-config:


cheers
Martin


Gerardo Casazza
greenhorn
Member # 129962 posted July 26, 2006 02:09 AM
--------------------------------------------------------------------------------
thank you martin, sorry if i bother you once again but my connection is not working yet, did you configure the oracle-ds.xml?

thank you

Gerardo Casazza
greenhorn
Member # 129962 posted July 25, 2006 11:11 AM
--------------------------------------------------------------------------------
Hi I read your post about oracle connection, i tried to do the same
i included classes12.jar where can i get the other jars
(commons-pool-1.3.jar, commons-collections-3.2.jar, jdbc2_0-stdext.jar) ?

thank you
--------------------------------------------------------------------------------
Posts: 0 | Registered: Jul 2006

Martin Thorpe
ranch hand
Member # 73745 posted July 26, 2006 01:30 AM
--------------------------------------------------------------------------------
Hello you will find them all in this list:

http://jakarta.apache.org/commons/components.html

cheers
Martin
[ July 26, 2006: Message edited by: Martin Thorpe ]
Gerardo Casazza
Greenhorn

Joined: Jul 25, 2006
Posts: 3
Hi Martin,

here my data source, i'm using jboss 4.04 and oracle 8.1.6

<data-source key="myKey" type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="url" value="jdbc racle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myHost)(PORT=1521))(CONNECT_DATA=(SID=mySid)))" /><set-property property="username" value="myUser" />
<set-property property="password" value="myPassword" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery" value="SELECT SYSDATE FROM DUAL" />
</data-source>

thank you
Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
That all looks fine to me, obviously I don't know if you host is correct, I found using the actual IP address to be more effective.

Do you have your Oracle on the standard 1521 port?

Other than that what is the problem do you get an error or?

Can you connect to the database from the machine you are setting up the web app on.

cheers
Martin
Gerardo Casazza
Greenhorn

Joined: Jul 25, 2006
Posts: 3
Hi Martin,

oracle configuration is standard and it's ok (i use oracle connections from other application, moreover using myeclipse db explorer i was able to connect to oracle). I paste a part of the log

11:01:27,265 ERROR [ActionServlet] Initializing application data source bizzCoop
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:207)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:231)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1081)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)

thanks
Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
Well that error is saying that you do not have the class to run a basic datasource.
Do you have this JAR in your WEB-INF/lib directory:

commons-dbcp-versionNumber.jar

obviously versionNumber in the above would be a number.

You can get it from here:
http://jakarta.apache.org/commons/dbcp/

cheers
Martin
Gerardo Casazza
Greenhorn

Joined: Jul 25, 2006
Posts: 3
i included all the library in my web-inf/lib....i configured the data source with the myeclipse editor and now i get the connection

thanks for your support
Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
No problem I am glad it works.

cheers
Martin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts datasource