[jboss-user] [EJB 3.0] - Re: can any one help me - having a bad day with ejb3 server

wiggy do-not-reply at jboss.com
Sun May 27 18:44:21 EDT 2007


felix - thanks but i think have - 

if i put the @Remote (RemoteInterface.class) on the bean then i can find it by JNDI lookup.

if i comment that out and rely on the @Remote on the interface class itself then i dont see to see it.

either way i cant seem to get Dep Inj to work - not even locally in the embeddable container.

I have  created a local bean in the emmbedded appliction client like this 


  | import javax.ejb.EJB;
  | import javax.ejb.Local;
  | import javax.ejb.Stateless;
  | 
  | import app.client.HelloUser;
  | import app.client.HelloUserRemote;
  | 
  | @Stateless
  | public class TestBean implements Test
  | {
  | 
  | 	@EJB (name="HelloUser")
  | 	public HelloUser tstHandler;
  | 
  | 	public void message (String msg)
  | 	{
  | 		
  | 		String retmsg = tstHandler.sayHello(msg);
  | 	}
  | 
  | }
  | 

with an interface like this 


  | import javax.ejb.Local;
  | 
  | 
  | @Local
  | public interface Test 
  | {
  | 	public void message (String msg);
  | }
  | 

and then include the following in my main class 


  | public class ClientApp 
  | {
  | 	@EJB (name="HelloUserRemote")
  | 	public HelloUserRemote tstHandler;
  | 
  | 	@EJB 
  | 	public Test test;
  | 
  | 	public ClientApp () {}
  | 
  | 	public static void main(String[] args) throws Exception 
  | 	{
  | 
  | [all startup stuff]...
  | 
  | 	    //try dependency injection!
  | 		new ClientApp().init ();
  | 		
  | 	    
  | 
  | 		
  | 		//Shut down EJB container
  | 		EJB3StandaloneBootstrap.shutdown();
  | 
  | 	}
  | 	
  | 	public void init()
  | 	{
  | 		//trigger the DI for test
  | 		test.message("try again");
  | 	}
  | 

TestBean is local and exposes the message method - this then calls my remote bean.

in this example when i run it i get an null pointer ref like this

anonymous wrote : 
  | Exception in thread "main" java.lang.NullPointerException
  | 	at ClientApp.init(ClientApp.java:74)
  | 	at ClientApp.main(ClientApp.java:61)
  | 

this implies that the container isnt creating the required TestBean and injecting it.  never mind my external bean DI - i cant even get the local bean to work 

i'm still being stupid somewhere i think

Wiggy 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048946#4048946

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048946



More information about the jboss-user mailing list