blackicecube
blackicecube

Reputation:

Where is class weblogic.jndi.WLInitialContextFactory?

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

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

I guess this is some kind of missing library on the classpath. Can anyone tell me which jar-file is missing? I can't find the class weblogic.jndi.WLInitialContextFactory anywhere...

Thanks!

P.S.: I already have weblogic 10.0 jar included.

Upvotes: 13

Views: 104835

Answers (10)

luiscla27
luiscla27

Reputation: 6449

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

Upvotes: 0

Marek-A-
Marek-A-

Reputation: 494

For WLS 12.2, where WL_HOME is The BEA home directory of your WebLogic installation

(as defualt WL_HOME is Middleware\Oracle_Home\wlserver)

%WL_HOME%\server\lib\wlclient.jar
%WL_HOME%\server\lib\wls-api.jar 
%WL_HOME%\server\lib\wls-api-part.jar 
%WL_HOME%\server\lib\wlthint3client.jar 

all these libs contains the: jar: weblogic\jndi\WLInitialContextFactory.class

see WLS doc.: https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wlprg/overview.html#GUID-FC14CC53-DE49-456F-B54C-D73CC6DBF818

Upvotes: 0

nick
nick

Reputation: 21

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

Upvotes: 2

Yang
Yang

Reputation: 51

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

Upvotes: 2

KarthikPon
KarthikPon

Reputation: 169

I faced the same issue and it's fixed now :)

The fix is, to go to WebLogic server and navigate to /Oracle/Middleware/wlserver_10.3/server/lib/ and execute the below command.

Command: java -jar wljarbuilder.jar -profile wlfullclient5

The above command creates a jar file with all the jar's inside WebLogic server /lib folder and place it in your client java code build path Eclipse and craetes runnable JAR file and place this wlfullclient5.jar file in server/lib folder as well.

Hope this helps! Kindly let me know if you have any issues.

Upvotes: 2

Igor Zelaya
Igor Zelaya

Reputation: 4297

in version 12c it is located in weblogic-classes.jar in your lib directory:

C:\wls1213\wlserver\server\lib

Upvotes: 0

Nuno Furtado
Nuno Furtado

Reputation: 4568

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

Upvotes: 14

Ali Shiravand
Ali Shiravand

Reputation: 21

it looks you are doing a JNDI lookup outside of WLS.

You need to use wlfulclient.jar or if your machine has a WLS installation then add to your classpath project: WL_HOME/server/lib/weblogic.jar

Upvotes: 2

jagan
jagan

Reputation: 61

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.

Upvotes: 6

gregwhitaker
gregwhitaker

Reputation: 13420

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

Upvotes: 0

Related Questions