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

Error while trying to run StatelessSessionBean

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello All,

Im very new to EJB 3. I was trying to run a very simple SessionBean, and Im getting the NullPointerException. The code are as follows:

BeanClass(serverpack.BeanClass)
--------------------------------
package serverpack;

import javax.ejb.Stateless;

@Stateless
public class BeanClass implements BeanInterface {
public void message() {
System.out.println("Hello World");
}
}
Component Interface(serverpack.BeanInterface)
----------------------------------------------
package serverpack;

import javax.ejb.Remote;

@Remote
public interface BeanInterface {
void message();
}
I compiled these two classes successfully, added them to myapp.ear and deployed them in the GlassFish server.

I wrote a client class, which is as follows:
Client Class: (clientpack.BeanClient)
-------------------------------------
package clientpack;

import javax.ejb.EJB;
import serverpack.*;

public class BeanClient {
@EJB
private static BeanInterface bInterface;

public static void main(String... args) {
bInterface.message();
}
}

When I tried to run this from the command line, I got a NullPointerException. Im sure Im missing some step. Could anyone of you please guide me through this?

Kind Regards,
Rakesh.R
SCJP 6, SCWCD 5.
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hih Rakesh


You must run your class with an ACC application client container, otherwise the normal java ignore the adnotations.


Radards,
M.
 
Rakesh Rajagopalan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks for the reply. Can you please be more elaborate on the ACC? How to invoke it etc.?

Thanks,
Rakesh.R
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Rakesh,

Please do not post the same question in multiple forums https://coderanch.com/t/414913/EJB-JEE/java/Error-while-trying-run-StatelessSessionBean
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic