aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Help needed to deploy HelloWorld EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Help needed to deploy HelloWorld EJB" Watch "Help needed to deploy HelloWorld EJB" New topic
Author

Help needed to deploy HelloWorld EJB

Vasanthi hiremath
Ranch Hand

Joined: May 05, 2009
Posts: 35
Hi,

I was following the step by step approch given in Beginning EJB3 Application Development book about the EJB3 Hello World deployment. I am deploying the EJB mannually, that is I am nit using any tool. I am new to EJB3. I deployed the bean it was successfull and I am stuck in Client deployment. I deployed the client as given in the book.But I am getting the following error. Could anyone help me why I am getting the error.. I am trying it since 2 days.

com.sun.enterprise.appclient.UserError: Appclient main-class is not found. Plea
se check the main-class entry of your appclient manifest file, the mainclass com
mand-line argument, and your classpath.
java.lang.ClassNotFoundException:


Regards
Vasanthi


Vasanthi hiremath
Ranch Hand

Joined: May 05, 2009
Posts: 35
Hi,

Can anybody please please..... help me. I set theclasspath of ejb jar file in Manifest.mf file of client Then when i use the command appclient to run the client i am getting the following exception


C:\EJBSamples\HelloWorldProject\dist>appclient -client helloworldapp.jar
11-Jun-2009 13:52:28 com.sun.enterprise.appclient.MainWithModuleSupport <init>
WARNING: ACC003: Application threw an exception.
com.sun.enterprise.InjectionException: Exception attempting to inject Resolved Ejb-Ref helloworld.client.Hell
oWorldClient/helloWorld@jndi: - > HelloWorldBean into class helloworld.client.HelloWorldClient
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: javax.naming.NameNotFoundException: #helloworld.ejb.HelloWorld not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.j
ava:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerReque
stDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatc
herImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorI
mpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:
1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:
223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563
)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)

at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Exception in thread "main" java.lang.RuntimeException: com.sun.enterprise.InjectionException: Exception attem
pting to inject Resolved Ejb-Ref helloworld.client.HelloWorldClient/helloWorld@jndi: - > HelloWorldBean into
class helloworld.client.HelloWorldClient
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:487)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Resolved Ejb-Ref helloworld.
client.HelloWorldClient/helloWorld@jndi: - > HelloWorldBean into class helloworld.client.HelloWorldClient
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
... 2 more
Caused by: javax.naming.NameNotFoundException: #helloworld.ejb.HelloWorld not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.j
ava:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerReque
stDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatc
herImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorI
mpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:
1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:
223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563
)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)

at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)

C:\EJBSamples\HelloWorldProject\dist>appclient -client helloworldapp.jar
11-Jun-2009 13:56:05 com.sun.enterprise.appclient.MainWithModuleSupport <init>
WARNING: ACC003: Application threw an exception.
com.sun.enterprise.InjectionException: Exception attempting to inject Resolved Ejb-Ref helloworld.client.Hell
oWorldClient/helloWorld@jndi: - > HelloWorldBean into class helloworld.client.HelloWorldClient
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: javax.naming.NameNotFoundException: #helloworld.ejb.HelloWorld not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.j
ava:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerReque
stDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatc
herImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorI
mpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:
1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:
223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563
)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)

at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Exception in thread "main" java.lang.RuntimeException: com.sun.enterprise.InjectionException: Exception attem
pting to inject Resolved Ejb-Ref helloworld.client.HelloWorldClient/helloWorld@jndi: - > HelloWorldBean into
class helloworld.client.HelloWorldClient
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:487)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Resolved Ejb-Ref helloworld.
client.HelloWorldClient/helloWorld@jndi: - > HelloWorldBean into class helloworld.client.HelloWorldClient
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:144)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:136)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:420)
... 2 more
Caused by: javax.naming.NameNotFoundException: #helloworld.ejb.HelloWorld not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.j
ava:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerReque
stDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatc
herImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorI
mpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:
1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:
223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.jav
a:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563
)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)

at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)

C:\EJBSamples\HelloWorldProject\dist>



PLSSSSSSSSSSSSSSSSSSSSSSSSS help me.


Many Thanks
Vasanthi
Marcos Serrano
Ranch Hand

Joined: Jul 13, 2006
Posts: 46
See one of my examples, I am using JBoss:







And client:


The jndi.properties file:



Hope it helps...


toutes les jours
Vasanthi hiremath
Ranch Hand

Joined: May 05, 2009
Posts: 35
Hi,

Actually in my EJB I am not using the JNDI properties, is it must?? if so then where will I put that file & how to deply it... please tell me...

kind regards
vasanthi
Vasanthi hiremath
Ranch Hand

Joined: May 05, 2009
Posts: 35
Hello I am waiting for some reply, please help me. My code looks like this

Remote interface

package helloworld.ejb;
import javax.ejb.Remote;
@Remote
public interface HelloWorld {
public String outputHelloWorld();
}

Bean class


package helloworld.ejb;
import javax.ejb.Stateless;
@Stateless
public class HelloWorldBean implements helloworld.ejb.HelloWorld {
public String outputHelloWorld() {
return "Hello World!";
}
}


And my client

package helloworld.client;
import javax.ejb.EJB;
import helloworld.ejb.HelloWorld;
public class HelloWorldClient {
@EJB
private static HelloWorld helloWorld;
public static void main (String[] args)
{
System.out.println(helloWorld.outputHelloWorld());
}
}

Manifest file

Manifest-Version: 1.0
Main-Class: helloworld.client.HelloWorldClient

And the last application.xml


<?xml version="1.0" encoding="UTF-8"?>
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_5.xsd">
<display-name>helloworldejb</display-name>
<module>
<ejb>helloworldejb.jar</ejb>
</module>
<module>
<java>helloworldclient.jar</java>
</module>
</application>


I have been working on it more than a week, I am not able to continue my study as I am stuck , I am not using any JNDI properties file I would really appriciate an early response. The server I am using is glassfish & I am not using an IDE.

Regards
Vasanthi
Sai Surya
Ranch Hand

Joined: Feb 08, 2006
Posts: 459

Hi Vasanthi,

Since you are trying to access EJB3 from outside (I mean outside of EJB container) you need to use JNDI look up to get a reference of the bean. Refer to the previous reply for the code example. If you access EJB from servlet which deployed in the same container you can use DI. Or else you need to use look up.

Hope this helps.

Sai Surya, SCJP 5.0, SCWCD 5.0, IBM 833 834
http://sai-surya-talk.blogspot.com, I believe in Murphy's law.
Vasanthi hiremath
Ranch Hand

Joined: May 05, 2009
Posts: 35
Hi Sai,

I took this example from Beginning EJB3 Application Development book, in that the author has not told anything about the JNDI look up. So if I have to call EJB from a stand alone java application should I have to user JNDI look up?? Also i don't know where to store the file during the package and also how to write the JNDI properties, is there any link where I get the step by step approach.

Many Thanks
Vasanthi
Sai Surya
Ranch Hand

Joined: Feb 08, 2006
Posts: 459

Vasanthi hiremath wrote:Hi Sai,

I took this example from Beginning EJB3 Application Development book, in that the author has not told anything about the JNDI look up. So if I have to call EJB from a stand alone java application should I have to user JNDI look up?? Also i don't know where to store the file during the package and also how to write the JNDI properties, is there any link where I get the step by step approach.

Many Thanks
Vasanthi


Hello Vasanthi,

The following link may help you.

http://www.webagesolutions.com/knowledgebase/javakb/jkb005/index.html

and yes, since client is outside the EJB container we need to use JNDI look up and no need for any properties. You can use annotations approach for JNDI lookup. Look at the above link.

Vasanthi hiremath
Ranch Hand

Joined: May 05, 2009
Posts: 35
Finally I am successfull....

Thanks a tonn Sai Surya...

Kind Regards
vasanthi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed to deploy HelloWorld EJB