JavaRanch » Java Forums »
Java »
EJB and other Java EE Technologies
| Author |
Problem with EJB 3. Name not bound error
|
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
Hi! I am updating a pre-existing EJB enterprise application. In that there is an EAR file which contains two web modules and one ejb module. In the web modules it is accessing stateless EJBs from the ejb modules. Now when it looks up the stateless ejb, there is a NameNotFoundException. The name that it uses to access the bean is EARfilename/beanName/local and the error is beanName not bound. Now I am new to EJB 3. The book that I read from declared ejb-ref tag in web.xml to declare the EJBs in the web module. But this application is not declaring any ejb-ref tags. The application uses jBoss server and the web module has no context path so it can be accessed directly. So basically is there a need to define the EJB in the client module. If yes, then can this configuration be given globally in the server configurations. I have checked the jmx-console and I cannot find any binding with the name of the EJB. What can I do to solve this problem. Please help in any way that you can. I am very hopeful that you fellow ranchers will help me. :roll: :roll: Please Please Please help me :roll:
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Reza Rahman
author
Ranch Hand
Joined: Feb 01, 2005
Posts: 559
|
|
Ankit, There is no need for ejb-ref in JBoss AS and what you are describing is very achievable. The fact that the EJBs are not in JMX means that the deployment did not happen. Try taking a look at some of the recent threads. You will likely find some answers quicker than having to wait for folks to repeat what they have posted recently :-). Regards, Reza
|
Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
Which version of JBoss do you use? Can you post the output of the JNDITree from the jmx-console? Also please post the logs from the console while your application is being deployed. Update: Oops, did not see Reza's reply when i posted this  [ November 13, 2008: Message edited by: Jaikiran Pai ]
|
[My Blog] [JavaRanch Journal]
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
I don't believe that the author of the book that I am reading (EJB 3 in Action) will come and help me. I will look at some of the recent threads and see if my problem is solved. Jaikiran This is the jmx output Global JNDI Namespace +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair) +- jmx (class: org.jnp.interfaces.NamingContext) | +- invoker (class: org.jnp.interfaces.NamingContext) | | +- RMIAdaptor (proxy: $Proxy47 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt) | +- rmi (class: org.jnp.interfaces.NamingContext) | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef) +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- UserTransactionSessionFactory (proxy: $Proxy15 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory) +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple) +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction) +- Project Dev (class: org.jnp.interfaces.NamingContext) | +- AlterWitBean (class: org.jnp.interfaces.NamingContext) | +- MagicBean (class: org.jnp.interfaces.NamingContext) +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef) +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef) +- queue (class: org.jnp.interfaces.NamingContext) | +- A (class: org.jboss.mq.SpyQueue) | +- testQueue (class: org.jboss.mq.SpyQueue) | +- ex (class: org.jboss.mq.SpyQueue) | +- DLQ (class: org.jboss.mq.SpyQueue) | +- D (class: org.jboss.mq.SpyQueue) | +- C (class: org.jboss.mq.SpyQueue) | +- B (class: org.jboss.mq.SpyQueue) +- topic (class: org.jnp.interfaces.NamingContext) | +- testDurableTopic (class: org.jboss.mq.SpyTopic) | +- testTopic (class: org.jboss.mq.SpyTopic) | +- securedTopic (class: org.jboss.mq.SpyTopic) +- console (class: org.jnp.interfaces.NamingContext) | +- PluginManager (proxy: $Proxy48 implements interface org.jboss.console.manager.PluginManagerMBean) +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef) +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory) +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef) +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair) +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory) I have made the code of my application bold. It has two beans registered but I want a bean named MasterCommanderBean which I cannot see. I am using Netbeans to deploy the project. This is the deployment console output- pre-init: init-private: init-userdir: init-user: init-project: do-init: post-init: init-check: init: deps-jar: deps-j2ee-archive: init: deps-jar: compile: library-inclusion-in-manifest: dist-ear: init: deps-module-jar: deps-ear-jar: init: deps-jar: compile: library-inclusion-in-manifest: dist-ear: deps-jar: library-inclusion-in-archive: library-inclusion-in-manifest: compile: compile-jsps: do-ear-dist: dist-ear: init: deps-module-jar: deps-ear-jar: init: deps-jar: compile: library-inclusion-in-manifest: dist-ear: deps-jar: library-inclusion-in-archive: library-inclusion-in-manifest: compile: compile-jsps: do-ear-dist: dist-ear: pre-pre-compile: pre-compile: do-compile: post-compile: compile: pre-dist: do-dist-without-manifest: do-dist-with-manifest: Building jar: C:\Documents and Settings\user\My Documents\NetBeansProjects\project\dist\project.ear post-dist: dist: pre-run-deploy: Distributing C:\Documents and Settings\user\My Documents\NetBeansProjects\project\dist\project.ear to [org.jboss.deployment.spi.LocalhostTarget@110d0f9] Deploying C:\Documents and Settings\user\My Documents\NetBeansProjects\project\dist\project.ear Waiting for server to start the module http://localhost:8080/ Applicaton Deployed Operation start started Operation start completed post-run-deploy: run-deploy: Browsing: http://localhost:8080// run-display-browser: run-ac: run: BUILD SUCCESSFUL (total time: 1 minute 10 seconds) As I have pointed out, the web module doesn't uses any context name. That I have marked in bold. I don't know if that makes a difference. [ November 13, 2008: Message edited by: Ankit Garg ]
|
 |
Reza Rahman
author
Ranch Hand
Joined: Feb 01, 2005
Posts: 559
|
|
Ankit, I think Jaikiran can take it from here. The web context does not make a difference. Looks like your bean did not deploy. I would look at the log output to see what might be going on. You may have an error or the EAR/EJB-JAR packaging might not be quite right. Regards, Reza
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
But Two of the beans are there in the jmx list (as I made bold in my previous post). Why are others not in the list??? I am confused
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
Originally posted by Ankit Garg: But Two of the beans are there in the jmx list (as I made bold in my previous post). Why are others not in the list???
Reza is right. The beans aren't deployed. What you are seeing in the JNDI tree is a NamingContext under which the proxies would have been registered with a different jndi name, if the beans were deployed. Ankit, which version of JBoss and Java do you use? I have seen some issues reported with JDK 1.6 when used with a particular version of JBoss. You even mention that you are using NetBeans. Do the beans deploy properly if you manually deploy the application in JBoss instead of deploying through the IDE?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
Well I am using jBoss 4.2.3GA and JDK 1.6 Actually I am confused very much. jBoss service is running automatically without my permission. I don't know what is happening. Something is terribly wrong. I downloaded jBoss from sourceforge and started using it straight away using Netbeans without setting the JBOSS_HOME environment variable. As per your recommendation, I started the server manually and when jBoss was deploying my application, this error came 12:49:01,236 ERROR [URLDeploymentScanner] Incomplete Deployment listing: --- Incompletely deployed packages --- org.jboss.deployment.DeploymentInfo@4088e30c { url=file:/E:/ankit/jboss-4.2.3.G/ server/default/deploy/mysql-ds.xml } deployer: org.jboss.deployment.XSLSubDeployer@b18494 status: Deployment FAILED reason: Trying to install an already registered mbea n: jboss.jca:service=LocalTxCM,name=DefaultDS state: FAILED watch: file:/E:/ankit/jboss-4.2.3.G/server/default/deploy/mysql-ds.xml altDD: null lastDeployed: 1226647099908 lastModified: 1226647099877 mbeans: Actually this code uses DataSource. So I created a mysql-ds.xml file in the JBOSS_HOME\server\default\deploy directory. It looks like this I don't what is creating the problems. I also have Apache Tomcat installed. Leave everything aside, I want to start over at a new machine. Can someone guide me on the correct steps to follow so that nothing goes wrong on that one.
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
The DefaultDS comes by default in JBoss through the hsql-ds.xml file. In your mysql-ds.xml you are trying to create the DefaultDS again. I would recommend that you change the mysql-ds.xml to use a different JNDI name instead of
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
|
Jaikiran I have changed the name of the data source. Now I want to manually deploy my EAR file on jBoss. Can you tell me the way hot to do it???
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
|
To deploy the application (EAR, WAR, JAR or any other recognized application format) all you have to do is place it in the %JBOSS_HOME%/server/< serverName>/deploy folder. The server will pick up the application and deploy it.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
|
But then how would I know that there is any deployment error???
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
|
If there are any deployment errors, you will see them on the server console or you can also see them in %JBOSS_HOME%/server/< serverName>/log/server.log file
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
OK here's my last bet. If this doesn't work then I may loose my job This is the console ouput of netbeans file console output This is the server log of the deployment server log These files will be deleted after they are downloaded 10 times. If it happens I will upload them again... Jaikiran, Reza or anyone else PLEASE HELP ME!!!
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
Originally posted by Ankit Garg: OK here's my last bet. If this doesn't work then I may loose my job
First, calm down Second, i can't access those logs. My office firewall block access to those files.
Originally posted by Ankit Garg: Jaikiran, Reza or anyone else PLEASE HELP ME!!!
Let's take this one step at a time. Let's forget about any IDE for a moment. 1) Download JBoss. You have already done this. So this step can be ignored. 2) Do not change anything on the clean installation of JBoss 3) Install JDK 1.5 or 1.6. You already have JDK 1.6. So again you can ignore this step 4) Create an EAR which you want to deploy. I believe you have scripts (maybe Ant scripts) which generates the EAR. 5) You might even need a datasource. I think you already have this (fixed) mysql-ds.xml. 6) Place the mysql-ds.xml in %JBOSS_HOME%/server/default/deploy folder 7) Place the EAR in %JBOSS_HOME%/server/default/deploy folder 8) Open a command prompt and 'cd' to %JBOSS_HOME%/bin 9) Run run.bat 10) Wait for the server to start. Post the logs that you see on the console (command prompt). As i said, let's not jump to next steps before we have completed these steps.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
Well there was a Mapping problem in the code. One of the entity bean was using the mappedBy annotation param to define a non existing type. So I removed it. Still the code shows this error on deployment. This is the console output when I start the server. I have removed redundant information for beans that I thought are not relevant. I have used :: in such places. But if required, I will post the whole code.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
OK, my problem was solved. I installed jBoss 4.0.4 and then it worked. Actually the problem was that jBoss 4.2.3 was not recognizing a OneToMany relationship's mappedBy property from a super class of the referenced class which had a @MappedSuperclass annotation. Anyways thanks Jaikiran for helping me . Without you I couldn't have solved this problem. When I read the console output all the things became clear. Thanks again
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8209
|
|
Ankit, Good to know, you got it working
|
 |
 |
|
|
subject: Problem with EJB 3. Name not bound error
|
|
|
|