-
1. StreamCorruptedException: unexpected block data on simple JN
myawn Nov 2, 2005 10:42 AM (in response to psseshwari)I have the same issue described by the original post (which doesn't seem to have garnered any replies)
Here is a complete program which exhibits the error:public class EJB30Client { public static void main(String[] args) throws Exception { InitialContext ctx = getInitialContext(); WSDLMgrRemote mgr = (WSDLMgrRemote)ctx.lookup(WSDLMgrRemote.class.getName()); } public static InitialContext getInitialContext() throws Exception { Hashtable props = getInitialContextProperties(); return new InitialContext(props); } private static Hashtable getInitialContextProperties() { Hashtable<String,String> props = new Hashtable<String,String>(); props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); props.put("java.naming.provider.url", "jnp://localhost:1100"); return props; } }
The class should be resolvable in the AS; here are some of the startup messages:07:27:45,942 INFO [ProxyDeployer] no declared remote bindings for : com.kenai.examine.wsdl.WSDLMgr 07:27:45,942 INFO [ProxyDeployer] there is remote interfaces for com.kenai.examine.wsdl.WSDLMgr 07:27:45,942 INFO [ProxyDeployer] default remote binding has jndiName of com.kenai.examine.wsdl.WSDLMgrRemote
Also, one of the debugging snippets that was given in the FAQ was to do a context.listBindings() -- that fails with the same error.
The failure isException in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1100 and discovery failed with error: javax.naming.CommunicationException: Failed to retrieve stub from server 10.1.1.79:1100 [Root exception is java.io.StreamCorruptedException: unexpected block data] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server localhost:1100 [Root exception is java.io.StreamCorruptedException: unexpected block data]] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1399) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572) at javax.naming.InitialContext.lookup(Unknown Source) at com.kenai.examine.wsdl.EJB30Client.main(EJB30Client.java:7)
Any pointers appreciated . . . -
3. Re: JBoss 4.0 JNDI from standalone program
delkant Nov 11, 2005 11:45 AM (in response to psseshwari)hi there.(first: my english is not the best.. :))
I have try these with two jboss servers jboss4.0.2 and jboss4.0.3SP1, after some little errors i get all working, i will put here some tips where i was stack in my tests,
my source:
the ejb-jar.xml file significative part:
<!-- Session Beans -->
[CDATA[Description for DelkantSession]]
<display-name>Name for DelkantSession</display-name>
<ejb-name>DelkantSession</ejb-name>
py.wpg.DelkantSessionHome
<!--this interfaces are require-->
py.wpg.DelkantSession
<local-home>py.wpg.DelkantSessionLocalHome</local-home>
py.wpg.DelkantSessionLocal
<ejb-class>py.wpg.DelkantSessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
the DelkantSessionBean.class :
/**
* @ejb.bean name="DelkantSession"
* display-name="Name for DelkantSession"
* description="Description for DelkantSession"
* jndi-name="ejb/delkant"
* type="Stateless"
* view-type="both"
* transaction-type = "Container"
*/
public class DelkantSessionBean implements SessionBean {
/**
* @ejb.interface-method view-type = "both"
* @ejb.transaction type = "Required"
*
*/
public String getSaludo(){
return "hola mundo / hello world / a string";
}
//all the methods from the SessionBean Implementation.
}
the DelkantTestClient.class (Standalone-client):
public class DelkantTestClient {
public static void main(String[] args) {
try{
System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
System.setProperty("java.naming.provider.url", "localhost:1099");
//Use them to get the context
Context context = new InitialContext(System.getProperties());
DelkantSessionHome home = (DelkantSessionHome) context.lookup("ejb/delkant");
String data= home.create().getSaludo();
System.out.println("lookup(ejb/delkant): " + data);
}catch (Exception e){
System.out.println("Exception "+e);
e.printStackTrace();
}
}
}
and that is all from the sources part, them we need to put two jars libraries in the DelkantTestClient classpath from the $JBOSS_HOME/client the jbossall-client.jar and the logkit.jar.
we also need the delkantClient.jar, here i put all the interfaces that i need to do a cast when i make the lookup.
that is.
CUESTION: i need a ear2ear comunication, i probe all but i dont get the way to comunicate a ejb Session from one application.ear to a second application2.ear
how do i get a remote interface from another application?? can i do something like new InitialContext( application.ear2 ); i dont understand how this work..
thanks.. -
4. Re: JBoss 4.0 JNDI from standalone program
pepeanto Jan 30, 2007 2:00 PM (in response to psseshwari)Hello:
I am developing an application using JBoss 4.0.5. JBoss is running in cluster and is offering support for ejb3.
A test client is supposed to contact the ejb through HAJNDI. It was working OK using JNDI, but when trying to contact the ejb using HAJNDI I had exactly the same problem as you do.
Luckily I was able to solve it adding some libraries to my client´s classpath.
I give you the whole list of libraries I was using:
concurrent.jar
jboss.jar
jboss-annotations-ejb3.jar
jboss-aop-jdk50.jar
jboss-aspect-library-jdk50.jar
jboss-common.jar
jboss-ejb3.jar
jboss-ejb3x.jar
jboss-j2ee.jar
jboss-remoting.jar
jbosssx.jar
jboss-transaction.jar
jnpserver.jar
junit.jar
The ones I was missing (and caused the hajndi problem) were:
jbossha.jar
jboss-serialization.jar.
I hope that can help.