• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

NullPointerException while using DI

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Im having trouble while using DI. Please help me out. The server that Im using is JBoss 5.

1. Component Interface:
-------------------------


2. Bean Class:
--------------


3. Client:
-------

While running the client, Im getting a NullPointerException. Please indicate me the additional steps that I should follow to correct this.

Kind Regards,
Rakesh.R
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friend,

I saw your code. I think you are implementing EJB first time. Please do not misunderstand. Though I didn't work on JBOSS, but your nullPointerException can be handled by creating new instance of your component interface, which you didn't created in your client code.
Tell me first whether you are implementing local view or remote view of your application. Also tell me which type of EJB bean you are using?

Best regards,
Vaibhav Goel
 
Rakesh Rajagopalan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vaibhav,

Im not implementing EJB for the first time, although Im new to DI. You can find that Im using Stateless Session bean by looking at the @Stateless annotation. You could also find that Im using Remote view using the @Remote annotation. Im not sure what you meant by creating a new instance of Component Interface.

In GlassFish AS, we would use the ACC application client container to run the client. I wanted to find whether there are similar client containers in JBoss as well.

Regards,
Rakesh.R

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In glassfish, you can use the appclient <jar-name> that simply runs the application in the environment of the application server. That is why DI works there.

However, for the said code above, it won't work because you are running the client as a stand alone application. For stand alone application, you need to create a Context supplying the
parameters for the provider(i.e. ORB host, port, provider url). DI on application client will only work if you packaged it within an EAR. I am not sure how to do this in JBoss though.

I suggest creating a new EAR and test the DI functionality in a servlet if the sole purpose is to test the DI functionality.

I hope this helps.
 
Rakesh Rajagopalan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jerwin
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh,

JBoss currently does not support an ACC. You'll have to use lookup instead.

Best regards,
Reza
 
Rakesh Rajagopalan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Reza. That was the info that I was looking for.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Reza Rahman wrote:

JBoss currently does not support an ACC.



It does
 
Reza Rahman
author
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran,

I stand corrected. This is definitely good news. For one, I'll make sure to use this when I update the EJB 3 in Action code for JBoss 5!

Thanks very much.

Best regards,
Reza
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic