Solved

NoInitialContextException-client connection using DataSource

Posted on 2006-06-29
9
395 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

920 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