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 :
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.
thanks and regards
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:
On the server computer, I have this:
On my client computer, I ran http://123.456.78.90:8080/HelloApplication-war/HelloClientServlet from my Firefox browser, where 123.456.78.90 is replaced by my server's IP address.
It works and prints "Hello George" on the browser.
But on my client computer, I ran HelloClient, which is a standalone client, I got this error:
My conclusion: The standalone client cannot look up the address of the HelloApplication.ear file and cannot even find the HelloApplication-ejb.jar.
The remote servlet client can connect to the server over HTTP.
Once you acquire the right context, the URL that you have mentioned will work.
You might want to go through a good book that explains this or search for articles online.
The Application Client Container (ACC) includes a set of Java classes, libraries, and other files that are required for and distributed with Java client programs that execute in their own Java Virtual Machine (JVM). The ACC manages the execution of Java EE application client components (application clients), which are used to access a variety of Java EE services (such as JMS resources, EJB components, web services, security, and so on.) from a JVM outside the Oracle GlassFish Server.
The ACC communicates with the GlassFish Server using RMI-IIOP protocol and manages the details of RMI-IIOP communication using the client ORB that is bundled with it. Compared to other Java EE containers, the ACC is lightweight.
The difficulty of how to get the right Context, as Paul was pointing out, is handled by the ACC.