5 Replies Latest reply on May 26, 2010 2:56 PM by Piotrek Stróżyk

    JMSAppender - Apache ServiceMix (4.2.0-fuse-01-00)

    Piotrek Stróżyk Newbie

      Hello,

      I have problem with JMSAppender configuration on Apache Service Mix 4.2.0 based on felix framework. I don't have problem with the same configuration described below running on Apache Service Mix 4.2.0 based on equinox framework.

       

      Maybe someone could tell me what's going on?

       

       

      I have my own bundle with log4j.properties configuration:

      log4j.category.log4j.jms.service=DEBUG, jms

       

      log4j.appender.jms=org.apache.log4j.net.JMSAppender

      log4j.appender.jms.InitialContextFactoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory

      log4j.appender.jms.ProviderURL=tcp://localhost:61616

      log4j.appender.jms.TopicBindingName=dynamicTopics/logTopic

      log4j.appender.jms.TopicConnectionFactoryBindingName=ConnectionFactory

       

       

      My MANIFEST.MF file looks like:

      Manifest-Version: 1.0

      Export-Package: log4j.jms.service.test;version="0";uses:="org.osgi.fra

      mework"

      Unversioned-Imports: *

      Bundle-Classpath: .,lib/log4j-1.2.12.jar

      Built-By: peter

      Bundle-Name: log4j-jms-service-test

      Created-By: Apache Maven

      Build-Jdk: 1.6.0_17

      Spring-DM-Version: 0.0.1-SNAPSHOT

      Bundle-Activator: log4j.jms.service.test.Log4JServiceTestImpl

      Bundle-ManifestVersion: 2

      Import-Package: javax.jms,javax.naming,org.apache.activemq.jndi,org.os

      gi.framework

      Bundle-SymbolicName: log4j-jms-service-test

      Archiver-Version: Plexus Archiver

       

       

       

      And as I said. Everything work fine with this configuration on Apache Service Mix based on equinox framework. JMS Appender works very well.

       

      But if I have Apache Service Mix based on felix framework I got error where I start my bundle:

      (...)

      log4j:ERROR Error while activating options for appender named .

      javax.naming.NamingException: Argh this should never happen Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory

           at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.createContext(OSGiInitialContextFactoryBuilder.java:159)

           at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:92)

           at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

           at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

           at javax.naming.InitialContext.init(InitialContext.java:223)

           at javax.naming.InitialContext.(InitialContext.java:197)

           at org.apache.log4j.net.JMSAppender.activateOptions(JMSAppender.java:200)

           at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)

           at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:133)

           at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:97)

           at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:689)

           at org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:47)

           at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)

           at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:568)

           at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:442)

           at org.ops4j.pax.logging.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:180)

           at org.ops4j.pax.logging.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:314)

           at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1389)

           at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)

      Caused by: java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory

           at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

           at java.security.AccessController.doPrivileged(Native Method)

           at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:315)

           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:250)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:247)

           at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.createContext(OSGiInitialContextFactoryBuilder.java:156)

           ... 18 more

      (...)

       

       

       

       

      Best regards,

      Peter

        • 1. Re: JMSAppender - Apache ServiceMix (4.2.0-fuse-01-00)
          Piotrek Stróżyk Newbie

           

          Antother test case. Below fragment of code works fine on Apache Service Mix based on Equinox. If I run this code on Apache Service Mix based on Felix I got Exception: ClassNotFoundException, described below.

           

           

          There is a bug in Felix implementation or I did something wrong?

           

           

          (...)

          Properties props = new Properties();

          props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");

          props.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");

          javax.naming.Context ctx = new InitialContext(props);

           

           

           

          ConnectionFactory connectionFactory = (ConnectionFactory)ctx.lookup("ConnectionFactory"); // Here is javax.naming.NamingException: Argh this should never happen Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory

           

          Connection connection = connectionFactory.createConnection();

           

           

           

          Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);

          Destination vendorOrderQueue = session.createQueue(QUEUE);

           

           

           

          MessageProducer producer = session.createProducer(vendorOrderQueue);

           

          connection.start();

           

           

           

          TextMessage message = session.createTextMessage();

           

           

           

          message.setText(textMessage);

          producer.send(message);

           

           

           

          session.commit();

           

           

           

          connection.close();

          (...)

           

           

           

           

           

          Best regards,

           

           

          Peter

           

           

          • 2. Re: JMSAppender - Apache ServiceMix (4.2.0-fuse-01-00)
            Gert Vanthienen Novice

            L.S.,

             

            When running this in Felix, could you enable Felix framework debugging (you can use the command dev:framework -debug)?  If you restart the container, it will give you a whole lot of information about the OSGi package wiring, but it will also 'enhance' the ClassNotFoundException by adding bundle IDs to it. 

             

            If you could let us know which bundle id are mentioned in the exception (and which bundles they represent), that might help us pinpoint the issue.

             

            Thanks,

             

            Gert

            • 3. Re: JMSAppender - Apache ServiceMix (4.2.0-fuse-01-00)
              Piotrek Stróżyk Newbie

              Hello Gert,

              Here is the fragment of the debug log where the Exception occurs. I also put whole log file because during cxf initialization (I think) is the same Exception. Maybe it will be importent to analyse.

               

              Bundle ID 201

               

              (...)

              karaf@root> update 201

              DEBUG: WIRE: 201.0 -> javax.jms -> 77.0

              DEBUG: WIRE: 201.0 -> javax.naming -> 0

              DEBUG: WIRE: 201.0 -> org.apache.activemq -> 87.0

              DEBUG: WIRE: 201.0 -> org.apache.activemq.jndi -> 87.0

              DEBUG: WIRE: 201.0 -> org.apache.log4j -> 3.0

              DEBUG: WIRE: 201.0 -> org.osgi.framework -> 0

              DEBUG: /META-INF/mailcap

              javax.naming.NamingException: Argh this should never happen [Root exception is java.lang.ClassNotFoundException: org.

              apache.activemq.jndi.ActiveMQInitialContextFactory]

                      at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.createContext(OSGiInitialContextFactoryBuilder.

              java:159)

                      at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuil

              der.java:92)

                      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

                      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

                      at javax.naming.InitialContext.init(InitialContext.java:223)

                      at javax.naming.InitialContext. DEBUG: META-INF/services/javax.xml.parsers.DocumentBuilderFactory

              DEBUG: META-INF/services/javax.xml.parsers.DocumentBuilderFactory

              (...)

               

              Thank you.

               

              Best regards,

              Peter

               

              Edited by: pstrozyk on May 18, 2010 9:55 PM

              Add bundle ID - 201

              • 4. Re: JMSAppender - Apache ServiceMix (4.2.0-fuse-01-00)
                Piotrek Stróżyk Newbie

                And here is the same Exception but taken from Mac OSX platform.

                 

                (...)

                karaf@root> update 191

                DEBUG: WIRE: 191.0 -> javax.jms -> 77.0

                DEBUG: WIRE: 191.0 -> javax.naming -> 0

                DEBUG: WIRE: 191.0 -> org.apache.activemq -> 87.0

                DEBUG: WIRE: 191.0 -> org.apache.activemq.jndi -> 87.0

                DEBUG: WIRE: 191.0 -> org.apache.log4j -> 3.0

                DEBUG: WIRE: 191.0 -> org.osgi.framework -> 0

                DEBUG: /META-INF/mailcap

                javax.naming.NamingException: Argh this should never happen Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory

                     at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.createContext(OSGiInitialContextFactoryBuilder.java:159)

                     at org.apache.servicemix.naming.OSGiInitialContextFactoryBuilder.getInitialContext(OSGiInitialContextFactoryBuilder.java:92)

                     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

                     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

                     at javax.naming.InitialContext.init(InitialContext.java:223)

                     at javax.naming.InitialContext. DEBUG: META-INF/services/javax.xml.parsers.DocumentBuilderFactory

                DEBUG: META-INF/services/javax.xml.parsers.DocumentBuilderFactory

                (...)

                 

                Unfortunatelly there is no more information from my point of view. Just an exception.

                 

                 

                Thank you.

                 

                Regards,

                Peter

                • 5. Re: JMSAppender - Apache ServiceMix (4.2.0-fuse-01-00)
                  Piotrek Stróżyk Newbie

                  Hello Gert,

                  You had time to look at this issue?

                   

                  Regards,

                  Peter