• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Still having problem with my first EJB3

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still confused with how to interact with the JNDI, here is my simple code to display hello, so could someone tell me what's wrong ?

1 - error message tha I got
Exception in thread "main" 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(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at sourceClient.HelloClient.main(HelloClient.java:21)

2 - My EJB class and interface:





3 - My EJB client
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

from a quick look your examples looks alright!

The problem is the JNDI lookup. You have to know the right lookup name and you most probably have to specify some system parameters which tell the client for example on which IP address and port it may connect to a JNDI provider.

Both of these things may depend on the application server (at least with EJB 3.0) you're using! So perhaps you can tell us which server it is or you can search yourself on the internet which are the correct settings for your server!

Marco
 
Mamadou Touré
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

I'm using Glassfish server

Do I have to setup something on the server ?
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

from the header of your code fragments I guess you used NetBeans to create the project. Perhaps it's the easiest way to understand the problem by having a look at this tutorial. In particular the section "Creating a Java Stand-Alone Client" will be helpful as it describes how to setup the JNDI parameters with a "jndi.properties" file on the classpath ;-)

Additionally it could be useful for debugging to show what's in the JNDI lookup of Glassfish as described here.

Marco
 
Ranch Hand
Posts: 463
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marco,

Perhaps you can try using name attribute for your @Stateless annotation and use that name in the JNDI look up. It worked for me in Glashfish app. server.


 
reply
    Bookmark Topic Watch Topic
  • New Topic