I have tried the HF chapter 1 example but I get an null Pointer exception in the home.create() in the client code. Code runs successfully up to that point. When I chek (home==null) it returns true.I am using SJSAS 8.2 App server and JDK 1.5. I have done everything according to the book and all the classpaths,JNDIs etc are working fine.
Context ic = new InitialContext(); Object o = ic.lookup("ejb.Advisor");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class); Advice advisor = home.create(); // -----> here it gives a null pointer exception System.out.println( advisor.getAdvice() ); ..............
Any idea about where that could have go wrong will be really appreciated.
You should check first your classpath settings to see if you have included all necessary libraries and files. In addition to that check if you have created those objects in the Application servers (e.g. ConnectionFactory, Queues, or Topics).
Amir, thanks for your reply. I have the j2ee.jar,AppClient.jar(created by the Application server at the time of the deployment) and other classes which i created for the bean, in the classpath. What about this ConnectionFactory, Queues, or Topics etc. ? Do we have to manually create those in the server? Isn't the server's default configuration create those? Can you please tell me how to check that in the server or what is needed to setup to run this application?
thanks in advance, Vijitha.
Joined: Mar 06, 2008
Sorry to get back to you late, but anyway,
Well, there are couple of them by default in any application server. for example you can find destinations such as queues A, B, C, etc. and the same with topics. However, for your own configured destination, you can create new ones, so others using your provider do not change anything in your configuration.
In order to do so, you have to startup the application server (e.g., Jboss), and load the administration UI through their default IP address that they give on their website. Then you should go and create your own destination. Some of these application servers such as Jboss provides you a feature of adding, modifying, or deleting any JMS destination manually in their xml configuration files.
subject: Null Pointer Exception in running the HeadFirst Chapter 1 Example