File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes How does Jboss 7 AS registers JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How does Jboss 7 AS registers JNDI" Watch "How does Jboss 7 AS registers JNDI" New topic
Author

How does Jboss 7 AS registers JNDI

Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
I've a simple session bean which implements a remote interface.



Above bean and it's interface is packaged in a jar. This jar is then deployed in JBoss 7 correctly. I can access the bean remotely from a client application. On the console I can see how JBoss registers the bean in the JNDI.

JNDI bindings for session bean named LTextsEjbBean in deployment unit deployment "ecospeedtext-1.0.jar" are as follows:

java:global/ecospeedtext-1.0/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:app/ecospeedtext-1.0/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:module/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:jboss/exported/ecospeedtext-1.0/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:global/ecospeedtext-1.0/LTextsEjbBean
java:app/ecospeedtext-1.0/LTextsEjbBean
java:module/LTextsEjbBean

JNDI bindings for session bean named LTextsEjb in deployment unit deployment "ecospeedtext-1.0.jar" are as follows:

java:global/ecospeedtext-1.0/LTextsEjb!com.ecospeed.text.ejb.LTextsEjbRemote
java:app/ecospeedtext-1.0/LTextsEjb!com.ecospeed.text.ejb.LTextsEjbRemote
java:module/LTextsEjb!com.ecospeed.text.ejb.LTextsEjbRemote
java:jboss/exported/ecospeedtext-1.0/LTextsEjb!com.ecospeed.text.ejb.LTextsEjbRemote
java:global/ecospeedtext-1.0/LTextsEjb
java:app/ecospeedtext-1.0/LTextsEjb
java:module/LTextsEjb



The jar which contains the session bean will need to access other jars, so I need to package all the jars in an EAR file.

When I deploy this ear file, I don't see JBoss registering the session bean in the JNDI anymore. Also, the remote client is not working anymore. It throws an exception:

javax.naming.NameNotFoundException

My question : why is JBoss not registering the beans anymore ... or better ... what do I have to do so that JBoss sees the beans and registres them in JNDI ?

Many thanks, Frank
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10101
    
164

What logs do you see on the console when you deploy it as a .ear? Also what's the output of:

jar -tf yourear.ear

[My Blog] [JavaRanch Journal]
Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
jar -tf ecospeedtextear-1.0.ear

META-INF/
META-INF/MANIFEST.MF
lib/
lib/commons-codec-1.5.jar
lib/ecospeedtext-1.0.jar
lib/jcl-over-slf4j-1.7.5.jar
lib/junit-3.8.1.jar
lib/log4j-1.2.17.jar
lib/mediacreative-1.0.jar
lib/mysql-connector-java-5.1.18.jar
lib/poi-3.9.jar
lib/slf4j-api-1.7.5.jar
lib/slf4j-log4j12-1.7.5.jar
lib/slf4j-nop-1.7.5.jar
lib/slf4j-simple-1.7.5.jar
META-INF/application.xml
META-INF/maven/
META-INF/maven/com.ecospeed.text/
META-INF/maven/com.ecospeed.text/ecospeedtextear/
META-INF/maven/com.ecospeed.text/ecospeedtextear/pom.xml
META-INF/maven/com.ecospeed.text/ecospeedtextear/pom.properties


The output of the JBoss console :

Calling "C:\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
===============================================================================

JBoss Bootstrap Environment

JBOSS_HOME: C:\jboss-as-7.1.1.Final

JAVA: C:\Program Files\Java\jdk1.7.0_45\bin\java

JAVA_OPTS: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jb
ning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.config=standalone.xml

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

13:11:36,064 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
13:11:36,365 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
13:11:36,404 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
13:11:37,325 INFO [org.xnio] XNIO Version 3.0.3.GA
13:11:37,325 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
13:11:37,333 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
13:11:37,340 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
13:11:37,359 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
13:11:37,629 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
13:11:37,749 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
13:11:37,820 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
13:11:37,844 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
13:11:37,879 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
13:11:37,913 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
13:11:38,394 INFO [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.7.Final
13:11:38,713 INFO [org.jboss.as.connector] (MSC service thread 1-13) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
13:11:38,886 INFO [org.jboss.as.naming] (MSC service thread 1-10) JBAS011802: Starting Naming Service
13:11:39,922 INFO [org.jboss.as.mail.extension] (MSC service thread 1-12) JBAS015400: Bound mail session [java:jboss/mail/Default]
13:11:40,724 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-15) JBoss Web Services - Stack CXF Server 4.0.2.GA
13:11:40,826 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
13:11:41,176 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-10) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
13:11:44,106 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-9) JBAS015012: Started FileSystemDeploymentService for directory C:\jboss-as-7.1.1.Final\standalone\deployments
13:11:44,245 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:4447
13:11:44,246 INFO [org.jboss.as.remoting] (MSC service thread 1-11) JBAS017100: Listening on /127.0.0.1:9999
13:11:44,865 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
13:11:45,106 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
13:11:45,108 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 9300ms - Started 133 of 208 services (74 services are passive or on-demand)
13:11:50,391 INFO [org.jboss.as.repository] (HttpManagementService-threads - 2) JBAS014900: Content added at location C:\jboss-as-7.1.1.Final\standalone\data\content\97\3ca8e6bd6f39ce3d39f62ee4540d2fe0d3ae57\content
13:11:54,577 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "ecospeedtextear-1.0.ear"
13:11:56,549 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
13:11:56,930 INFO [org.jboss.as.server] (HttpManagementService-threads - 2) JBAS018559: Deployed "ecospeedtextear-1.0.ear"

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10101
    
164

What's the name of the jar which contains the EJBs and where in the .ear is it located? I don't see any jar at the root of the .ear and all the jars seem to have been packaged as libraries in lib folder. Also, what does your application.xml look like?
Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
The jar which contains the ejb : ecospeedtext-1.0.jar
It's location is in the lib directory. Should the ejb jar be at the root of the ear ?

The content of application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>ecospeedtextear</display-name>
<library-directory>lib</library-directory>
</application>

thanks, Frank
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10101
    
164

Move it out of the lib folder and place it right at the root within the .ear.
Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
I've put it in the root, redeployed it, but still the console doesn't show that jndi has new entires.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10101
    
164

Please repost the new output of:



and



and also the new console logs.
Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
jar -tf ecospeedtextear-1.0.ear



jar -tf ecospeedtext-1.0.jar



console






Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
I've created a new project from maven archtype (Jboss ...). I had to rename because of Maven.
The ear file is now : ecospeedtextear1-ear.ear
The EJB jar is now : ecospeedtextear1-ejb.jar

The ear looks like this




On the console, I can see that JBoss is adding entries.




The bindings which are important are

java:global/ecospeedtextear1-ear/ecospeedtextear1-ejb/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:app/ecospeedtextear1-ejb/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:module/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:jboss/exported/ecospeedtextear1-ear/ecospeedtextear1-ejb/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote
java:global/ecospeedtextear1-ear/ecospeedtextear1-ejb/LTextsEjbBean
java:app/ecospeedtextear1-ejb/LTextsEjbBean
java:module/LTextsEjbBean


Now, from a java client, I do a lookup :




I can see on JBoss log, the connection request due to --> new InitialContext(props);


But when context.lookup(...) is called , the following exception:





Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10101
    
164

From the remote client, you won't have access to java:global namespace. Instead you are allowed access to java:jboss/exported which is what the remote-naming defaults to. So change the JNDI lookup in your remote client code to:

Frank VanOor
Ranch Hand

Joined: Jun 18, 2004
Posts: 49
I removed the prefix from the context lookup , and now I can access the bean.
ctx.lookup("ecospeedtextear1-ear/ecospeedtextear1-ejb/LTextsEjbBean!com.ecospeed.text.ejb.LTextsEjbRemote");

Many thanks !!!

Frank
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does Jboss 7 AS registers JNDI