hi, I am trying to write first hello world program. I have written below code, and it does not work. what is wrong with it? I am using eclipse indigo, ejb3,
jboss 7.1.1. I am able to deploy the
ejb to jboss without any errors.
HelloWorldLocal.java
HelloWorldLocalBean.java
EJBApplicationClientLocal.java
ClientUtilityLocal.java
When I run the EJBApplicationClientLocal.java file, I get below error message:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an
applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.ibytecode.client.EJBApplicationClientLocal.doLookup(EJBApplicationClientLocal.java:26)
at com.ibytecode.client.EJBApplicationClientLocal.main(EJBApplicationClientLocal.java:13)
Exception in
thread "main" java.lang.NullPointerException
at com.ibytecode.client.EJBApplicationClientLocal.main(EJBApplicationClientLocal.java:14)
Looks like some JNDI stuff is missing, that i am not able to figure out. I read through the NoInitialContextException stuff, but dont know what is missing.
I wrote another program looking up on web, with remote session bean, and that worked fine. It used: jboss-ejb-client.properties file with below info. I dont know what is equivalent to that for local session bean (interface) so i did not include that file for local.
Also, I observed 1 key difference when both the ejbs are deployed into jboss server.
For remote session bean where things worked, 1 extra line is generated.
java:global/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld
java:app/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld
java:module/HelloWorldBean!com.ibytecode.business.HelloWorld
java:jboss/exported/HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld
java:global/HelloWorldSessionBean/HelloWorldBean
java:app/HelloWorldSessionBean/HelloWorldBean
java:module/HelloWorldBean
for local session bean, this line is not generated.
java:global/HelloWorldLocalSessionBean/HelloWorldLocalBean!com.ibytecode.business.HelloWorldLocal
java:app/HelloWorldLocalSessionBean/HelloWorldLocalBean!com.ibytecode.business.HelloWorldLocal
java:module/HelloWorldLocalBean!com.ibytecode.business.HelloWorldLocal
java:global/HelloWorldLocalSessionBean/HelloWorldLocalBean
java:app/HelloWorldLocalSessionBean/HelloWorldLocalBean
java:module/HelloWorldLocalBean
Any help is appreciated. Entire code is on my PC.