[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Getting JNDI/ db connection pool to work
|
I have:
----- src/main/webapp/WEB-INF/web.xml
...
<resource-ref>
<description>DataSource</description>
<res-ref-name>jdbc/pr</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
----- src/main/webapp/WEB-INF/jetty-env.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<New id="prDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/pr</Arg>
<Arg>
<New class="com.mchange.v2.c3p0.ComboPooledDataSource">
<Set name="driverClass">com.mysql.jdbc.Driver</Set>
<Set name="jdbcUrl">jdbc:mysql://localhost:3306/pr</Set>
<Set name="user">user</Set>
<Set name="password">pwd</Set>
</New>
</Arg>
</New>
</Configure>
------ src/main/java/com/priot/servlet/GetSession.java
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/pr");
--- Thrown on ic.lookup():
01:19:19.592 [qtp1963387170-40] ERROR com.priot.servlet.GetSession - Naming
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
~[?:1.8.0_45]
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
~[?:1.8.0_45]
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)
~[?:1.8.0_45]
at javax.naming.InitialContext.lookup(InitialContext.java:417)
~[?:1.8.0_45]
at com.priot.servlet.GetSession.doPost(GetSession.java:53)
[classes/:?]
It's as if my jetty-env.xml isn't being seen? But it is there in the war
file (along with the .swp).
Am I missing something obvious?
Thanks,
Bill