• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Invoking EJB from standalone java client in JBoss7

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there ! I'm new to ejb. Using Eclipse and Jboss server. I've deployed an EJB and now want to invoke it using a standalone java program. I know that Eclipse and JBoss do some job to bind JNDI names. I just want to know that how to lookup EJB by which JNDI binding out of 6 options available (shown in deployment console) there.

Here I'm dropping all my java code and server/console logs please help...

LibrarySessionBeanRemote



LibrarySessionBean


jndi.properties


jboss-ejb-client.properties


EJBTester


After deployment, when I run EJBTester.java, I'm getting the following server logs...


Please also observe property files if any mistake I made here...
And I also hv disabled the security-realm of JBoss to remove extra disturbances....
 
Author
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typically if you want to use an EJB you use it inside of the EE server. However, if you are writing an stand alone application what you need to do is run you application inside the EE application client container. This is not something which is used much. Typically (and much more easy) is to expose your EJB functionality as a RESTful or full Web Service and have your client call them. However if you want to use the EJB, your application need to run inside the EE application client container. I don't know how JBoss does it, but basically what you do is execute a command which comes with your EE server to "wrap" your application with the EE server's application client container. You'll need to research how JBoss does this.
 
Sheriff
Posts: 22802
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not necessary Michael. If the EJB is running in an existing application, then you can access them from standalone programs (or even other applications) through their remote interfaces. You need to look them up explicitly though, no injection.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi how you  resolve this issue. i am facing same issue.
 
Saloon Keeper
Posts: 28121
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EJB container (Wildfly, for example) publishes a JNDI service. Your standalone client just needs to be told the network address and port that the JNDI server listens on. Then your client submits a JNDI lookup request using the bean's logical identifier as the search string and the JNDI server will return a remote interface which serves as a proxy for the EJB. You invoke that proxy's methods and the corresponding method logic on the EJB server is executed.

Of course, EJB3 doesn't automatically create remote support objects like EJB version 1 did, so you do have to have explicitly defined the bean for remote invocation.
 
kannan vimal
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This  below  is   my  client    invocation


Errorlog



19:44:10,169 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
19:44:10,636 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
19:44:10,686 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
19:44:13,824 INFO  [org.xnio] XNIO Version 3.0.3.GA
19:44:13,826 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
19:44:13,835 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
19:44:13,843 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
19:44:13,888 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
19:44:13,908 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.7.Final
19:44:13,991 INFO  [org.jboss.as.connector] (MSC service thread 1-5) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
19:44:14,783 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
19:44:14,940 INFO  [org.jboss.as.naming] (MSC service thread 1-5) JBAS011802: Starting Naming Service
19:44:14,955 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-7) JBAS015400: Bound mail session [java:jboss/mail/Default]
19:44:14,998 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-8) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080
19:44:16,684 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
19:44:16,933 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-6) JBoss Web Services - Stack CXF Server 4.0.2.GA
19:44:17,613 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on localhost/127.0.0.1:4447
19:44:17,613 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on localhost/127.0.0.1:8999
19:44:17,618 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) JBAS015012: Started FileSystemDeploymentService for directory C:\param\learning\softwares\jboss-as-7.1.1.Final\jboss-as-7.1.1.Final\standalone\deployments
19:44:17,631 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found EjbExample.jar in deployment directory. To trigger deployment create a file called EjbExample.jar.dodeploy
19:44:17,988 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "EjbExample.jar"
19:44:18,032 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5) Class Path entry javax.ejb-3.1.jar in "/C:/param/learning/softwares/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/standalone/deployments/EjbExample.jar"  does not point to a valid jar for a Class-Path reference.
19:44:18,033 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5) Class Path entry jboss-client.jar in "/C:/param/learning/softwares/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final/standalone/deployments/EjbExample.jar"  does not point to a valid jar for a Class-Path reference.
19:44:18,266 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named ExampleBean in deployment unit deployment "EjbExample.jar" are as follows:

java:global/EjbExample/ExampleBean!com.ejbs.ExampleBeanRemote
java:app/EjbExample/ExampleBean!com.ejbs.ExampleBeanRemote
java:module/ExampleBean!com.ejbs.ExampleBeanRemote
java:jboss/exported/EjbExample/ExampleBean!com.ejbs.ExampleBeanRemote
java:global/EjbExample/ExampleBean!com.ejbs.ExampleBeanLocal
java:app/EjbExample/ExampleBean!com.ejbs.ExampleBeanLocal
java:module/ExampleBean!com.ejbs.ExampleBeanLocal

19:44:18,558 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015951: Admin console listening on http://127.0.0.1:8990
19:44:18,559 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 9236ms - Started 173 of 250 services (76 services are passive or on-demand)
19:44:18,629 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "EjbExample.jar"
19:44:38,333 INFO  [org.jboss.as.naming] (Remoting "par-pc" task-4) JBAS011806: Channel end notification received, closing channel Channel ID 603862b4 (inbound) of Remoting connection 75629b42 to /127.0.0.1:49445

Kindly help  me to resolve
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic