aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to run a client... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to run a client..." Watch "How to run a client..." New topic
Author

How to run a client...

Ankit Mishra
Ranch Hand

Joined: Jul 15, 2009
Posts: 40
I am having trouble to run a client. Its a simple stand alone program accessing EJB.

My EJB is deployed perfectly on weblogic 9.2 server with entry in the JNDI tree.
but i am not able to make my client run..
Following is the exception I am getting while running through console. It compiled perfectly with all necessary classes.


C:\Users\abhinav\workspace\EJBConverter\src\com\client>java -cp .;c:\j2ee-1.4.jar; ConverterClient
Exception in thread "main" java.lang.NoClassDefFoundError: ConverterClient (wrong name: com/client/ConverterClient)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: ConverterClient. Program will exit.

Below is the client code:





Regards,
Ankit Mishra (SCJP 5.0 93%), (SCWCD 5.0 97%)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42583
    
  65
Change to the C:\Users\abhinav\workspace\EJBConverter\src directory, and then run it like this:

java -cp .;c:\j2ee-1.4.jar com.client.ConverterClient


Ping & DNS - my free Android networking tools app
Ankit Mishra
Ranch Hand

Joined: Jul 15, 2009
Posts: 40
Hey thanks for the solution it worked.

But I am having a naming exception I have posted the client code above can you let me know where I am making mistake.

This is the exception:

Caught an unexpected exception!
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.client.ConverterClient.main(ConverterClient.java:15)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42583
    
  65
Using JNDI in a standalone application is a bit tricky, since the InitialContext is not supplied by any server. You may want to work through the JNDI Tutorial to understand what's going on. It's possible that you need to download the fscontext provider. And, of course, you need to put "ConverterApp" into the context.
Ankit Mishra
Ranch Hand

Joined: Jul 15, 2009
Posts: 40
hmmmm thanks Ulf for your help and time. I have reached till this point:




What's this exception now

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus
at weblogic.jndi.Environment.<clinit>(Environment.java:73)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at com.client.ConverterClient.main(ConverterClient.java:23)

I am really tired working on this from days....


I really appreciate your time and kindness
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42583
    
  65
You'll probably need to add several of WebLogic's jar files. Its documentation should have an example of how to use a remote EJB.
Ankit Mishra
Ranch Hand

Joined: Jul 15, 2009
Posts: 40
Hey I finally ran my first EJB example.

Problem was I was having weblogic service file in my lib (in eclipse).

I removed that and it worked ..

Thanks a lot for your help ulf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run a client...