File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes ejb3 with javaee client helloworld Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb3 with javaee client helloworld" Watch "ejb3 with javaee client helloworld" New topic
Author

ejb3 with javaee client helloworld

Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Hi everyone!
I have started learning ejb3 using the "EJB in Action". But I cant even develop "Hello world" using annotations.
This is my little project:
CLient jsp:

*********
Jsp's backing bean

********
EJB interface:

********
EJB bean:

******
Finally, web-xml

********
All compile great, but injection failes every time. I have read, that deployment descriptors are COMPLETELY OPTIONAL. Can anyone help me with this problem?
Thanks for any reply.
[ March 28, 2008: Message edited by: Max Vaha ]
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi Max,

unfortunately I'm not an expert in EJB but I'd recommend you not starting with a web application to experiment with EJB. You could use a simple Java client application to not make things more complicated than necessary by introducing the web tier in your application.

But there is one thing I know of which could be a problem in your application: You should annotate your local bean interface with @Local. Perhaps this already can solve your problem.

And it's true: You don't have to configure your interfaces and beans with a XML descriptor like you had to in EJB 2.x!

Marco
[ March 28, 2008: Message edited by: Marco Ehrentreich ]
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Thanks for your answer.
Interface is with @Local annotation - error while copy-pasting to site. Now I've edited my first message.
I prefer to use EE clients - it's "native" for me, because I develop web applications.
So even with @Local annotation there is an error in dependency injection ((
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Could you please let us know where do you get which error? Is it at deployment? At runtime? Perhaps you could post the specific error message.

Which container do you use?
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
I am trying to run it on Weblogic 10 now (on my job). But I have tried to run it on Glassfish at home with same result - NullPointerException.
Project compiles and deploys well.
Exception is on runtime.
This is console output:

******
I catch NullPointer in my code and set "Injection failed" value to the message field (in MainPageBean).
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Sorry Max, It seems to be a problem with the SecurityManager but I don't have any experience with Weblogic. And as I already said I'm not an expert in EJB, too.

But I'm confident someone else around here can help you!
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Ok, but can you show any "helloworld" project code (with EE client), which runs correctly on your app server? I can try it on that app server, in example, Glassfish.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hey Max, please check your email. I've sent you a small test application!

-Marco
Rajeev R Tumkur
Greenhorn

Joined: Sep 13, 2007
Posts: 17
Hi Max,
Try learning the EJB3 with the Mikalai Zaikin SCBCD 5.0 study guide.
It can be accessed in the below link. Follow the steps in appendix. It's very easy to install & learn with Eclipse & JBoss.

http://java.boot.by/scbcd5-guide/


_ _____________ _ <br />Regards,<br />Rajeev
Ram Venkat
Greenhorn

Joined: Nov 28, 2007
Posts: 29
Max Vaha ,

Problem with your DI code in MainPageBean class


Through service instance you need to call all business class implementation methods, @EJB annotation should use on service interface in your case service interface in IHelloEJBLocal.

Hope it will help
[ April 02, 2008: Message edited by: Ram Venkat ]

Ram Venkat<br />----------<br />SCJP 1.4<br />SCWCD 1.4<br />SCBCD 5 (In Process..)
Madhura Oak
Greenhorn

Joined: Apr 02, 2008
Posts: 2
Hi Max,

Dependency injection in Weblogic 10 can be used in servlets, listeners, filters and tag handlers. They cannot be used in backing bean.

Please check out this link
http://e-docs.bea.com/wls/docs100/webapp/annotateservlet.html#wp159396

Try using the dependency injection in servlet.

Regards,
Madhura
Max Vaha
Greenhorn

Joined: Nov 27, 2007
Posts: 29
Sorry guys, I have troubles with my inet provider, can't visit forum.
Big thanks to all, now "project" works fine!
I tried to use DI in servlet and it works now!
shabarish vai
Ranch Hand

Joined: May 26, 2008
Posts: 79
hello all,

even am not able to run this ejb3 hello world plase some help

am getting

java.lang.NullPointerException
servlets.testSer.doGet(testSer.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
index.jsp




 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejb3 with javaee client helloworld
 
Similar Threads
WebLogic12C + Eclipse Indigo develop JSF 2.0 with CDI
Spring MVC question
Running a servlet on Tomcat using Eclipse
pushbutton problem
org.springframework.web.servlet.DispatcherServlet noHandlerFound