[jboss-user] [EJB 3.0] - newbie question: ejb3 tutorial examples
Nikola Kolev
do-not-reply at jboss.com
Sat Aug 14 07:47:48 EDT 2010
Nikola Kolev [http://community.jboss.org/people/ntk] created the discussion
"newbie question: ejb3 tutorial examples"
To view the discussion, visit: http://community.jboss.org/message/557408#557408
--------------------------------------------------------------
Hello community,
I'm new to JBoss and the javaEE environment, and after playing around with the tutorials I have come across a problem with the java naming service (simple problem probably but still one I have found hard to overcome)
What I did:
1. I took the "Stateless" tutorial source code and created a .jar from it (without the Client.java).
2. I deployed the new .jar in my JBoss AS distribution, which is the latest JBoss 5 release. Restarted JBoss.
3. I checked if it is deployed correctly on the JBoss admin console.
4. I modified the Client.java the following way ( the underlined code is what I added ).
package org.jboss.tutorial.stateless.client;
import java.util.Hashtable;
import org.jboss.tutorial.stateless.bean.Calculator;
import org.jboss.tutorial.stateless.bean.CalculatorRemote;
import javax.naming.Context;
import javax.naming.InitialContext;
public class Client
{
public static void main(String[] args) throws Exception
{
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext ctx = new InitialContext(properties);
Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");
System.out.println("1 + 1 = " + calculator.add(1, 1));
System.out.println("1 - 1 = " + calculator.subtract(1, 1));
}
}
.... and I received the following exception:
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
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 org.jboss.tutorial.stateless.client.Client.main(Client.java:41)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
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
What am I doing wrong?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/557408#557408]
Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100814/ee68c5fa/attachment.html
More information about the jboss-user
mailing list