• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null Pointer Exception in running the HeadFirst Chapter 1 Example

 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic