1 Reply Latest reply on Aug 14, 2011 4:26 PM by Nicolai Ødum

    Not able to lookup a EJB from Spring 2.5.x

    Nicolai Ødum Newbie

      Using build (#1496)

       

      I have 2 ear files. One contains a EJB that is exposed in the JNDI view in the console as

       

       

      JNDI name
      Decription
      java:global/kerne/kerne/TinglysningServiceBean!com.csc.etl.kerne.serviceinterface.interfaces.TinglysningServiceTinglysningService of EJB: TinglysningServiceBean
      java:global/kerne/kerne/TinglysningServiceBeanTinglysningService of EJB: TinglysningServiceBean

       

      In the other ear file I have a client jar that contains the com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService interface class and a war file that tries to look up the EJB using Spring 2.5.x

       

      The definition looks like this in Spring applicationContext.xml

       

        <bean id="tinglysningService" class="org.springframework.jndi.JndiObjectFactoryBean"

          lazy-init="true">

          <property name="expectedType"

            value="com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService" />

          <property name="jndiName"

            value="java:global/kerne/kerne/TinglysningServiceBean">

          </property>

          <property name="lookupOnStartup">

            <value>false</value>

          </property>

          <property name="proxyInterface">

            <value>com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService</value>

          </property>

        </bean>

       

      But when I lookup the EJB with the following code in the DataLoader class

       

      org.springframework.context.ApplicationContext context

      .....

      TinglysningService tinglysningService = (TinglysningService) context.getBean("tinglysningService")

       

       

      I get this error

       

      20:47:53,813 ERROR [com.csc.etl.sagsportal.beans.forespoerg.tingbogen.DataLoader] (MSC service thread 1-1) JndiObjectTargetSource failed to obtain new target object; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService$$$view17] available at JNDI location [java:global/kerne/kerne/TinglysningServiceBean] is not assignable to [com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService]: org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService$$$view17] available at JNDI location [java:global/kerne/kerne/TinglysningServiceBean] is not assignable to [com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService]

          at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:138) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184) [spring-2.5.6.SEC01.jar:]

          at $Proxy128.hentAlleEjerLav(Unknown Source)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]

          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

          at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77) [spring-2.5.6.SEC01.jar:]

          at com.csc.etl.sagsportal.utils.logging.PerformanceLoggingAspect.log(PerformanceLoggingAspect.java:94) [classes:]

          at com.csc.etl.sagsportal.utils.logging.PerformanceLoggingAspect.doPerformanceLogging(PerformanceLoggingAspect.java:50) [classes:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]

          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

          at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) [spring-2.5.6.SEC01.jar:]

          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [spring-2.5.6.SEC01.jar:]

          at $Proxy129.hentAlleEjerLav(Unknown Source)    at com.csc.etl.sagsportal.beans.forespoerg.tingbogen.DataLoader.init(DataLoader.java:40) [classes:]

          at com.csc.etl.sagsportal.servlets.AjaxContentProviderServlet.init(AjaxContentProviderServlet.java:49) [classes:]

          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]

          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]

          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]

          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3844) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]

          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

      Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService$$$view17] available at JNDI location [java:global/kerne/kerne/TinglysningServiceBean] is not assignable to [com.csc.etl.kerne.serviceinterface.interfaces.TinglysningService]

          at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:180) [spring-2.5.6.SEC01.jar:]

          at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) [spring-2.5.6.SEC01.jar:]

          at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) [spring-2.5.6.SEC01.jar:]

          at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:131) [spring-2.5.6.SEC01.jar:]

          ... 36 more

       

      Is this a bug or am i doing something wrong?

        • 1. Re: Not able to lookup a EJB from Spring 2.5.x
          Nicolai Ødum Newbie

          I have been looking a little deeper into this problem - and I don't think it has anything to do with Spring.

           

          I have created a very simple example that shows my problem

           

          HelloWorld.ear

          • HelloWorld.jar (HelloWorldEJB)
          • HelloWorldWeb.war

           

          HelloWorld2.jar

          • HelloWorld2.jar (HelloWorldEJB2)

           

          The war file has 2 servlets - one that injects the  HelloWorldEJB ejb and one that injects the HelloWorldEJB2 ejb.

           

          But I haven't been able to get the HelloWorldEJB2 version working.

           

          No mater what I do I get a

           

          java.lang.IllegalArgumentException: Can not set dk.ejb.HelloWorldEJB2Remote field dk.servlet.HelloWorldEJBNotInSameEar.helloWorldEJB to dk.ejb.HelloWorldEJB2Remote$$$view1

           

          So my question is - has anybody succesfully been able to inject a EJB that was not deployed in the same ear?