-
1. Re: Configuration JNDI
benjiii Jan 24, 2008 9:46 AM (in response to benjiii)Sorry, I took the wrong folder... hope you'll help my anyway
-
2. Re: Configuration JNDI
jaikiran Jan 24, 2008 10:42 AM (in response to benjiii)In web.xml you are using ejb-local-ref where as in jboss-web.xml you are using ejb-ref. Change your jboss-web.xml to use ejb-local-ref as follows:
<jboss-web> <ejb-local-ref> <ejb-ref-name>ejb/DataAccessFacade</ejb-ref-name> <jndi-name>ejb/DataAccessFacadeLocalHome</jndi-name> </ejb-local-ref> </jboss-web>
-
3. Re: Configuration JNDI
benjiii Jan 24, 2008 10:54 AM (in response to benjiii)If I do this, I get a clean server start, but when calling the first servlet, I get this error now:
javax.naming.NameNotFoundException: local:ejb not bound
Is this because I use the callDataAccessFacadeLocalHome dataFacadeHome = (DataAccessFacadeLocalHome)getContext().lookup("local:ejb/ejb/com/wag/debeos/DataAccessFacadeLocalHome");
in the code of the servlet?
(;-) you remember - I'm just a rookie trying to get some knowledge, but haven't yet...) -
4. Re: Configuration JNDI
jaikiran Jan 24, 2008 11:03 AM (in response to benjiii)"benjiii" wrote:
(;-) you remember - I'm just a rookie trying to get some knowledge, but haven't yet...)
Ok, so here's how the ejb-local-ref/ejb-ref work.
When you specify the ejb-ref-name then the bean will be bound with the name that you specified in the ejb-ref-name in the JNDI tree in the java:comp/env namespace. So in your case, you specifed the ejb-ref-name as ejb/DataAccessFacade. So the bean will be bound to java:comp/env/ejb/DataAccessFacade. Hence the lookup string in your servlet should be:DataAccessFacadeLocalHome dataFacadeHome = (DataAccessFacadeLocalHome)getContext().lookup("java:comp/env/ejb/DataAccessFacade");
And finally, the best way to debug NameNotFoundException is to look at the JNDI tree:
- Go to http://< server>:< port>/jmx-console (Ex: http://localhost:8080/jmx-console)
- Search for service=JNDIView on the jmx-console page
- Click on that link
- On the page that comes up click on the Invoke button beside the list() method
- The page that comes up will show the contents of the JNDI tree. -
5. Re: Configuration JNDI
benjiii Jan 24, 2008 11:54 AM (in response to benjiii)Do you mean this part of the tree here?
+- env (class: org.jnp.interfaces.NamingContext) | +- ejb (class: org.jnp.interfaces.NamingContext) | | +- DataAccessFacade[link -> local/DataAccessFacade@23482138] (class: javax.naming.LinkRef)
For me it seems correct, or not? But the Nullpointer still is there...
(I changed the lookup like you said) -
6. Re: Configuration JNDI
benjiii Jan 24, 2008 12:01 PM (in response to benjiii)Sorry - moment - I've got an idea... perhaps another part of the code...
-
7. Re: Configuration JNDI
benjiii Jan 24, 2008 12:12 PM (in response to benjiii)Seems to be that my EntityBeans now aren't reachable - the facade now is ok.
Where have I to look to get the correct jndi for the entity beans? Is it defined in an JBoss specific file? (ejb-jar.xml e.g?) -
8. Re: Configuration JNDI
jaikiran Jan 25, 2008 2:30 AM (in response to benjiii)"benjiii" wrote:
Where have I to look to get the correct jndi for the entity beans? Is it defined in an JBoss specific file? (ejb-jar.xml e.g?)
By default the beans will be bound to a default jndi-name. However, if you have manually specified the jndi-name for that bean, then it goes in the jboss.xml file (which is in the same folder as the ejb-jar.xml). -
9. Re: Configuration JNDI
benjiii Jan 25, 2008 11:09 AM (in response to benjiii)Ok - thanks, you helped a lot - perhaps I don't understand everything, but I'm on the way now - and I got an idea about understanding all that.
Now there's the next problem I've got. If I understood right after googling the RAD generates non-JBoss-conform EJBQL - and so the Error tolds me I saw in the log-File. So I made a jbosscmp-jdbc.xml beside the jboss.xml with code for each query:<enterprise-beans> <entity> <ejb-name>Data</ejb-name> <query> <query-method> <method-name>ejbSelectLastId</method-name> <method-params> </method-params> </query-method> <ejb-ql><![CDATA[select max(o.data_id) from Data o]]></ejb-ql> </query> </ejb-name>Data</ejb-name> <!--[... donefor each EJB and query...]--> </entity> </enterprise-beans>
But RAD now gives syntax error - and I'm also not sure, if my file is correct - and will solve the EJB-problems.
For 2.: I also use direct SQL. The lookup for this - I'm not sure, if it will work - what lookup I have to put there? The same as for the EJB's?
Hope for another great answer ;-) -
10. Re: Configuration JNDI
benjiii Jan 25, 2008 11:11 AM (in response to benjiii)Forgot: The RAD doesn't know the ejb-ql-tag... that's the reason for the syntax error...
-
11. Re: Configuration JNDI
jaikiran Jan 26, 2008 8:42 AM (in response to benjiii)what lookup I have to put there? The same as for the EJB's?
I haven't worked with Entity beans. But, if you are asking where to put the jndi-name for your entity beans, then create a file named jboss.xml and add the following contents to it:<jboss> <enterprise-beans> <entity> <ejb-name>Data</ejb-name> <jndi-name>MyEntityBean</jndi-name> </entity> </enterprise-beans> </jboss>
Place this jboss.xml file in the META-INF folder of your ejb jar (the same place where you have the ejb-jar.xml) and deploy the ejb jar.
Then in your code, you can lookup the bean through the jndi-name "MyEntityBean". -
12. Re: Configuration JNDI
benjiii Jan 28, 2008 8:46 AM (in response to benjiii)Hey - it works now! I had to try a while - but now the EJB's and even the direct sql works! Thanks a lot for your great help. I fear I didn't understand everything - but I'm on the way now and happy about it! Thanks!