Announcement Announcement Module
Collapse
No announcement yet.
Spring2 + EJB3 + JBoss405 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring2 + EJB3 + JBoss405

    Hello,

    I've been trying to use a SLSB from a Stripes ActionBean, but for some reason it doesn't work. Checking the JMX console, the SLSB looks correctly deployed, so I guess it's a matter of Spring configuration.

    Code:
    	<!-- Security service EJB -->
    	<bean id="securityServiceEjb" class="org.springframework.jndi.JndiObjectFactoryBean">
    	   	<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:org.jnp.interfaces
    	   			</prop>
    	   			<prop key="java.naming.provider.url">
    	   				jnp://localhost:1099
    	   			</prop>
    	   		</props>
    	   	</property>
    		<property name="jndiName" value="schlange-security/SecurityServiceEjb/local" />
    		<property name="proxyInterface" value="org.schlange.security.server.SecurityService" />
    		<property name="lookupOnStartup" value="false" />
    	</bean>
    Code:
    20:36:45,062 INFO  [STDOUT] ERROR 08:36:45 org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/mpc].[StripesDispatcher].error(L119) - Servlet.service() for servlet StripesDispatcher threw exception
    java.lang.IllegalArgumentException: object is not an instance of declaring class
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
    	at $Proxy75.login(Unknown Source)
    	at org.mpc.web.controller.user.LoginActionBean.confirm(LoginActionBean.java:56)
    I saw other posts concerning this issue, but I couldn't find out a way to get this issue solved yet.

    Can anybody give me a hand here, please?

    Thanks in advance!

  • #2
    I have the same issue (see my topic). JndiObjectFactoryBean doesn't work for me. One guy claims that Spring JBoss Deployer helps to solve it but I don't know how (from what it seems the JBoss deployer allows deployment of .spring files, but how may it help)

    Comment


    • #3
      Well, I guess I'll try JBoss deployer or another technique then. It's a pity JndiObjectFactoryBean doesn't work as expected in this case, since it's so clean...

      As soon as I get this thing working, I'll let you know in this post. Thanks!

      Comment


      • #4
        Have you tried removing the proxyInterface?

        Code:
        <property name="proxyInterface" value="org.schlange.security.server.SecurityService" />
        If you remove this it will just do a lookup of the object and return it as an object. This might help you move forward because the problem is in the AOP proxy that gets built when you provide the interface. It seem as if the error is indicating that the object that is returned from the JNDI lookup does not implement the 'org.schlange.security.server.SecurityService' interface.

        Comment


        • #5
          JndiObjectFactoryBean works just fine
          in my JBoss 4.0.4 + Spring 2 + JBoss-Spring integration package from Ales Justin and co
          http://www.jboss.org/index.html?modu...iewforum&f=223

          Comment


          • #6
            Tell me, in what way does JBoss Spring deployer help here? I don't want to package into .spring file.

            Cheers,
            Leet Geezer

            Comment


            • #7
              That's how my jspring.ear deployed to JBoss 4.0.4 with JBoss-Spring deployer looks like
              Code:
              [arno@fedora distribution]$ jar -tvf jspring.ear
                   0 Thu Dec 21 03:06:32 EST 2006 META-INF/
                 106 Thu Dec 21 03:06:30 EST 2006 META-INF/MANIFEST.MF
               24956 Thu Dec 21 03:06:20 EST 2006 common.jar
               19032 Thu Dec 21 03:06:24 EST 2006 domain.jar
               58972 Thu Dec 21 03:06:24 EST 2006 service.spring
               16914 Thu Dec 21 03:06:26 EST 2006 facade.jar
              1340603 Thu Dec 21 03:06:32 EST 2006 web.war
              444463 Sat Sep 16 15:20:06 EDT 2006 acegi-security.jar
              559366 Fri Sep 22 12:20:42 EDT 2006 commons-collections.jar
              207723 Fri Apr 21 15:04:32 EDT 2006 commons-lang.jar
                8034 Sun Sep 03 05:52:06 EDT 2006 jsr181-api.jar
               65261 Sat Sep 16 15:33:12 EDT 2006 oro-2.0.8.jar
              388716 Thu Sep 14 00:51:20 EDT 2006 quartz-1.5.2.jar
              116736 Thu Sep 14 00:57:18 EDT 2006 spring-support.jar
                1147 Fri Sep 22 12:23:32 EDT 2006 META-INF/application.xml
              Yeah, service.spring is here. Naturally. You don't like ? Feel free to write your own implementation. Hey, it's open source (almost), isn't it?
              Tell me, in what way does JBoss Spring deployer help here?
              Why should I reiterate what Ales has explained already. Feel free to read his article and docs. All links you can find in the adjacent thread.

              Comment


              • #8
                Hi Caleb, thanks for helping! Removing the proxyInterface property doesn't help, and BTW the JNDI object does implement the 'org.schlange.security.server.SecurityService' interface.

                I'd rather to make it working without the JBoss Spring deployer, so I'll try to find out what's wrong with the JNDI lookup.

                Comment


                • #9
                  This is getting funny. I've put a break point before calling the login() method, and I'm playing with the JNDI bound object:

                  securityManager instanceof org.schlange.security.server.service.SecurityServi ceEjb
                  (boolean) false

                  securityManager instanceof org.schlange.security.server.SecurityService
                  (boolean) true

                  So, how can it be instance of SecurityService and not instance of SecurityServiceEjb? There is something really weird in this implementation...

                  Comment


                  • #10
                    For the record, I've tried

                    Code:
                    	<jee:local-slsb id="securityServiceEjb"
                    		jndi-name="schlange-security/SecurityServiceEjb/local" 
                    		business-interface="org.schlange.security.server.SecurityService"
                    		cache-home="true" lookup-home-on-startup="false" resource-ref="true" />
                    and

                    Code:
                    	<jee:jndi-lookup
                    		id="securityServiceEjb"
                    		cache="false"
                    		resource-ref="true"
                    		lookup-on-startup="false"
                    		jndi-name="schlange-security/SecurityServiceEjb/local"
                    		expected-type="org.schlange.security.server.service.SecurityServiceEjb" 
                    		proxy-interface="org.schlange.security.server.SecurityService">
                    		<jee:environment>
                    			java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory 
                    			java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces 
                    			java.naming.provider.url=jnp://localhost:1099
                    		</jee:environment>
                    	</jee:jndi-lookup>
                    ... but the result stills the same!

                    Code:
                    org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract org.schlange.security.server.data.TlfUser org.schlange.security.server.SecurityService.login(org.schlange.security.server.util.SecureCipher,org.schlange.security.server.util.SecureCipher) throws org.schlange.security.server.exception.LoginException,org.schlange.foundation.common.SystemException] on target [SecurityServiceEjb]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
                    	org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:326)
                    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
                    	$Proxy75.login(Unknown Source)
                    Code:
                    java.lang.IllegalArgumentException: object is not an instance of declaring class
                    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    	java.lang.reflect.Method.invoke(Method.java:585)
                    	org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
                    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
                    	$Proxy75.login(Unknown Source)

                    Comment


                    • #11
                      So in your web application can you do the following?

                      Code:
                      
                      SecurityService securityService = (SecurityService)ctx.lookup("java:comp/env/schlange-security/SecurityServiceEjb/local"); 
                      

                      Comment


                      • #12
                        Originally posted by tiago182 View Post
                        This is getting funny. I've put a break point before calling the login() method, and I'm playing with the JNDI bound object:

                        securityManager instanceof org.schlange.security.server.service.SecurityServi ceEjb
                        (boolean) false

                        securityManager instanceof org.schlange.security.server.SecurityService
                        (boolean) true

                        So, how can it be instance of SecurityService and not instance of SecurityServiceEjb? There is something really weird in this implementation...
                        It's a proxy instance. Ejb class is only server side, it can't be accessed client side.

                        Your problem is, most probably, classloading.

                        Comment


                        • #13
                          Originally posted by cwash5 View Post
                          So in your web application can you do the following?

                          Code:
                          
                          SecurityService securityService = (SecurityService)ctx.lookup("java:comp/env/schlange-security/SecurityServiceEjb/local"); 
                          
                          I have the same problem and for me the above line works.
                          Maybe you have a solution?

                          Comment


                          • #14
                            It might work, but certainly looks ugly.

                            Comment


                            • #15
                              Originally posted by dejanp View Post
                              It's a proxy instance. Ejb class is only server side, it can't be accessed client side.
                              Your problem is, most probably, classloading.
                              If the problem is classloading, how would I solve it? Any idea? Tks

                              Comment

                              Working...
                              X