[jboss-user] [JNDI and Naming] - Re: lookup a session bean inside a servlet

stefano bertozzi do-not-reply at jboss.com
Thu May 5 06:57:06 EDT 2011


stefano bertozzi [http://community.jboss.org/people/bertoz84] created the discussion

"Re: lookup a session bean inside a servlet"

To view the discussion, visit: http://community.jboss.org/message/603644#603644

--------------------------------------------------------------
one step ahead!

I created the .ear ( EARShop ) that "uses" both the .jar ( BookShop ) and the .war ( WebShop ).
I removed the .jar from the WEB-INF/lib inside the .war ( because during .ear deploy there was a duplicate name error ); to include my beans in my web project i simply added under its properties, to the JavaBuildPath/Projects, my BookShop project.

now while deploying the .ear i can read this:

+12:37:25,110 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:+
 ++ 
+  EARShop/AccessoUtente/local - EJB3.x Default Local Business Interface+
+          EARShop/AccessoUtente/local-bookshop.library.sessionbean.AccessoUtenteLocal - EJB3.x Local Business Interface+

+12:37:25,113 INFO  [org.jboss.ejb3.session.SessionSpecContainer] Starting jboss.j2ee:ear=EARShop.ear,jar=BookShop.jar,name=Carrello,service=EJB3+
+12:37:25,114 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: bookshop.library.sessionbean.Carrello ejbName: Carrello+
+12:37:25,118 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:+
+ + 
+  EARShop/Carrello/local - EJB3.x Default Local Business Interface+
+          EARShop/Carrello/local-bookshop.library.sessionbean.CarrelloLocal - EJB3.x Local Business Interface+

+12:37:25,120 INFO  [org.jboss.ejb3.session.SessionSpecContainer] Starting jboss.j2ee:ear=EARShop.ear,jar=BookShop.jar,name=OperazioniLibri,service=EJB3+
+12:37:25,121 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: bookshop.library.sessionbean.OperazioniLibri ejbName: OperazioniLibri+
+12:37:25,125 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:+

+          EARShop/OperazioniLibri/local - EJB3.x Default Local Business Interface+
+          EARShop/OperazioniLibri/local-bookshop.library.sessionbean.OperazioniLibriLocal - EJB3.x Local Business Interface+

+12:37:25,125 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers+
+12:37:25,127 INFO  [org.jboss.ejb3.session.SessionSpecContainer] Starting jboss.j2ee:ear=EARShop.ear,jar=BookShop.jar,name=BookTestBean,service=EJB3+
+12:37:25,128 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: bookshop.test.BookTestBean ejbName: BookTestBean+
+12:37:25,133 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:+

+          EARShop/BookTestBean/remote - EJB3.x Default Remote Business Interface+
+          EARShop/BookTestBean/remote-bookshop.test.BookTestBeanRemote - EJB3.x Remote Business Interface+
+          EARShop/BookTestBean/local - EJB3.x Default Local Business Interface+
+          EARShop/BookTestBean/local-bookshop.test.BookTestBeanLocal - EJB3.x Local Business Interface+

+12:37:25,134 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers+
+12:37:25,135 INFO  [org.jboss.ejb3.session.SessionSpecContainer] Starting jboss.j2ee:ear=EARShop.ear,jar=BookShop.jar,name=OperazioniUtenti,service=EJB3+
+12:37:25,136 INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: bookshop.library.sessionbean.OperazioniUtenti ejbName: OperazioniUtenti+
+12:37:25,138 INFO  [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:+

*+          EARShop/OperazioniUtenti/local - EJB3.x Default Local Business Interface+*
*+          EARShop/OperazioniUtenti/local-bookshop.library.sessionbean.OperazioniUtentiLocal - EJB3.x Local Business Interface+*

+12:37:25,139 WARN  [org.jboss.ejb3.TimerServiceContainer] EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers+
+12:37:25,147 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/WebShop+
+12:37:47,745 INFO  [STDOUT] interface bookshop.library.sessionbean.OperazioniUtentiLocal+


that means i should lookup my ejbs with this name:
+EARShop/OperazioniUtenti/local+
( EAR_NAME/bean/local, not JAR_NAME/bean/local );
i tried it and i found out that it doesn't work; instead it works if i use: 
+          EARShop/OperazioniUtenti/local-bookshop.library.sessionbean.OperazioniUtentiLocal+

Why are there 2 jndi binding, non-default and default, and here i need to use the default while testing my .jar i use the non-default?


A problem however still persist in the lookup procedure:

+opUser = (OperazioniUtenti) context.lookup("EARShop/OperazioniUtenti/local-bookshop.library.sessionbean.OperazioniUtentiLocal");+

+12:37:47,753 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/WebShop].[somethingServlet]] Servlet.service() for servlet somethingServlet threw exception: java.lang.ClassCastException: $Proxy330 cannot be cast to bookshop.library.sessionbean.OperazioniUtenti+
+          at webinterface.servlet.somethingServlet.doPost(somethingServlet.java:50) [:]+
+          at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [:1.0.0.Final]+
bla bla bla

Do you know how to solve it?

Thank you a lot and sorry for bothering you so much!!!
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/603644#603644]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110505/0a4adc9e/attachment-0001.html 


More information about the jboss-user mailing list