geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes Lietz <rmail-geronimo-u...@rmail.dadabase.de>
Subject Re: Exception in thread "main" java.lang.NullPointerException?
Date Tue, 04 Dec 2007 15:39:15 GMT

Simply said: You can't just add a main method to an EJB class and expect it
to run in the same way as it would inside an application server.

You need the whole infrastructure an application server provides, which
does a lot of things behind the scenes. In your class, the server would
"magically" instantiate an object for your member remoteBusinessIntf, which
will do a sayHello(). In your case remoteBusinessIntf is null, and the
error is thrown.

-Johannes


On Tue, 4 Dec 2007 07:23:22 -0800 (PST), beyondjusitn
<beyondjustin@gmail.com> wrote:
> 
> Sorry, but could you be more specific? You know, I'm rather naive, very
> new
> to Java EE. Could you write something like 5-minutes tutorial?
> 
> Thanks a lot.
> 
> Jacek Laskowski wrote:
>>
>> On Dec 4, 2007 2:47 PM, beyondjusitn <beyondjustin@gmail.com> wrote:
>>>
>>> I followed the 5-minute Tutorial on Enterprise Application Development
>>> with
>>> Eclipse and Geronimo. And in my web client the EJB works fine. However,
>>> when
>>> I tested it in my application client, as following:
>>> public class Main{
>>>         @EJB
>>>         private static RemoteBusinessInterface remoteBusinessIntf;
>>>         public static void main(String[] args) {
>>>
>>> System.out.println(remoteBusinessIntf.sayHello("justin"));
>>>         }
>>> I got this error:Exception in thread "main"
>>> java.lang.NullPointerException.
>>
>> I've realized I didn't answer your question, so here it goes again. It
>> won't work unless you're using the concept of javaee5 application
>> client where DI (dependency injection) works. You should deploy your
>> application with an application client and run client.jar with the
>> module id of the application you deploy. It should be clearer now ;-)
>>
>> Jacek
>>
>> --
>> Jacek Laskowski
>> http://www.JacekLaskowski.pl
>>
>>
> 
> 
> -----
> --
> Best Wishes!
> Justin Tsao
> --
> View this message in context:
>
http://www.nabble.com/Exception-in-thread-%22main%22-java.lang.NullPointerException--tf4943169s134.html#a14152277
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message