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 Certification (SCBCD/OCPJBCD) and the fly likes my first ejb program and finding it hard to run ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Reply Bookmark "my first ejb program and finding it hard to run ?" Watch "my first ejb program and finding it hard to run ?" New topic
Author

my first ejb program and finding it hard to run ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 867

hi,
i'm trying to run a simple hello world kind of ejb program in eclipse. here is what i did.

i created a new enterprise application project. after that there was an option of NEW MODULE . i clicked on it and it gave me option of creating default module. i created application client module and ejb module.

IN EJB MODULE:

i have a POJI and a POJO which is a stateless bean as given below :



in the application client module i have :

package ejb3inaction.example;

import javax.ejb.EJB;



so in project explorer i have an enterprise application project with 2 modules viz. ejb module and client module. i right clicked enterprise project and clicked run on server. then i exported the application client module project as export > application client jar file. i placed the jar file in the location of appclient binary of glassfish. i invoked appclient - client Testclient.jar and it gave me error that it cannot find class HelloUser.

i have included ejb moduel project in build path of application module. Please help ?

if i dont create enterprise application project but just create ejb project and put all 3 files in the single project then it runs fine.

please help

thanks and regards


OCPJP 6(100 %) OCEWCD 6(91 %)
Frits Walraven
Rancher

Joined: Apr 07, 2010
Posts: 1039

Hi Gurpeet,

Trying to access an EJB from a Java SE project or the ACC (Application Client Container) is always a bit tricky as you need to configure some things manually. The best way is to test from a Servlet, as you are now quite familiar with Servlets. Injection of an EJB in a Servlet doesn't need any extra configuration.

Did you read the Oracle ACC article?

You can also try if the lookup from the JNDI (replace ApplicationClientContainerTest with your ear-project name and ApplicationClientContainerTestEJB with your EJB-project name) works:

Regards,
Frits
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: my first ejb program and finding it hard to run ?
 
Similar Threads
Problem facing while creating EJB3 application in Netbeans
@EJB annotation from servlet and JBoss
EJB simple client is not running
How to run Hello World example in Eclipse with Glassfish v3 as appserver
Stateless session bean keeping state???