Results 1 to 2 of 2

Thread: Regarding Ejb 3.0 Deployment With Spring 2.5

  1. #1
    Join Date
    Jul 2008
    Posts
    10

    Default Regarding Ejb 3.0 Deployment With Spring 2.5

    Hi All,

    At present, I am trying my hand in integrating Ejb 3.0 with Spring 2.5. I am using jboss 4.2.2 GA.
    I am starting my server and deploying my ear file through Eclipse.

    I am getting the following exception while deploying the ejb jar along with the ear file. ( after removing this ejb jar , the deployment is fine )


    09:40:38,674 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=demoear.ear,jar=demoejb.jar,name=Ma sterdataEJB,service=EJB3 with dependencies:
    09:40:38,721 INFO [EJBContainer] STARTED EJB: com.demo.MasterdataEJB ejbName: MasterdataEJB
    09:40:38,799 INFO [EJBContainer] STOPPED EJB: com.demo.MasterdataEJB ejbName: MasterdataEJB
    09:40:38,799 WARN [ServiceController] Problem starting service jboss.j2ee:ear=demoear.ear,jar=demoejb.jar,name=Ma sterdataEJB,service=EJB3
    java.lang.ClassCastException: $Proxy81
    at org.jboss.util.naming.Util.createSubcontext(Util.j ava:69)
    at org.jboss.util.naming.Util.rebind(Util.java:125)
    at org.jboss.util.naming.Util.rebind(Util.java:113)
    at org.jboss.ejb3.stateless.StatelessRemoteProxyFacto ry.start(StatelessRemoteProxyFactory.java:128)
    at org.jboss.ejb3.ProxyDeployer.start(ProxyDeployer.j ava:83)
    at org.jboss.ejb3.SessionContainer.start(SessionConta iner.java:157)
    at org.jboss.ejb3.stateless.StatelessContainer.start( StatelessContainer.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.ejb3.ServiceDelegateWrapper.startService (ServiceDelegateWrapper.java:103)
    at org.jboss.system.ServiceMBeanSupport.jbossInternal Start(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternal Lifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invok e(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation .java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.j ava:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ab stractMBeanInvoker.java:264)


    I am not sure where the mistake is.

    below are the files.

    Files inside META-INF
    ejb-jar.xml
    Code:
     <enterprise-beans>
          <session>
             <ejb-name>MasterdataEJB</ejb-name>
             <home>com.demo.MasterdataEJB</home>
             <remote>com.demo.MasterdataRemote</remote>
             <ejb-class>com.demo.MasterdataEJB</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
             <env-entry>
             	<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
             	<env-entry-type>java.lang.String</env-entry-type>
             	<env-entry-value>service.xml</env-entry-value>
           	</env-entry>
          </session>
       </enterprise-beans>
    </ejb-jar>
    jboss.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?> 
     <jboss>
       <enterprise-beans>
          <session>
             <ejb-name>MasterdataEJB</ejb-name>
             <local-jndi-name>ejb/masterdataejb</local-jndi-name>
          </session>
       </enterprise-beans>
    </jboss>
    service.xml ( availabe in the root folder of the classpath )

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans>
    	<!-- =========  DAO DECLARATIONS============== -->
    	<bean id="rootService"
    		class="com.demo.WorkService">
    	</bean> 
     </beans>
    Java Classes ( have not used the at-the-rate symbol for annotations while posting , as im not permitted to post it. )

    Code:
    Stateless(name = "MasterdataEJB")
    public class MasterdataEJB extends AbstractStatelessSessionBean implements
    		MasterdataService {
     
    }
    
    Local
    public interface MasterdataHome extends EJBHome {
    	public MasterdataRemote create() throws CreateException, RemoteException;
    }
    
    Remote
    public interface MasterdataRemote extends MasterdataService, EJBObject {
    
    }
    
    public interface MasterdataService {
    }
    As of now, there are no methods. I am not getting why, I am getting this exp while deploying an ejb with spring.

    Thanx in Advance.
    Vasu

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    First off all it seems you are mixing classes from EJB2 and EJB3, the AbstractStatelessSessionBean is EJB 2 NOT EJB3, the same for EJBHome and EJBObject, so start by removing that. Also isn't your interface declaration off?! Your @Local is at the Home interface not a Local interface. Just seems odd to me. Remember that EJB3 is an attempt to use POJO based programming in an EJB model. So no more special EJB classes, just some annotations.

    Another question I have is is the service.xml posted in whole? No tx stuff going on? I also suggest chapter 18.3.2 which explains how to use spring in EJB3.

    Code:
    @Stateless(name = "MasterdataEJB")
    @Interceptors(SpringBeanAutowiringInterceptor.class)
    public class MasterdataEJB implements MaterdataLocal, MasterdataRemote {
    
      public void someMethod() {
        System.out.println("someMethod called.");
      }
    
    }
    
    @Local
    public interface MasterdataLocal extends MasterdataService {
    }
    
    @Remote
    public interface MasterdataRemote extends MasterdataService {
    
    }
    
    public interface MasterdataService {
      public void someMethod();
    }
    I would have expected something like this. Although you might want to check if you really need both a Local and Remote interface...
    Last edited by Marten Deinum; Aug 28th, 2008 at 12:41 AM.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •