aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Getting NullPointerException while accessing Local EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Getting NullPointerException while accessing Local EJB" Watch "Getting NullPointerException while accessing Local EJB" New topic
Author

Getting NullPointerException while accessing Local EJB

satyajit bhosale
Greenhorn

Joined: Jun 15, 2006
Posts: 10
hi,

I am getting following exception while accessing local ejb --

java.lang.NullPointerException
at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
at $Proxy0.create(Unknown Source)
at HelloEJBClient.main(HelloEJBClient.java:36)
-------------------------------------------------------------------------

My client code --
HelloEJBClient.java -
--------------------
public class HelloEJBClient {

public static void main(String[] args) {
Hashtable env = new Hashtable();
env.put(Context.SECURITY_PRINCIPAL, "java.naming.security.principal");
env.put(Context.SECURITY_CREDENTIALS, "java.naming.security.credentials");
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");

try {
Context ctx = new InitialContext(env);
Object obj = ctx.lookup("HelloLocalEJB");
HelloEJBHome home = (HelloEJBHome) obj;
HelloEJB helloWorld = home.create();
helloWorld.hello();
} catch(Exception e) {
e.printStackTrace();
}
}
}

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

jboss.xml --
---------

<jboss>
<enterprise-beans>
<session>
<ejb-name> HelloLocalEJB </ejb-name>
<jndi-name> HelloLocalEJB </jndi-name>
<local-jndi-name> HelloLocalEJB </local-jndi-name>
</session>
</enterprise-beans>

<enforce-ejb-restrictions></enforce-ejb-restrictions>
<container-configurations></container-configurations>
<unauthenticated-principal></unauthenticated-principal>

<resource-managers>
</resource-managers>


</jboss>

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

ejb-jar.xml --
-----------

<ejb-jar>

<display-name> HelloLocalEJB</display-name>

<enterprise-beans>
<session>
<ejb-name> HelloLocalEJB </ejb-name>
<local-home> HelloEJBHome </local-home>
<local> HelloEJB </local>

<ejb-class> HelloEJBBean </ejb-class>
<session-type> Stateless </session-type>
<transaction-type> Container </transaction-type>
</session>
</enterprise-beans>

<assembly-descriptor>
<security-role>
<role-name> everyone </role-name>
</security-role>

<method-permission>
<role-name> everyone </role-name>
<method>
<ejb-name> HelloLocalEJB </ejb-name>
<method-intf> Local </method-intf>
<method-name> * </method-name>
</method>
</method-permission>

</assembly-descriptor>

</ejb-jar>

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


Thanks,
satyajit
Lave Kulshreshtha
Ranch Hand

Joined: Oct 21, 2007
Posts: 106
Hi,
Are your remote EJB's working fine on JBoss? Which version of JBoss are you using?

-Lave


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, ITIL V3 Foundation Certification
satyajit bhosale
Greenhorn

Joined: Jun 15, 2006
Posts: 10
yes, Remote ejb works fine.
I am using JBoss 3.2.6, jdk 1.4.2

thanks,
satyajit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting NullPointerException while accessing Local EJB