Solved

NoInitialContextException-client connection using DataSource

Posted on 2006-06-29
9
391 Views
Last Modified: 2013-11-24
Hi,

I am trying to connect DB by data source and this is what I did. However, I get javax.naming.NoInitialContextException.
+++++++++++++++++++++++
     public void init() throws ServletException
     {
         
        ...
...
               Hashtable ht = new Hashtable();  
               ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
               ht.put(Context.PROVIDER_URL, "t3://localhost:7001");  
                      
               try {
             System.out.println("before initcntx");
                     initcntx = new InitialContext(ht); <------------------------
...
...
+++++++++++++++++++++++=
this is error message.

before initcntx
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      at LoginServlet.init(LoginServlet.java:48)
      at javax.servlet.GenericServlet.init(GenericServlet.java:211)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:641)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      at RegistrationController.doGet(RegistrationController.java:60)
      at RegistrationController.doPost(RegistrationController.java:88)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1338)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1187)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:242)
      at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
      ... 29 more
++++++++++

what am I doing wrong?
0
Comment
Question by:dkim18
  • 3
  • 3
9 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 17013451
> Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

you should put related classes in your classpath. I think weblogic.jar in this case
0
 

Author Comment

by:dkim18
ID: 17013483
I added weblogic.jar, but still having same error.
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17013621
what about wlclient.jar along with weblogic.jar
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:dkim18
ID: 17013802
still having same error.
0
 

Author Comment

by:dkim18
ID: 17013838
By the way, I am using eclipse...
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 125 total points
ID: 17013922
0
 
LVL 3

Assisted Solution

by:anumalas
anumalas earned 125 total points
ID: 17016384
Hi

These are the steps:-

1.Go to DOS Prompt

2.go to BEA_HOME\user_projects\<urdominname>

3. Type setEnv // This will set the weblogic environment for you

4. Start Weblogic using startWeblogic.cmd

This will solves your problem :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now