- This topic has 5 replies, 2 voices, and was last updated 19 years, 8 months ago by Alejandro Barrero.
-
AuthorPosts
-
Alejandro BarreroParticipantI have not been able to find anything in the documentation. I am trying
public class TestEJB {
public static void main(String[] args) {
InitialContext jndiContext = null;
try {
jndiContext = getContext();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Object o;
try {
o = jndiContext.lookup(“ejb/Stateless”);
} catch (NamingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println(“No problem.”);
}public static InitialContext getContext() throws NamingException {
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,”org.jnp.interfaces.NamingContextFactory”);
props.put(Context.PROVIDER_URL, “localhost:8080”);
props.put(“java.naming.factory.url.pkgs”, “org.jboss.naming”);
return new InitialContext(props);
}
}
But I am getting
javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]Any help will be greatly appreciated.
Alejandro Barrero
Riyad KallaMember
Alejandro BarreroParticipantThank you very much for the tutorials; in particular, the properties for the initial context are invaluable. I modified my program as specified; my ejb now shows in the JMX MBean Operation Result page. Unfortunately i am getting the exception:
javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 6926421946503004889, local class serialVersionUID = 3289509836244263718]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:663)
…
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:51)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:566)
It looks like the class in the client does not match the class in the server. I am puzzled, because I an using the j2ee.jar from the same jdk I am using on JBoss and in the debugger.I will apreciate your help.
Alejandro barrero
Alejandro BarreroParticipantThank you very much for the tutorials; in particular, the properties for the initial context are invaluable. I modified my program as specified; my ejb now shows in the JMX MBean Operation Result page. Unfortunately i am getting the exception:
javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.util.id.GUID; local class incompatible: stream classdesc serialVersionUID = 6926421946503004889, local class serialVersionUID = 3289509836244263718]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:663)
…
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:51)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:566)
It looks like the class in the client does not match the class in the server. I am puzzled, because I an using the j2ee.jar from the same jdk I am using on JBoss and in the debugger.I will apreciate your help.
Alejandro barrero
Riyad KallaMemberYou aren’t deploying the J2EE library JARs with your project out into your WEB-INF/lib dir are you?
Alejandro BarreroParticipantThe code to access an EJB in JBoss from a client is:
//Set up the initial context for JBoss.
InitialContext jndiContext = null;
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”);
properties.put(“jnp.disableDiscovery”, “true”);
try {
jndiContext = new InitialContext(properties);
} catch (NamingException e) {
e.printStackTrace();
}
//Retrieve the home object.
Stateless statelessSession = null;
try {
Object obj = jndiContext.lookup(“Stateless”);
StatelessHome home = (StatelessHome) PortableRemoteObject.narrow(obj, StatelessHome.class);
statelessSession = home.create();
System.out.println(statelessSession.sayHello());
} catch (Exception e1) {
e1.printStackTrace();
}The jars needed are:
j2sdkee1.4x\lib\j2ee.jar
jboss-4.0.1sp1\client\jboss-common-client.jar
jboss-4.0.1sp1\client\jbossx-client.jar
jboss-4.0.1sp1\client\jboss-transaction-client.jar
jboss-4.0.1sp1\client\jpn-client.jar -
AuthorPosts