2 Replies Latest reply on Jan 14, 2014 3:43 AM by nschweig

    EJB invoking Problem Jboss 7.1.1 (Example EJB invocations from a remote client using JNDI)

    nschweig

      Hi,

       

      I try to follow the example from :https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI

       

      I am using JBoss 7.1.1. In attachment you see my project structure in Eclipse.

      When I am starting JBoss, there appears the following output:

       

      12:02:34,614 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA

      12:02:34,806 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA

      12:02:34,854 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

      12:02:35,590 INFO  [org.xnio] XNIO Version 3.0.3.GA

      12:02:35,590 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)

      12:02:35,601 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA

      12:02:35,610 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA

      12:02:35,640 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers

      12:02:35,643 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem

      12:02:35,690 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.

      12:02:35,698 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem

      12:02:35,700 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem

      12:02:35,705 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension

      12:02:35,741 INFO  [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)

      12:02:35,745 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

      12:02:35,778 INFO  [org.jboss.as.security] (MSC service thread 1-3) JBAS013100: Current PicketBox version=4.0.7.Final

      12:02:35,786 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)

      12:02:35,801 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem

      12:02:35,828 INFO  [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service

      12:02:35,833 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mail/Default]

      12:02:35,996 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-5) JBoss Web Services - Stack CXF Server 4.0.2.GA

      12:02:36,235 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory C:\jboss-as-7.1.1.Final\standalone\deployments

      12:02:36,242 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found jboss-as-ejb-remote-app.jar in deployment directory. To trigger deployment create a file called jboss-as-ejb-remote-app.jar.dodeploy

      12:02:36,469 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on localhost/127.0.0.1:4447

      12:02:36,482 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-6) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080

      12:02:36,529 INFO  [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on /127.0.0.1:9999

      12:02:36,597 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

      12:02:36,604 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) JBAS010400: Bound data source [java:jboss/datasources/mysqlDS]

      12:02:36,641 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "jboss-as-ejb-remote-app.jar"

      12:02:36,776 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named CalculatorBean in deployment unit deployment "jboss-as-ejb-remote-app.jar" are as follows:

       

          java:global/jboss-as-ejb-remote-app/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator

          java:app/jboss-as-ejb-remote-app/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator

          java:module/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator

          java:jboss/exported/jboss-as-ejb-remote-app/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator

          java:global/jboss-as-ejb-remote-app/CalculatorBean

          java:app/jboss-as-ejb-remote-app/CalculatorBean

          java:module/CalculatorBean

       

      12:02:36,779 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named CounterBean in deployment unit deployment "jboss-as-ejb-remote-app.jar" are as follows:

       

          java:global/jboss-as-ejb-remote-app/CounterBean!org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter

          java:app/jboss-as-ejb-remote-app/CounterBean!org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter

          java:module/CounterBean!org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter

          java:jboss/exported/jboss-as-ejb-remote-app/CounterBean!org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter

          java:global/jboss-as-ejb-remote-app/CounterBean

          java:app/jboss-as-ejb-remote-app/CounterBean

          java:module/CounterBean

       

      12:02:36,924 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015951: Admin console listening on http://127.0.0.1:9990

      12:02:36,925 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 2574ms - Started 193 of 271 services (76 services are passive or on-demand)

      12:02:36,992 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "jboss-as-ejb-remote-app.jar"


      But when I invoke my EJBClient (RemoteEJBClient.java) the following exception appears:


      Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)

          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)

          at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)

          at javax.naming.InitialContext.lookup(InitialContext.java:411)

          at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.lookupRemoteStatelessCalculator(RemoteEJBClient.java:113)

          at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:37)

          at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.main(RemoteEJBClient.java:24)

       

      I googled a lot and spent two days to solve it but I have no idea.

      The Eclipseproject is in the attachment.

      The only thing I changed to the code at https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

      is that I deleted the import import org.jboss.sasl.JBossSaslProvider;

      Do I need that? (not referenced in the Client-Code)

       

      I hope you have any ideas.

      Thanks a lot,

      Nicole


        • 1. Re: EJB invoking Problem Jboss 7.1.1 (Example EJB invocations from a remote client using JNDI)
          wdfink

          Hello Nicole,

           

          from the attached code I did not see that you use "remote://host:port" 

          If you do such you need to have this for the IC:

          jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

          jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");

          // This is an important property to set if you want to do EJB invocations via the remote-naming project

          jndiProps.put("jboss.naming.client.ejb.context", true);

           

          and remote the "ejb:" from the lookup.

          But I recommend to use the ejb-client approach which is used in the quickstart.

           

          BTW I suppose you are German, if you have a change to look into the Java Magazin (5+6 2013) there is an article about ejb-clients with AS7 and EAP6

          • 2. Re: EJB invoking Problem Jboss 7.1.1 (Example EJB invocations from a remote client using JNDI)
            nschweig

            Hello Wolf-Dieter,

             

            thanks for your hints but it the solution was to put the jboss-client.jar into the classpath.

            new_buildpath.jpg

             

            But I think I should take a look into the java magazines anyway... to understand what I am doing ;-)

            Bye

            Nicole