I'm making a small servlet app in Java, with Maven, in Netbeans. I'm using SQLite database, and newest Jetty server. I have problem with creating connection pool for use in servlets. What works(in servlet):
Class.forName("org.sqlite.JDBC");
String url = "jdbc:sqlite:c:\\db\\base";
Connection con = DriverManager.getConnection(url);
And this works without specific settings in http://ift.tt/16Dc5T1 I have libraries to use SQLite and connection pools (org.xerial.sqlite-jdbc, commons-pool, commons-dbcp).
What doesn't work:
web.xml:
<resource-ref>
<description>DB Connection Pool</description>
<res-ref-name>jdbc/DSTestPool</res-ref-name>
<res-type>javax.sql.ConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
jetty.xml
<New id="DSTestPool" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/DSTestPool</Arg>
<Arg>
<New class="org.sqlite.SQLiteConnectionPoolDataSource">
<Set name="driverClassName">org.sqlite.JDBC</Set>
<Set name="url">jdbc:sqlite:c:\\db\\base</Set>
</New>
</Arg>
</New>
pom.xml - dependencies.
This configuration, even without changes in code (change to using pool) creates error in jetty console: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) .... Caused by: java.lang.IllegalStateException: Nothing to bind for name jdbc/DSTestPool at org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.bindEntry(PlusDescriptorProcessor.java:895) ...
Opening app in Jetty: Error 503
I think there is something wrong with my declaration of jdbc/DSTestPool in jetty.xml, I've tried different parameters, but result was the same.
Aucun commentaire:
Enregistrer un commentaire