File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Null Pointer Exception in running the HeadFirst Chapter 1 Example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Null Pointer Exception in running the HeadFirst Chapter 1 Example" Watch "Null Pointer Exception in running the HeadFirst Chapter 1 Example" New topic
Author

Null Pointer Exception in running the HeadFirst Chapter 1 Example

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Hi Everyone,

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.

Regards
Vijitha
(SCJP 1.5)

----------------------------

[ June 23, 2008: Message edited by: Vijitha Kumara ]
[ June 24, 2008: Message edited by: Vijitha Kumara ]

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Amir Pourteymour
Ranch Hand

Joined: Mar 06, 2008
Posts: 45
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).
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Hi All,

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.
Amir Pourteymour
Ranch Hand

Joined: Mar 06, 2008
Posts: 45
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null Pointer Exception in running the HeadFirst Chapter 1 Example