Hi

It is kind of funny find out that someone else has exactly the same problem, at the same time as I have . I have been trying to find a solution to this during all day and all night. My code is almost identical to yours but I get a nullpointer exception at line:

Context envContext = (Context)initContext.lookup("java:/comp/env");

This piece of code is packed in my aar-file and deployed to axis2 in tomcat. However I am not using Axis2 1.0 but a later nightly build.

I have searched the whole wide Internet for a solution to this but nothing turned out as a solution. Is the initialContext.lookUp("java:/comp/env") in my aar-file isolated from the tomcat or axis2?

Prótár, did you get this to work?
/johan

Sanjesh Pathak wrote:

Looks ok to me.

Sanjesh

Real-Time Web Service Monitoring for Axis, Axis2

SoapKnox Inc

http://www.soapknox.com

Ph: 832 279 3745

------------------------------------------------------------------------

*From:* Prótár Gábor [mailto:[EMAIL PROTECTED]
*Sent:* Wednesday, September 20, 2006 7:41 AM
*To:* [email protected]
*Subject:* Tomcat + Axis2 + MySQL

Hello!

I wrote a similar mail yesterday, but now I found something.

I am using Tomcat v5.5.17, Axis 2 v1.0, MySQL v5.0.24, MySQL Connector/J v5.0.3

This is how I configured MySQL under Tomcat:

1.: put context information to server.xml: <tomcat install folder>/conf/server.xml

<Context path="/axis2" docBase="axis2"

debug="5" reloadable="true" crossContext="true">

<Resource name="jdbc/TestDB2" auth="Container" type="javax.sql.DataSource"

maxActive="100" maxIdle="30" maxWait="100000"

username="wsuser" password="pass" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/ws?autoReconnect=true"/>

</Context>

2.: create resource link to the web.xml file at <tomcat install folder>/webapps/axis2/web-inf/web.xml

<resource-ref>

<description>DB Connection</description>

<res-ref-name>jdbc/TestDB</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

This resource works well in a test servlet, but I don’t how to use it axis2 webservice.

My question is: how can I reference this resource from java code?

Context initContext = new InitialContext();

Context envContext = (Context)initContext.lookup("java:/comp/env");

DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");

Connection conn = ds.getConnection();

Is it correct?

Thanks,

Gábor



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to