Solved

NoInitialContextException-client connection using DataSource

Posted on 2006-06-29
9
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

717 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