Announcement Announcement Module
Collapse
No announcement yet.
Classloader problems with JBoss ejb and Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Classloader problems with JBoss ejb and Spring

    I am trying to use Spring with a SLSB, using AbstractStatelessSessionBean as:


    public class SearchServiceEJB extends AbstractStatelessSessionBean implements com.invest.common.business.ISearch
    {
    private ISearch searchService;

    /* (non-Javadoc)
    * @see org.springframework.ejb.support.AbstractStatelessS essionBean#onEjbCreate()
    */
    protected void onEjbCreate() throws CreateException {
    //Get a reference to the bean factory and to the POJO service implementation
    searchService = (ISearch) getBeanFactory().getBean(
    Constants.SEARCH_SERVICE);

    }

    public List searchAssets(Map searchCriteria){

    return searchService.searchAssets(searchCriteria);
    }

    /**
    * Override default BeanFactoryLocator implementation
    *
    * @see javax.ejb.SessionBean#setSessionContext(javax.ejb. SessionContext)
    */
    public void setSessionContext(SessionContext sessionContext) {
    super.setSessionContext(sessionContext);
    setBeanFactoryLocator(ContextSingletonBeanFactoryL ocator.getInstance(Constants.SERVER_CONTEXT_FILENA ME));
    setBeanFactoryLocatorKey("SERVER_BEANFACTORY");
    }

    }


    I package everthing except the implementation of the service in the ejb.jar called SearchService.jar.

    The implementation searchServicelImpl goes under the lib directory in a seperate jar.

    heres is the xml file

    <beans>

    <!-- ========================= GENERAL DEFINITIONS ========================= -->

    <bean id="searchService" class="com.invest.model.capgroup.SearchServiceCapg roupImpl">
    </bean>

    </beans>

    The ejb just delegated to the impl class

    Upon accessing the ejb the bean factory tries to build the SingletonContext and throws the following exception, stating that it cannot find the class, even though it is under the lib directory.



    12:56:10,131 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [jar:file:/C:/apps/jboss-4.0.1/server/default/tmp/deploy/tmp58919SearchService.jar!/serverContext.xml]
    12:56:10,151 ERROR [LogInterceptor] EJBException in method: public abstract void javax.ejb.EJBObject.remove() throws java.rmi.RemoteException,javax.ejb.RemoveException , causedBy:
    org.springframework.beans.factory.BeanDefinitionSt oreException: Error registering bean with name 'searchService' defined in URL [jar:file:/C:/apps/jboss-4.0.1/server/default/tmp/deploy/tmp58919SearchService.jar!/serverContext.xml]: Bean class [com.in
    vest.model.capgroup.SearchServiceCapgroupImpl] not found; nested exception is java.lang.ClassNotFoundException: No ClassLoaders found for: com.invest.model.capgroup.SearchServiceCapgroupImp l
    java.lang.ClassNotFoundException: No ClassLoaders found for: com.invest.model.capgroup.SearchServiceCapgroupImp l
    at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMg r3.java:198)
    at org.jboss.mx.loading.RepositoryClassLoader.loadCla ssImpl(RepositoryClassLoader.java:464)
    at org.jboss.mx.loading.RepositoryClassLoader.loadCla ss(RepositoryClassLoader.java:374)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 35)
    at org.jboss.util.loading.DelegatingClassLoader.loadC lass(DelegatingClassLoader.java:77)
    at org.jboss.mx.loading.LoaderRepositoryClassLoader.l oadClass(LoaderRepositoryClassLoader.java:78)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 35)
    at org.jboss.util.loading.DelegatingClassLoader.loadC lass(DelegatingClassLoader.java:77)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 35)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at org.springframework.beans.factory.support.BeanDefi nitionReaderUtils.createBeanDefinition(BeanDefinit ionReaderUtils.java:60)
    at org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser.parseBeanDefinition(DefaultXmlB eanDefinitionParser.java:293)
    at org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser.parseBeanDefinition(DefaultXmlB eanDefinitionParser.java:261)
    at org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser.registerBeanDefinitions(Default XmlBeanDefinitionParser.java:184)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:173)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:131)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:83)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:101)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:69)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:87)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:262)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:80)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:65)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:56)
    at org.springframework.context.access.ContextSingleto nBeanFactoryLocator.createDefinition(ContextSingle tonBeanFactoryLocator.java:127)
    at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.useBeanFactory(SingletonBeanFac toryLocator.java:373)
    at org.springframework.ejb.support.AbstractEnterprise Bean.loadBeanFactory(AbstractEnterpriseBean.java:1 15)
    at org.springframework.ejb.support.AbstractStatelessS essionBean.ejbCreate(AbstractStatelessSessionBean. java:63)
    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:324)
    at org.jboss.ejb.StatelessSessionEnterpriseContext.<i nit>(StatelessSessionEnterpriseContext.java:63)
    at org.jboss.ejb.plugins.StatelessSessionInstancePool .create(StatelessSessionInstancePool.java:35)
    at org.jboss.ejb.plugins.AbstractInstancePool.get(Abs tractInstancePool.java:146)
    at org.jboss.ejb.plugins.StatelessSessionInstanceInte rceptor.invoke(StatelessSessionInstanceInterceptor .java:80)
    at org.jboss.webservice.server.ServiceEndpointInterce ptor.invoke(ServiceEndpointInterceptor.java:51)
    at org.jboss.ejb.plugins.CallValidationInterceptor.in voke(CallValidationInterceptor.java:48)
    at org.jboss.ejb.plugins.AbstractTxInterceptor.invoke Next(AbstractTxInterceptor.java:105)
    at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTran sactions(TxInterceptorCMT.java:313)
    at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxIn terceptorCMT.java:146)
    at org.jboss.ejb.plugins.SecurityInterceptor.invoke(S ecurityInterceptor.java:123)
    at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInt erceptor.java:192)
    at org.jboss.ejb.plugins.ProxyFactoryFinderIntercepto r.invoke(ProxyFactoryFinderInterceptor.java:122)
    at org.jboss.ejb.SessionContainer.internalInvoke(Sess ionContainer.java:624)
    at org.jboss.ejb.Container.invoke(Container.java:870)
    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:324)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invok e(ReflectedDispatcher.java:144)
    at org.jboss.mx.server.Invocation.dispatch(Invocation .java:80)
    at org.jboss.mx.server.Invocation.invoke(Invocation.j ava:72)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ab stractMBeanInvoker.java:249)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanSe rverImpl.java:642)
    at org.jboss.invocation.jrmp.server.JRMPInvoker$MBean ServerAction.invoke(JRMPInvoker.java:805)
    at org.jboss.invocation.jrmp.server.JRMPInvoker.invok e(JRMPInvoker.java:406)
    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:324)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:261)
    at sun.rmi.transport.Transport$1.run(Transport.java:1 48)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport. java:144)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:460)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:701)
    at java.lang.Thread.run(Thread.java:534)



    What is happening here?
    THis seems a relatively basic architecture that should work.

    Do I need to stuff everyhting in my ejb.jar file for this to work? If so that would really suck big time!

    THanks
    Alex

  • #2
    It's not completely clear what you mean by "..even though it is under the lib directory.".

    I think you need the following:

    - create a \lib directory under the .ear directory
    - put the .jar in the \lib directory
    - create a <java> module in your application.xml. From memory it looks something like the following and sits alongside your <web> and <ejb> module definitions.

    <module>
    <java>lib\mystuff.jar</java>
    </module>

    Alternatively, you can put jars in <jboss>\server\default\lib but it's not a good way to deploy since it's just another chore you need to do when deploying on another appserver.

    If you can get everything configured under the .ear directory, then it should work exactly the same when jar'ed up or in exploded format.

    Comment

    Working...
    X