• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Accessing remote Ejb

 
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers , i was trying a small example and i am facing a problem which i am not able to resolve.

I have an ejb bean which exposes remote service.I have deployed that bean in Jboss App Server.
I made a separate web module project which has a servlet in which i am accessing my remote bean.
like this :

and this is working fine for me.
What i did next was create another web module project which again has a servlet with similar code but deployed this web app in tomcat.
Now after deploying when i try to send request to servlet i get this java.lang.ClassNotFoundException: mypack.MyBeanRemote
i am not able to understand as i am new to this.Why did it work when i deployed it Jboss and why not with Apache.

Regards,
Shroff.
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sagar,

Tomcat doesn't have an EJB-container (or are you using TomEE?), so that won't work (it only contains a Servlet-container)

Regards,
Frits
 
Sagar Shroff
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah i am using Tomcat . And i am aware that tomcat is not an ejb compliant app server.But i thought that ejb annotation was simply an abstract way of doing a JNDI (nothing Ejb specific) , the reason i thought so was because at the end of the day my servlet is going to be deployed in a Web container , so it is going to be managed by a Web container , so i thought that ejb complaint or not being ejb compliant wont make difference.

Regards,
Shroff.
 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Shroff wrote:Yeah i am using Tomcat . And i am aware that tomcat is not an ejb compliant app server.But i thought that ejb annotation was simply an abstract way of doing a JNDI (nothing Ejb specific) , the reason i thought so was because at the end of the day my servlet is going to be deployed in a Web container , so it is going to be managed by a Web container , so i thought that ejb complaint or not being ejb compliant wont make difference.

Regards,
Shroff.



dear Sagar,
even if you used JNDI to do lookup then also you wouldn't have got the reference to the bean. the reason is what Fritz pointed. there is no EJB CONTAINER. in other words there is no deploytime or runtime environment in which ejb's run. there wont be logical namespaces (java:app,java:module,java:global) available for the ejb since all this environment is provided by the ejb container.
 
Sagar Shroff
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

dear Sagar,
even if you used JNDI to do lookup then also you wouldn't have got the reference to the bean. the reason is what Fritz pointed. there is no EJB CONTAINER. in other words there is no deploytime or runtime environment in which ejb's run. there wont be logical namespaces (java:app,java:module,java:global) available for the ejb since all this environment is provided by the ejb container.



If so then i am confused because how i can always do jndi lookup from a normal java standalone application which has no EJB container. Please rectify me where i am getting wrong in my understanding.

Regards,
Shroff
 
gurpeet singh
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dependency injection is a service provided by the container. if there is no container then you cannot use dependency injection. in a stand alone client there is no container environment so you cannot use services provided by the container. when you do jndi lookup from your SE client then you are actually connecting to the naming service of your container and then lookup names from there. you specify the connection properties through the jndi environment and then use container-specific implementation of global jndi names(which are not portable; also I am not sure I have read about portable global jndi names which are new feature of ejb 3.1 that allows to do lookup in a portable manner).
 
Sagar Shroff
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

gurpeet singh wrote:when you do jndi lookup from your SE client then you are actually connecting to the naming service of your container and then lookup names from there. you specify the connection properties through the jndi environment and then use container-specific implementation of global jndi names(which are not portable; also I am not sure I have read about portable global jndi names which are new feature of ejb 3.1 that allows to do lookup in a portable manner).



SE client means standard Java application ? i dint understood What SE means here ? if its java application then how can i connect to the naming service of container , because my java application is not deployed in any application server its a standalone client . I am really confused here . Can you please clarify my doubts . And What does portability means in context to jndi ? Can you also explain as this is a new concept to me in terms of jndi . Also a short defination of global jndi will be really awesome.


Regards,
Shroff.

 
Sagar Shroff
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And one more question which is popping in my mind is suppose if i have an Ejb service running in one application server , and the client who is going to invoke it is a remote client in another application server , So if i want to invoke that serviced then i would do a JNDI Global lookup right ? So thats what global means , for remote access ? And can i use EJB annnotation to get a reference to that remote service if yes then how ? because in the annotation we simply specify the ejb mapping name right ? also how can my remote client can do jndi lookup ? I am damn confused with all the concepts unclear to me like a fog .

Regards,
Shroff.
 
gurpeet singh
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sagar,
java se application means stand-alone java application. let me explain you with a requirement. you have a ejb application running on a remote glassfish server. I want to access your say MyEjbBean from my standalone java application which is running on different physical machine. how would we do it ? . we cannot use @EJB annotation since there is no container environment in which we can run our standalone java application so we wont have dependency injection services . as you know that as per jee specifications , a container has to provide a naming support for the components , so there will be a naming environment on your remote glassfish server under which your ejb components will be bind. now until ejb 3. 0 there was no standardized or portable global jndi names. each vendor has its own format ( refer http://www.theserverside.com/news/1363649/New-Features-in-EJB-31-Part-5). we can connect with our glassfish server from our java standalone application and lookup our ejb's using the naming format provided by the vendor. as told earlier in case of ejb 3.1 this has been standardized . so even though your standalone java application is not running inside a application server , it can access/lookup ejb's or any other resources on your remote glassfish server.
 
Sagar Shroff
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for such good explanation .
I tried one example but it threw an exception i have posted it on the forum. Can you check and help me out ?

Regards,
Shroff
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic