0

im getting following Error

**ERROR:**

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

Code:

final Properties env = new Properties();

env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "127.0.0.1");
//OR env.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "password");
context = new InitialContext(env);
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
Shankar S
  • 133
  • 1
  • 5
  • 15

2 Answers2

1

Try adding a jboss-deployment-structure.xml to the META-INF of the top level .ear file. In the jboss-deployment-structure.xml add a dependency for org.jboss.remote-naming and org.jboss.ejb-client.

Here's some documentation on jboss-deployment-strucure.xml: Class Loading in WildFly

Other useful links:

EJB invocations from a remote server instance
ejb-multi-server: EJB Communication Across Servers

Federico Sierra
  • 5,118
  • 2
  • 23
  • 36
0

You'll need to include in your war/WEB-INF/lib directory all dependencies of a remote client:

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-jms-client-bom</artifactId>
        <version>${version.wildfly}</version>
        <type>pom</type>
    </dependency>
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
  • Thanks. but i dont want add libs in war. only server itself. so what are remote lib needs to add in server ? – Shankar S Oct 16 '14 at 09:04
  • Download the bom: `mvn org.apache.maven.plugins:maven-dependency-plugin:2.6:get -Dartifact=org.wildfly:wildfly-jms-client-bom:${version.wildfly}:pom -Ddest=. -U` go to the `dependencies` sections and see – Boris Pavlović Oct 16 '14 at 09:33