简体   繁体   中英

java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory

I am moving jboss-4.0.4.GA to wildfly-8.1.0.Final. while deploying my EAR I'm getting following error:

2014-07-10 17:09:44,900 ERROR [stderr] (default task-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.wildfly.ear.wildfly-war.war:main" from Service Module Loader [Root exception is java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory from [Module "deployment.wildfly.ear.wildfly-war.war:main" from Service Module Loader]]

My code:

Properties appProp = new Properties();
appProp.put(Context.INITIAL_CONTEXT_FACTORY, CGProperties.initial_context_factory);
appProp.put(Context.PROVIDER_URL, CGProperties.provider_url);
appProp.put("java.naming.rmi.security.manager", "yes");
appProp.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
appProp.put("jboss.naming.client.ejb.context","true");
context = new InitialContext(appProp);
//context = new InitialContext();

if(serverName.equalsIgnoreCase("JBOSS")) {
    ds = (javax.sql.DataSource) context.lookup(CGProperties.dsName);
    reportDS=(javax.sql.DataSource) context.lookup(CGProperties.reportdsName);
}

Please Help me to solve this error.

Either the jboss-client.jar needs to be added or corresponding WildFly module be included.

As answered here the following config in the standalone-full.xml does the trick:

    <subsystem xmlns="urn:jboss:domain:ee:4.0"><!-- ee:2.0  in WildFly 8 -->
                <global-modules>
                    <module name="org.jboss.remote-naming"/>
                </global-modules>
...

which allows to lookup for a remote connection on another WildFly server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM