This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes naming exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "naming exception" Watch "naming exception" New topic
Author

naming exception

santosh gunake
Greenhorn

Joined: May 20, 2006
Posts: 6
Hi I am new to EJB running my first application am getting the
following exception

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enter
rise.naming.SerialInitContextFactory. Root exception is java.lang.ClassNotFoun
Exception: com.sun.enterprise.naming.SerialInitContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.ja
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
49)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:24
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at HelloClient.main(HelloClient.java:11)

jndi.properties file is

java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs=com.sun.enterprise.naming

and classpth includes
set classpath=C:\JBOSS\jboss-3.0.8_tomcat-4.1.24\server\all\lib\jboss-j2ee.jar;


thankx in advance
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well, there is a mismatch between the App Server you are using and the values in your JNDI porperties which looks like they are trying to reach a Sun Enterprise App Server.

For JBoss you need the following in your jndi.properties file instead

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
santosh gunake
Greenhorn

Joined: May 20, 2006
Posts: 6
Hi

now am getting the following error

javax.naming.CommunicationException: Receive timed out. Root exception is java.
net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive(Native Method)
at java.net.DatagramSocket.receive(DatagramSocket.java:671)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:10
23)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1112)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:479)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:472)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at HelloClient.main(HelloClient.java:16)

Client code

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");
System.out.println("1");
InitialContext ctx = new InitialContext(env);
System.out.println("2");
Object obj = ctx.lookup("ejb/HelloTest");
System.out.println("3");
HelloHome home = (HelloHome)PortableRemoteObject.narrow(obj, HelloHome.class);
System.out.println("4");
HelloRemote remote = home.create();
System.out.println(remote.hello());
remote.remove();

ejb-jar.xml

<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>HelloHome</home>
<remote>HelloRemote</remote>
<ejb-class>HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>


jboss.xml

<jboss>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<jndi-name>ejb/HelloTest</jndi-name>
</session>
</enterprise-beans>

<resource-manager>
</resource-manager>

</jboss>

and application.xml

<application>
<module>
<ejb>SimpleStateless.jar</ejb>
</module>
</application>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: naming exception