3 Replies Latest reply on Jan 29, 2008 9:25 AM by Nicolas Daudin

    LinkageError... and yet everything seems fine

    Nicolas Daudin Newbie

      Hi,
      I have an app running under JBoss4.0.5.
      I have a quartz task, supposed to do some file parsing and then send a mail with a file attached. Before implementing this task, i didnt have any Linkage problem with my mail and activation librairies.
      But now when the task launches, i get the following:

      javax.ejb.EJBException: com.thalys.opalys.business.MailServiceException: loader constraints violated when linking javax/activation/DataHandler class
       at com.thalys.opalys.business.ejb.MailServiceBean.sendAttachmentMail(MailServiceBean.java:53)
       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.jboss.invocation.Invocation.performCall(Invocation.java:359)
       at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
       at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
       at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
       at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
       at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
       at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
       at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
       at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
       at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
       at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
       at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
       at org.jboss.ejb.Container.invoke(Container.java:954)
       at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:430)
       at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:103)
       at $Proxy91.sendAttachmentMail(Unknown Source)
       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.ejb.access.LocalSlsbInvokerInterceptor.invoke(LocalSlsbInvokerInterceptor.java:71)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:169)
       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:169)
       at $Proxy124.sendAttachmentMail(Unknown Source)
       at com.thalys.opalys.schedule.WifiRequestSenderJob.doIt(WifiRequestSenderJob.java:55)
       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.util.MethodInvoker.invoke(MethodInvoker.java:248)
       at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:198)
       at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
       at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
       at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
      Caused by: com.thalys.opalys.business.MailServiceException: loader constraints violated when linking javax/activation/DataHandler class
       at com.thalys.opalys.business.MailServiceBase.sendAttachmentMail(MailServiceBase.java:105)
       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:291)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:180)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:147)
       at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:88)
       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:169)
       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:169)
       at $Proxy124.sendAttachmentMail(Unknown Source)
       at com.thalys.opalys.business.ejb.MailServiceBean.sendAttachmentMail(MailServiceBean.java:44)
       ... 38 more
      Caused by: java.lang.LinkageError: loader constraints violated when linking javax/activation/DataHandler class
       at org.springframework.mail.javamail.MimeMessageHelper.addAttachment(MimeMessageHelper.java:966)
       at org.springframework.mail.javamail.MimeMessageHelper.addAttachment(MimeMessageHelper.java:987)
       at com.thalys.opalys.business.MailServiceImpl.handleSendAttachmentMail(MailServiceImpl.java:73)
       at com.thalys.opalys.business.MailServiceBase.sendAttachmentMail(MailServiceBase.java:101)
       ... 50 more


      But i checked in my JMX console, i tried displayClassInfo() on "javax/activation/DataHandler" and i get the following
      javax/activation/DataHandler Information
      Not loaded in repository cache
      
      
      ### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3@297ba3{ url=null ,addedOrder=2}
      

      which is Ok according to the JBoss wiki available here about LinkageError: http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassCastExceptions

        • 1. Re: LinkageError... and yet everything seems fine
          Nicolas Daudin Newbie

          Sorry didnt finish my post.
          Well it was just to ask if anyone had any idea?
          I checked my .ear, i have activation-1.1.jar
          I checked my JBOSS_HOME/server/deploy/lib, i have activation.jar and mail.jar....

          • 2. Re: LinkageError... and yet everything seems fine
            jaikiran pai Master

            Well, that's the reason!

            Looks like some of the classes are being loaded from JBoss's jar (the one from server/default/lib) and some from your application's package.

            I would suggest, enabling classloader scoping for your EAR, which should solve this problem. Just add a jboss-app.xml file in the META-INF folder of the EAR with something like this:

            <jboss-app>
            
             <loader-repository>
             org.myapp:loader=MyAppClassLoader
             <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
             </loader-repository>
            
            
            </jboss-app>


            More details can be found at http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration


            • 3. Re: LinkageError... and yet everything seems fine
              Nicolas Daudin Newbie

              Thanks! i tried this but it still does not work. Now i actually get an error at deployment time.
              Here is my jboss-app.xml

              <?xml version="1.0" encoding="ISO-8859-1"?>
              <!DOCTYPE jboss-app PUBLIC '-//JBoss//DTD J2EE Application 1.3V2//EN' 'http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd'>
              <jboss-app>
               <loader-repository>
               jboss.loader:loader=com.thalys.opalys-opalys-server-4.2.5-SNAPSHOT.ear
               <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
               </loader-repository>
              </jboss-app>


              Is it right?
              Problem is, my use of activation.jar is in a .jar inside my .ear. And apparelntly, from the Wiki link you gave to me, it is said that nested modules are not taken into account
              There are two levels of scoping, isolation from other deployments, and isolation that overrides the loading of JBoss server classes. With nested modules, only the top level file may specify class loader scoping. If you have a .ear file containing other modules, only scoping specified in the .ear's META-INF/jboss-app.xml is used.


              And at deployment time, i now get this:
              15:20:37,979 INFO [STDOUT] 15:20:37,976 ERROR [ContextLoader] Context initialization failed
              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext-dataSource.xml]: Initialization of bean failed; nested exception is org.springframework.transaction.TransactionSystemException: JTA UserTransaction is not available at JNDI location [java:comp/UserTransaction]; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object [org.jboss.tm.usertx.client.ServerVMClientUserTransaction@a11c08] available at JNDI location [java:comp/UserTransaction] is not assignable to [javax.transaction.UserTransaction]
              org.springframework.transaction.TransactionSystemException: JTA UserTransaction is not available at JNDI location [java:comp/UserTransaction]; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object [org.jboss.tm.usertx.client.ServerVMClientUserTransaction@a11c08] available at JNDI location [java:comp/UserTransaction] is not assignable to [javax.transaction.UserTransaction]
              org.springframework.jndi.TypeMismatchNamingException: Object [org.jboss.tm.usertx.client.ServerVMClientUserTransaction@a11c08] available at JNDI location [java:comp/UserTransaction] is not assignable to [javax.transaction.UserTransaction]
              at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:148)