netbeans 5.5 beta2 session bean nullpointerexception

Hi,

I`ve tried to create a simplest stateless remote session bean using netbeans 5.5 beta2 and Sun App Server and access it using an application client (not servlet). It generates nullpointerexception.

Steps to reproduce:

1.Create new Enterprise Project and tick "create application client module".

2.Create new Session bean HelloBean and code it. (Bean has only one method doCall())

3.In the Application client module Main class inject

@EJB

private HelloRemote helloBean;

...

public static void main(String[] args) {

Main m = new Main();

m.helloBean.doCall();

}

4. Deploy the applcation by right clicking on the project and choosing "Deploy Project"

5. Run the App client by right clicking on app-client module and choosing "Run Project"

NullPointerException is thrown on the m.helloBean.doCall() line.

Later I tried to play around with JNDI and ejb-ref names in sun-application-client.xml but it didnt help either.

Does someone have any idea how to fix this thing?

Thanks

[1089 byte] By [vs87777a] at [2007-10-3 5:08:53]
# 1

The problem still exist. Can anyone help please?

Also I found appclient.bat in ..AppServer/bin directory.

If you add your session bean EJB jar to the classpath and leave the rest as it is - it works and it calls the session bean. (You have to put a -client and -mainclass options in the command line)

I decompiled the com.sun.enterprise.appclient.Main class (The one which is used in appclient.bat to see what mechanism it uses to lauch the client class and its really not simple. It even does the injection manually).

I think there must be a question raised whether the IDE allows to run such a clients to test beans or may be it doesnt work just because its beta version.

P.S. Web clients also work. if you create a web client project with a simple servlet and add the bean there - it successfully calls the bean.

vs87777a at 2007-7-14 23:15:06 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

As I know, even in previous version of NetBeans (NB5.5Beta1) there was such problem.

Instead of doing ->Deploy on main project , use ->Run on it , then you will have project deployed and client aplication ran.

You cannot ->Run on application client project, if you want to run client without deploying whole project you have to do this in command line (as you said):

e.g: appclient -client Main

taras_staza at 2007-7-14 23:15:06 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

I have been working on the same problem for a few days.

I've learned that if you have used netbeans to create an "Enterprise Application Client", then you are not creating a remote client application in the traditional since. Instead netbeans packages your app into the glassfish ACC (Application Client Container), and this ("JEE 5 App Client" compliant) client application is "launched" when a client user connects to the applications URL on the server, which uses Java Web Start to download and launch the application on the client machine. Two claimed benifits of this are the local host information gets packed into the clients ENC (JNDI context) (I think this is true, it should be anyway), and with the full server ENC the client has more complete acces to JEE server resources.

I apologize if you knew all this, but it came as a big surprise to me as I investigated the same null pointer problem.

It was hard to learn this as most documentation and discussion these days are focussed on web services. And while I've learned a few things, I have made no progress getting my "Enterprise Application Client" to see my EJB on the server.

I am going to switch to a regular Java class, use old fashoin context look up and rmi for now. Hopefully in the future the documentation will detail running these clients and also assist with trouble shooting failed references.

I am wondering if when you click the net beans run button, or select run after a right click on main, it launches the client correctly since the server has packaged the jar for use with Java Web Start. One would expect netbeans to know this, but...

I am also wondering if it is still the job of the developer to specifiy for the client the local host and port somewhwere, becasue I never read explicitly that it gets done for you, and this would explain the null pointer. But having to do this would not seem compliant with the idea of the "JEE 5 app client"....

Thanks in advance to anyone who knows more.

Jay_Smathersa at 2007-7-14 23:15:06 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...