Where is class weblogic.jndi.WLInitialContextFactory?

后端 未结 10 1005
无人共我
无人共我 2021-02-13 15:33

when trying to execute my jar file I get an exception:

javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory 
[         


        
相关标签:
10条回答
  • 2021-02-13 16:01

    I've faced the issue stated here and I've managed to solved by fixing WL_HOME enviroment variable.

    In my case the wlserver_10.3 folder was moved to another drive (From D to E) and the guy who did the disk "migration" forgot to change the WL_HOME value at PATH\TO\Oracle\Middleware\wlserver_10.3\common\bin

    By fixing the wlserver_10.3 path I was able to deploy JAR's at WebLogic

    0 讨论(0)
  • 2021-02-13 16:02

    Step 1:

    Go to E:\weblogic81\user_projects\domains\mydomain. Then type Setenv command. As follows

    E:\weblogic81\user_projects\domains\mydomain>setenv 
    

    Step 2:

    Weblogic.jar file is needed by your client application. It may contain in the following path E:\weblogic81\weblogic81\server\lib\weblogic.jar. so set the classpath for the this folder or copy this weblogic.jar file into your application-folder so that weblogic.jar file is available to your application first.

    E:\weblogic81\user_projects\domains\mydomain>set CLASSPATH=%CLASSPATH%;E:\weblogic81\weblogic81\server\lib;.
    

    Step 3:

    Go to domain folder in command prompt as shown above and set classpath. To not to disturb other classpaths set classpath as:

    set CLASSPATH=%CLASSPATH%;E:\weblogic81\weblogic81\server\lib;.
    

    Here (.) dot represents set classpath to current directory.

    Step 4:

    After classpath set run command STARTWEBLOGIC as follows:

    E:\weblogic81\user_projects\domains\mydomain>STARTWEBLOGIC 
    

    Step 5:

    Do not login to weblogic server. If you are already login just log out and write the following code in myeclipse or some other IDE.

    Step 6:

    package directory.service;
    import java.util.*;
    import weblogic.jndi.*;
    import java.io.FileInputStream;
    import javax.naming.*;
    public class GetInitContext {
    
        /**
         * @param args
         */
    
        public static void main(String[] args) {
    
    
            try{
            weblogic.jndi.Environment env=new weblogic.jndi.Environment();
        weblogic.jndi.Environment environment = new weblogic.jndi.Environment();
            environment.setInitialContextFactory(
              weblogic.jndi.Environment.DEFAULT_INITIAL_CONTEXT_FACTORY);
            env.setProviderUrl("t3://localhost:7001");
            env.setSecurityPrincipal("agni");
            env.setSecurityCredentials("agnidevam");
            Context context=env.getInitialContext();
            System.out.println("got the initial context for weblogic server---> "+context);
            context.createSubcontext("sone");
            context.bind("agni one",new Integer(10));
            context.createSubcontext("sone/sctwo");
            context.bind("agni two",new Integer(20));
            context.createSubcontext("sone/sctwo/scthree");
            context.bind("agni three",new Integer(30));
            System.out.println("subcontex object created please check in admin server for more details");
    
            }
            catch(Exception e){
                System.out.println("file inputstream exception  ---> "+e);
            }
        }
    
    }
    

    Step 7:

    Execute the above code and login to weblogic and right click on myserver>view jndi tree> you find the bound objects information.

    0 讨论(0)
  • 2021-02-13 16:06

    Check your server/lib/ folder to find wliclient.jar.

    With Weblogic 12.1.3, you can find it here:
    ${INSTALL_DIR}/inventory/wlserver/server/lib/wlclient.jar

    0 讨论(0)
  • 2021-02-13 16:11

    Check the following tag in your build.xml

    property name="WLS_HOME" value="${env.WLS_HOME}"

    where WLS_HOME=c:\weblogic\wls\wlserver if running on windows i kept trying to run a simple hello world program and it kept throwing

    *run:

     [echo] Executing client class  
     [java] javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]*
    

    once i changed the above mentioned tag it in the build.xml it worked fine

    0 讨论(0)
  • 2021-02-13 16:12

    It is packaged inside of the weblogic.jar under your server/lib.

    0 讨论(0)
  • 2021-02-13 16:13

    Adding wlserver/server/lib/weblogic.jar is enough. I test it.

    0 讨论(0)
提交回复
热议问题