1 Reply Latest reply: Nov 12, 2012 8:03 AM by Felipe Nova RSS

    ejb3 client with spring and maven, java.io.StreamCorruptedException: invalid stream header

    Alessandro D'Ottavio Newbie

      Hi guys

       

      i'm try to create a simple client application that is able to call ejb3 deployed in jboss with spring 3 and maven

       

      before to start i create a simple ejb following the comunity documentatio that describe step by step as implement one ejb and create a stand alone client that call it using the jboss-client.jar, it works correctly

       

      after that i took ( the bad decision ) to create a client using spring 3 and maven as i do for my other project in production

      but i get an exception and until now in not able this figure out the reason

       

      before to all i describe my develop environment

       

       

      Jboss AS:  jboss-as-7.1.1.Final

       

      dependences used fo the generation of the client has advised in the jboss distribution (exaclty jboss-as-7.1.1.Final\bin\client\readme.txt file)

       

      <spring-version>3.0.0.RELEASE</spring-version>

      <jboss-version>7.1.1.FINAL</jboss-version>

       

       

      after the start of the application i had a Class not found exception so i imported also this artifact   jboss:jnp-client (and tested the client with all the possibles version)

      <jboss-jnp-client-version>4.2.2.GA</jboss-jnp-client-version>

      <!-- jboss-jnp-client-version>4.0.2</jboss-jnp-client-version-->

      <!--jboss-jnp-client-version>3.2.1</jboss-jnp-client-version -->

       

       

       

      <dependency>

                                    <groupId>org.springframework</groupId>

                                    <artifactId>spring-context</artifactId>

                                    <version>${spring-version}</version>

                          </dependency>

                          <dependency>

                                    <groupId>org.springframework</groupId>

                                    <artifactId>spring-beans</artifactId>

                                    <version>${spring-version}</version>

                          </dependency>

                          <dependency>

                                    <groupId>org.springframework</groupId>

                                    <artifactId>spring-aop</artifactId>

                                    <version>${spring-version}</version>

                          </dependency>

                          <dependency>

                                    <groupId>org.jboss.as</groupId>

                                    <artifactId>jboss-as-ejb-client-bom</artifactId>

                                    <version>${jboss-version}</version>

                                    <type>pom</type>

                          </dependency>

                          <dependency>

                                    <groupId>jboss</groupId>

                                    <artifactId>jnp-client</artifactId>

                                    <version>${jboss-jnp-client-version}</version>

                          </dependency>

       

       

      the application is extreamely easy, i'm just try to look up of the ejb at the start of the application (that all!!!!)

       

      public static void main(String[] args){

       

                          ApplicationContext context = new ClassPathXmlApplicationContext("ejb-client-context.xml");

                          Context contex;

                }

       

      and this is my spring configuration file

       

      <bean id="ejbStateles"

                          class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">

                          <property name="jndiName" value="ejb/MyEjbStateless" />

                          <property name="businessInterface" value="it.spaghettisource.MyEjbRemote" />

                          <property name="lookupHomeOnStartup" value="true" />

                          <property name="cacheHome" value="false" />

                          <property name="jndiEnvironment">

                                    <props>

                                              <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>

                                              <prop key="java.naming.factory.url.pkgs">org.jboss.naming</prop>

                                              <prop key="java.naming.provider.url">jnp://alexpc:4447</prop>

                                    </props>

                          </property>

                </bean>

       

       

      but i get this exception

       

      27-apr-2012 17.55.27 org.springframework.context.support.AbstractApplicationContext prepareRefresh

      INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3f7fa65e: startup date [Fri Apr 27 17:55:27 CEST 2012]; root of context hierarchy

      27-apr-2012 17.55.27 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

      INFO: Loading XML bean definitions from class path resource [ejb-client-context.xml]

      27-apr-2012 17.55.27 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons

      INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1f25fefa: defining beans [ejbStateles]; root of factory hierarchy

      27-apr-2012 17.55.32 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons

      INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1f25fefa: defining beans [ejbStateles]; root of factory hierarchy

      Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ejbStateles' defined in class path resource [ejb-client-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtain connection to any of these urls: alexpc:4447 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server alexpc:4447 [Root exception is java.io.StreamCorruptedException: invalid stream header: 00000009]]

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)

                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)

                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)

                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)

                at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:540)

                at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)

                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)

                at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

                at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

                at it.spaghettisource.MyEjbClientSpring.main(MyEjbClientSpring.java:20)

      Caused by: javax.naming.CommunicationException: Could not obtain connection to any of these urls: alexpc:4447 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server alexpc:4447 [Root exception is java.io.StreamCorruptedException: invalid stream header: 00000009]]

                at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)

                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)

                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)

                at javax.naming.InitialContext.lookup(InitialContext.java:392)

                at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)

                at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)

                at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)

                at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)

                at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)

                at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)

                at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.refreshHome(AbstractSlsbInvokerInterceptor.java:122)

                at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.afterPropertiesSet(AbstractSlsbInvokerInterceptor.java:109)

                at org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean.afterPropertiesSet(LocalStatelessSessionProxyFactoryBean.java:86)

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)

                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)

                ... 12 more

      Caused by: javax.naming.CommunicationException: Failed to retrieve stub from server alexpc:4447 [Root exception is java.io.StreamCorruptedException: invalid stream header: 00000009]

                at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:268)

                at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)

                ... 26 more

      Caused by: java.io.StreamCorruptedException: invalid stream header: 00000009

                at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782)

                at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)

                at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:255)

                ... 27 more

       

       

      in the server instead i found this log message:

       

      17:55:32,506 ERROR [org.jboss.remoting.remote.connection] (Remoting "segrmnlpt027" read-1) JBREM000200: Remote connection failed: java.io.IOException: Connessione in corso interrotta forzatamente dall'host remoto

       

      i traslate fo that one that are not italian

      Connessione in corso interrotta forzatamente dall'host remoto = An existing connection was forcibly closed by remote host

       

       

      look like a reason related to the incorrect importing of dependences but the only one that i have imported alone is

       

               <dependency>

                     <groupId>jboss</groupId>

                     <artifactId>jnp-client</artifactId>

                     <version>${jboss-jnp-client-version}</version>

                </dependency>

      tested wiht all the version that i found in the repository

       

      <jboss-jnp-client-version>4.2.2.GA</jboss-jnp-client-version>

      <jboss-jnp-client-version>4.0.2</jboss-jnp-client-version>

      <jboss-jnp-client-version>3.2.1</jboss-jnp-client-version>

       

       

      is there someone of u that have this issue or that is able to create a client with the correct dependences and lookup the ejb with spring 3?

       

       

      in attack the two lines of code and the configurations files if some one want to try

       

      thank