6 Replies Latest reply on Aug 14, 2012 9:21 AM by Sham HC

    Problem with javax.activation when sending html mails and/or using CXF

    Luthiger Level 1

      In my CQ5.5 installation I have a component which sends html-mails and another component which uses CXF to import data from an external data provider (SOAP interface) and to render that data on a web page. Therefore, both components (which are packaged in different bundles) use javax.activation. The javax.activation package is provided by two different bundles, either by org.apache.felix.framework or by com.day.commons.osgi.wrapper.mail.

       

      I’ve noticed that there’s some mutual exclusiveness. If I manage to obtain javax.activation from com.day.commons.osgi.wrapper.mail, I’m able to send html mails, but get an error (loader constraint violation, see [1]) when trying to get the data using CXF.

       

      On the other side, if I manage to obtain javax.activation from org.apache.felix.framework, I’m able to get and render the data using CXF but fail when trying to send html formatted mails.

       

      How can I solve this problem?

       

      Note: I’m wrapping the calls to the JaxWs classes generated by CXF in an OSGI-aware classloader (by setting the classloader to the CXF bundle).

       

       

      [1] Caused by: java.lang.LinkageError: loader constraint violation:

      when resolving overridden method

      "org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller.addMtomAttachment(Ljavax/activati on/DataHandler;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"

      the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5) of the current class,

      org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller, and its superclass loader (instance of <bootloader>),

      have different Class objects for the type javax/activation/DataHandler used in the signature

        • 1. Re: Problem with javax.activation when sending html mails and/or using CXF
          Sham HC Level 7

          Seems like third part jar also have javax.activation included causing  classloaders for java.mail and javax.activation not be same raising LinkageError. See making javax.activation as part of the system packages helps.  In order to do that add [1] at <cq_home>/crx-quickstart/conf/sling.properties,  restart the server & verify.

           

           

          [1]   org.osgi.framework.system.packages.extra=javax.activation

          • 2. Re: Problem with javax.activation when sending html mails and/or using CXF
            Luthiger Level 1

            Thanks for your reply.

             

            Unfortunately, adding org.osgi.framework.system.packages.extra=javax.activation to sling.properties doesn't change the situation.

            I'm only able to send html mails whereas trying to access the data using the CXF classes results in exactely the same loader constraint violation error as before.

             

            Using the dependency finder in the Felix console to look up the packages using javax.activation, I now get the following result:

            javax.activationcom.day.commons.osgi.wrapper.mail (78) and 1 others.

             

            Any other ideas to solve this problem?

            • 3. Re: Problem with javax.activation when sending html mails and/or using CXF
              Sham HC Level 7

              Please post results of dependency filter.  Please give one more try to revert old changes and add [1] and also make sure javax.activation obtained from com.day.commons.osgi.wrapper.mail,

               

              [1]  com.day.commons.osgi.wrapper.mail.system.packages.extra=javax.activation

              • 4. Re: Problem with javax.activation when sending html mails and/or using CXF
                Luthiger Level 1

                Adding com.day.commons.osgi.wrapper.mail.system.packages.extra=javax.activation to sling.properties did not improve the situation.

                 

                Do you mean "dependecy finder"? I didn't find a dependency filter possibility in the Felix web console, therefore, I post my results of the dependecy finder lookups for javax.activation:

                ===

                with "org.osgi.framework.system.packages.extra=javax.activation"

                 

                Packages

                Here are the packages you entered and by which bundle they are exported.

                javax.activation    com.day.commons.osgi.wrapper.mail (78) and 1 others.

                 

                Maven Dependencies

                Here are the bundles listed above as Maven dependencies

                <dependency>

                    <groupId>com.day.commons.osgi.wrapper</groupId>

                    <artifactId>com.day.commons.osgi.wrapper.mail</artifactId>

                    <version>1.4.0-0001</version>

                    <scope>provided</scope>

                </dependency>

                ===

                with "com.day.commons.osgi.wrapper.mail.system.packages.extra=javax.activation"

                 

                Packages

                Here are the packages you entered and by which bundle they are exported.

                javax.activation    com.day.commons.osgi.wrapper.mail (78)

                 

                Maven Dependencies

                Here are the bundles listed above as Maven dependencies

                <dependency>

                    <groupId>com.day.commons.osgi.wrapper</groupId>

                    <artifactId>com.day.commons.osgi.wrapper.mail</artifactId>

                    <version>1.4.0-0001</version>

                    <scope>provided</scope>

                </dependency>

                ===

                with both settings

                 

                Packages

                Here are the packages you entered and by which bundle they are exported.

                javax.activation    com.day.commons.osgi.wrapper.mail (78) and 1 others.

                Maven Dependencies

                Here are the bundles listed above as Maven dependencies

                <dependency>

                    <groupId>com.day.commons.osgi.wrapper</groupId>

                    <artifactId>com.day.commons.osgi.wrapper.mail</artifactId>

                    <version>1.4.0-0001</version>

                    <scope>provided</scope>

                </dependency>

                ===

                I see only a small variation. With org.osgi.framework.system.packages.extra=javax.activation, the dependency finder reported one additional package exporting javax.activation.

                • 5. Re: Problem with javax.activation when sending html mails and/or using CXF
                  Luthiger Level 1

                  I'm still stuck with this javax.activation problem.

                   

                  I have the same problem as http://dev.day.com/discussion-groups/content/lists/cq-google/2011-01/2011-01-19__day_commu nique_Error_javax_activation_UnsupportedDataTypeException_no_object_DCH_for_MIME_type___N. html.

                  Unfortunately, the approach provided in that post doesn't work for me. I tried the thread context class loading trick only to find out that it didn't change anything in my case.

                   

                  Are there any other approaches to overcome this problem?

                  • 6. Re: Problem with javax.activation when sending html mails and/or using CXF
                    Sham HC Level 7

                    Could you please file daycare and attach the component in the ticket.