[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Getting JNDI/ db connection pool to work
|
Hi Jan,
Inline:
On 7/11/2015 4:07 PM, Jan Bartel wrote:
Bill,
This is the link to the page with the current docs:
https://www.eclipse.org/jetty/documentation/
I don't see a link to a "jetty dependencies" page. Likely you are
following out-of-date doco - alternatively post a link to the page
linked from the one of the doc bundles above and I'll amend/remove it
as necessary.
This page seems to be there:
https://eclipse.org/jetty/documentation/current/jndi-embedded.html
-- errata:
"You can obtain this jar from the Jetty dependencies site. "
404
http://download.eclipse.org/jetty/orbit/javax.mail.glassfish_1.4.1.v201005082020.jar/dist/
Regarding adding jetty-plus to the classpath, it looks like
jetty-plus.jar is already in the distribution:
/opt/jetty-distribution-9.3.0.v20150612/lib/jetty-plus-9.3.0.v20150612.jar
One thing I noticed that wasn't in the docs is that I had --module=jndi
commented out in start.ini.
Now I get:
On the lookup line in my servlet:
DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/pr");
Getting hard-to-interpret NameNotFoundException:
00:19:24.129 [qtp1915503092-15] ERROR com.priot.servlet.GetSession - Naming
javax.naming.NameNotFoundException
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:533)
~[jetty-jndi-9.3.1-SNAPSHOT.jar:9.3.1-SNAPSHOT]
This tells me that I am getting jetty-jndi from local source, so adding
my own info in a warn and reinstalling:
2015-07-14 00:19:24.129:WARN:jndi:qtp1915503092-15: Binding null for
firstComponent: [env]
But 'env' is boilerplate from the examples:
DataSource myDS = (DataSource)ic.lookup("java:comp/env/jdbc/myds");
Does that reveal something useful?
Thanks,
Bill
jetty-plus is most definitely still in use. You'll need it. I suggest
you look at either the embedded examples in the jetty repo or the
test-jndi webapp in the jetty distro to see what you need to do.
cheers
Jan
On 12 July 2015 at 02:45, Bill Ross <ross@xxxxxxxxxxxx> wrote:
By the way, I notice the 'Jetty dependencies site' is broken, and the jndi
intro page that mentions it looks out of date.
Why isn't the source for jetty-jndi.jar in the distribution? It would be
easier to debug. I found the jar on maven and got it via my build.gradle:
compile group: 'org.eclipse.jetty', name: 'jetty-jndi', version:
'9.3.0.v20150612'
But now it gives me this on lookup:
09:25:46.627 [qtp1963387170-11] ERROR com.priot.servlet.GetSession - Naming
javax.naming.NameNotFoundException
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:532)
~[jetty-jndi-9.3.0.v20150612.jar:9.3.0.v20150612]
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:563)
~[jetty-jndi-9.3.0.v20150612.jar:9.3.0.v20150612]
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:578)
~[jetty-jndi-9.3.0.v20150612.jar:9.3.0.v20150612]
at
org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:106)
~[jetty-jndi-9.3.0.v20150612.jar:9.3.0.v20150612]
at javax.naming.InitialContext.lookup(InitialContext.java:417)
~[?:1.8.0_45]
at com.priot.servlet.GetSession.doPost(GetSession.java:53)
[classes/:?]
I wonder if this I got from the doc is right, since it defines the name -
what about the empty first arg?
Hm - it uses jetty.plus but jetty-plus.jar seems to be a thing of the past
(see note on out of date page above - jetty-plus.jar seems to have ended w/
v7 in maven central). Another odd thing is that the name is in the Arg, not
in the id, which is normally what I'd expect to use to look up an object:
<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>
Thanks,
Bill
On 7/10/2015 11:05 PM, Jan Bartel wrote:
Looks to me that you don't have jetty-jndi.jar on the classpath - it
contains the jndi impl.
Jan
On 11 July 2015 at 14:52, Bill Ross <ross@xxxxxxxxxxxx> wrote:
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
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users