This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

EJB JNDI NoInitialContext Exception  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

Iam new to EJB. Iam running a simple SLSB application on eclipse using JBOSS 5 AS. Iam getting this exception.


Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: jboss.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: jboss.jndi.WLInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at session.client.Clientside.main(Clientside.java:22)
Caused by: java.lang.ClassNotFoundException: jboss.jndi.WLInitialContextFactory
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.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more

my code is like this:

jndi.properties

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.Provider.url=t3://localhost:8080

client.java

public class Clientside {

/**
* @param args
* @throws Exception
*/

public static void main(String[] args) throws Exception {

Properties p=new Properties();
p.load(new FileInputStream("jndi.properties"));
InitialContext ic = new InitialContext(p);

Add add=(Add)ic.lookup("SampleAppEJB.ejbModule.session.stateless.Add");
System.out.println("the sum is"+add.add(1,2));

}

}
I don't knw where the prblem is. i also added the following jar files to the client application

jbossall-client.jar
jboss-ejb3-common-client.jar
jboss-ejb3-core-client.jar

can any one suggest me the solution . thanks in advance

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this for your JNDI properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming.client
java.naming.factory.provider.url=localhost:1099

I have noticed that your provider is started with "P" instead of "p".
 
raghu gillela
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, thanks for replying it worked but another exception came

Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1640)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1757)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:689)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
at javax.naming.InitialContext.lookup(Unknown Source)
at session.client.Clientside.main(Clientside.java:24)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1609)
... 5 more

i didn't understood where it is comming. can you tell me the solution for this one also .thanks in advance
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to use :

Hashtable hashtable = new Hashtable();

hashtable.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
hashtable.put("java.naming.provider.url", "jnp://localhost:1099");
hashtable.put("java.naming.factory.url.pkgs", "org.jnp.interfaces");

InitialContext context = new InitialContext(hashtable);


some j2ee with jboss5 lib:
 
Samdani masum
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use this library from jboss 5 server : add lib into your project classpath

concurrent.jar
jboss-aop-client.jar
jboss-common-core.jar
jboss-ejb3-common.jar
jboss-ejb3-core.jar
jboss-ejb3-proxy.jar
jboss-ejb3-security.jar
jboss-integration.jar
jboss-javaee.jar
jboss-logging-spi.jar
jboss-remoting-aspects.jar
jboss-security-spi.jar
jbosssx.jar
jboss-transaction-aspects.jar
jmc.jar
jnpserver.jar
jogl.jar
 
raghu gillela
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,thanks for your reply. but still i couldn't solved it. iam using jndi properties file and passing it to the initial context.still do i have to write them in hash table also ?
even though i changed the code to hash code i got exception called name not found exception at look up line.

i have added the jars but i couldn't found some of the jar they are these


i tried to download from net but i couldn't found some of the jars those are :

jogl.jar

their is some difference between the jars you mentioned and i have in my server/client/ libraries are they are same ?

you mentioned i have
jboss-ejb3-core.jar jboss-ejb3-core-client.jar

jboss-ejb3-proxy.jar jboss-ejb3-proxy-client.jar

jboss-ejb3-security.jar jboss-ejb3-security-client.jar

can you help out . thanks in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!