aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB JNDI NoInitialContext Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB JNDI NoInitialContext Exception" Watch "EJB JNDI NoInitialContext Exception" New topic
Author

EJB JNDI NoInitialContext Exception

raghu gillela
Greenhorn

Joined: Oct 17, 2011
Posts: 3
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.namingrg.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

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

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".


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
raghu gillela
Greenhorn

Joined: Oct 17, 2011
Posts: 3
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
Samdani masum
Greenhorn

Joined: Oct 10, 2010
Posts: 3
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
Greenhorn

Joined: Oct 10, 2010
Posts: 3
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

Joined: Oct 17, 2011
Posts: 3
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB JNDI NoInitialContext Exception