Solved

NoInitialContextException-client connection using DataSource

Posted on 2006-06-29
9
400 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

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 …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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 …

830 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