Hi all,
I am trying to setup the embedded Jetty that comes with the GWT (2.0.3) Eclipse plugin to use a JNDI connection pool that works perfectly under Tomcat, without success. Now since i have read some things regarding the issue, i have managed to do the following:
Included the Jetty naming initial context factory to the classpath by launching the jvm with the following parameter: -Djava.naming.factory.initial=org.mortbay.naming.InitialContextFactory
.
I have also created a jetty-web.xml
that looks like this:
<New id="mysqltest" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>java:comp/env/jdbc/mysqldb</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://192.168.0.5:3306/mydb</Set>
<Set name="User">testuser</Set>
<Set name="Password">testpass</Set>
</New>
</Arg>
</New>
<New id="db2test" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>java:comp/env/jdbc/db2db</Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.ibm.db2.jcc.DB2Driver</Set>
<Set name="url">jdbc:db2://192.168.0.6:50000/mydb2</Set>
<Set name="username">testuser</Set>
<Set name="password">testpass</Set>
</New>
</New>
</Configure>
and have included the neccessary files in my build path. As you can see, there are two JNDI resources declared there, a handle to a MySQL database using MysqlConnectionPoolDataSource
(i saw that on a blog post) that works fine under my environment and used that to ensure that jetty was parsing the jetty-web.xml correctly and a second one that attempts to use DBCP
to connect to a DB2 database. The problem is that whenever i try to use the DBCP resource i get the following error when Jetty starts up:
[WARN] Config error at <New id="db2test" class="org.mortbay.jetty.plus.naming.Resource"><Arg>java:comp/env/jdbc/db2db</Arg>...
[WARN] Failed startup of context com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload@7a74db2c{/,/home/..}
java.lang.IllegalStateException: No Constructor <New id="db2test" class="org.mortbay.jetty.plus.naming.Resource"><Arg>java:comp/env/jdbc/db2db</Arg>...
As i said, these work fine under Tomcat and the problem is not specific to DB2, i cannot get a MySQL Datasource using DBCP as well. Looking at the error message, it seems that the DBCP files are not in the classpath but i have no clue on how to put them there (they are of course in the projects build path but that seems irrelevant to Jetty). I probably have to add another parameter to Djava.naming.factory.initial but i am not sure whats the correct one for DBCP to work.
Cheers