• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to run a client...

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:



 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ankit Mishra
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic