Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.naming.NamingException: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader

I have s problem with Jboss-as-7.1.1. when I deploy it, it deploys properly, but when I send the request from client side I am getting this error:

javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory

MyErrorlog:-

14:18:22,952 INFO  [stdout] (http--127.0.0.1-8080-1) BusinessClass::sendResponse Starts...
14:18:22,953 INFO  [stdout] (http--127.0.0.1-8080-1) Enter the Try Block Edited by vivek
14:18:22,962 ERROR [stderr] (http--127.0.0.1-8080-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.responsecomponent.ear.response.war:main" from Service Module Loader
14:18:22,978 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
14:18:22,996 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:664)
14:18:22,998 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
14:18:23,007 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.naming.InitialContext.init(InitialContext.java:223)
14:18:23,008 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.naming.InitialContext.<init>(InitialContext.java:197)
14:18:23,010 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.jsp.response_jsp._jspService(response_jsp.java:132)
14:18:23,011 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
14:18:23,012 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
14:18:23,014 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
14:18:23,037 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
14:18:23,038 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
14:18:23,040 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
14:18:23,041 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
14:18:23,049 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
14:18:23,051 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
14:18:23,053 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
14:18:23,054 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
14:18:23,064 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
14:18:23,065 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
14:18:23,066 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
14:18:23,068 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
14:18:23,069 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
14:18:23,076 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
14:18:23,078 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
14:18:23,081 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.Thread.run(Thread.java:662)

ServerLog:-

JBoss Bootstrap Environment

  JBOSS_HOME: /home/vivekray/Desktop/vivek/jboss-as-7.1.1.Final

  JAVA: /home/vivekray/Softwares/jdk1.6.0_30/bin/java

  JAVA_OPTS:  -server -XX:+TieredCompilation -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

=========================================================================

14:14:09,212 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
14:14:09,978 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
14:14:10,233 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
14:14:13,122 INFO  [org.xnio] XNIO Version 3.0.3.GA
14:14:13,148 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
14:14:13,224 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
14:14:13,264 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
14:14:13,553 INFO  [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem.
14:14:13,557 INFO  [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
14:14:13,619 INFO  [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem
14:14:13,660 INFO  [org.jboss.as.osgi] JBAS011940: Activating OSGi Subsystem
14:14:13,707 INFO  [org.jboss.as.security] JBAS013101: Activating Security Subsystem
14:14:13,765 INFO  [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension
14:14:13,809 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
14:14:14,204 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default]
14:14:14,260 INFO  [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
14:14:14,514 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
14:14:14,773 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA
14:14:15,739 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
14:14:16,378 WARN  [com.arjuna.ats.arjuna] (Transaction Expired Entry Monitor) ARJUNA012210: Unable to use InetAddress.getLocalHost() to resolve address.
14:14:16,636 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:9999
14:14:16,639 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:4447
14:14:16,717 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /home/vivekray/Desktop/vivek/jboss-as-7.1.1.Final/standalone/deployments
14:14:17,095 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
14:14:17,201 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "responsecomponent.ear"
14:14:24,491 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb-api.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,502 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb-impl.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,515 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jsr173_1.0_api.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,524 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry activation.jar in "/content/responsecomponent.ear/lib/jaxb-xjc-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,539 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb-api.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,548 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry activation.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,564 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jsr173_1.0_api.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,567 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jaxb1-impl.jar in "/content/responsecomponent.ear/lib/jaxb-impl-2.1.7.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,575 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry bcel.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,580 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry jibx-run.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,583 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xpp3.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,585 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry stax-api.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,589 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry wstx-asl.jar in "/content/responsecomponent.ear/lib/jibx-bind-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,594 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xercesImpl.jar in "/content/responsecomponent.ear/lib/xalan-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,596 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xml-apis.jar in "/content/responsecomponent.ear/lib/xalan-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,599 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry serializer.jar in "/content/responsecomponent.ear/lib/xalan-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,602 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry activation.jar in "/content/responsecomponent.ear/lib/mail-1.4.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,613 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry xpp3.jar in "/content/responsecomponent.ear/lib/jibx-run-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,615 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry stax-api.jar in "/content/responsecomponent.ear/lib/jibx-run-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,617 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) Class Path entry wstx-asl.jar in "/content/responsecomponent.ear/lib/jibx-run-1.2.1.jar"  does not point to a valid jar for a Class-Path reference.
14:14:24,630 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "response.war"
14:14:24,633 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "AsyncResponseComponentVer2.jar"
14:14:25,750 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named SPConnectorResponseComponent in deployment unit subdeployment "AsyncResponseComponentVer2.jar" of deployment "responsecomponent.ear" are as follows:

    java:global/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
    java:app/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
    java:module/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
    java:jboss/exported/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBRemote
    java:global/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
    java:app/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
    java:module/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome
    java:jboss/exported/responsecomponent/AsyncResponseComponentVer2/SPConnectorResponseComponent!com.cdac.AsyncSPResponse.SPResponseEJBHome

14:14:26,794 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /response
14:14:26,797 INFO  [org.jboss.as] (MSC service thread 1-3) JBAS015951: Admin console listening on http://127.0.0.1:9990
14:14:26,807 INFO  [org.jboss.as] (MSC service thread 1-3) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 18387ms - Started 222 of 303 services (80 services are passive or on-demand)
14:14:26,958 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "responsecomponent.ear"

MyCode:-

 Context context=null;
    System.out.println("BusinessClass::sendResponse Starts...");
    HashMap ack_gateway=null;
    try {

        System.out.println("Enter the Try Block Edited by vivek");

        //add by vivek

            Properties props = new Properties();
                    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                    props.put(Context.PROVIDER_URL, "remote://localhost:4447");
                    props.put(Context.SECURITY_PRINCIPAL, "testuser");
                    props.put(Context.SECURITY_CREDENTIALS, "testpassword");
                    context = new InitialContext(props);
                System.out.println("\n\tGot initial Context: "+context);
                System.out.println("Got Initial Context");
              SPResponseEJBHome home = (SPResponseEJBHome)  ortableRemoteObject.narrow(context.lookup            ("SPConnectorResponseComponent"),SPResponseEJBHome.class);

        System.out.println("BusinessClass::sendResponse Starts...");

        System.out.println("Got Home object");
        SPResponseEJBRemote remote = home.create();
        System.out.println("Got Remote object");

Any one have some idea please help me ? Thanks vivek

like image 282
vivek rai Avatar asked Oct 06 '22 05:10

vivek rai


2 Answers

I spent a day following tutorials and ebooks (and forum solutions too) for JBoss 6. The main "problem" is JBoss 7 has a different approach for JNDI settings and with InitialContext.

Finally I found a tutorial that saved my day, hope this can help you too:

http://theopentutorials.com/examples/java-ee/ejb3/how-to-create-a-simple-ejb3-project-in-eclipse-jboss-7-1/

How I solved

Props must have only this entry:

props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

Missing jboss-ejb-client.properties in client folder with this content:

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

remote.connections=default

remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

And jboss-client-7.1.0.Final.jar (JBOSS_HOME/bin/client) missing in build path.

Best regards, Daniele.

like image 191
Daniele Vrut Avatar answered Oct 10 '22 21:10

Daniele Vrut


first of all, from the server log I see some warnings related to the classpath so that seems to me that is going to jump out some errors later. Maybe you already solved this but the error you report form the client side almost always relate to the classpath you are using to compile that client, for instance, compile it with:

javac -cp <JBOSS_FOLDER>/bin/client/jboss_client.jar <your src directory>

greetings

like image 43
carlosavoy Avatar answered Oct 10 '22 19:10

carlosavoy