This week's book giveaway is in the
General Computing
forum.
We're giving away four copies of
Arduino in Action
and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
EJB and other Java EE Technologies
Author
cannot lookup jndi if using following method
peter tong
Ranch Hand
Joined: Mar 15, 2008
Posts: 234
posted
Feb 16, 2012 02:03:44
0
I have set up the datasource in weblogic console with jndi name jdbc/als
in web.xml, I add the following section
<resource-ref> <res-ref-name>jdbc/als</res-ref-name> <res-type>java.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
then I created a weblogic.xml and write
<wls:context-root>ALS</wls:context-root> <wls:resource-description> <wls:res-ref-name>jdbc/asl</wls:res-ref-name> <wls:jndi-name>jdbc/asl</wls:jndi-name> </wls:resource-description>
but when I deploy the application, error
NamingException
: Cannot bind null object to jndi with name jdbc/alsJNDI
is thrown, what is the reason?
peter tong
Ranch Hand
Joined: Mar 15, 2008
Posts: 234
posted
Feb 16, 2012 02:08:27
0
But if I remove the section in web.xml and weblogic.xml, then in the DBConnection class, I write
Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); Context ctx = new InitialContext(env); DataSource ds = (DataSource) ctx.lookup("jdbc/als"); Connection conn = ds.getConnection();
everything is Ok!!
So what is wrong with the first method (setting in web.xml and weblogic.xml)? I see most online tutorial recommend the first method.
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: cannot lookup jndi if using following method
Similar Threads
Connection pooling in tomcat
Query in : JNDI look up of DataSource
JNDI on startup
JBOSS connection pooling
Warning: Resource reference is not defined for JNDI name
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter