5 Replies Latest reply on Dec 28, 2006 1:52 PM by vasu vanam

    Exception by getting a reference to the ConnectionFactory

    Björn Wilken Newbie

      Dear JBoss-Comunity!

      The Problem:
      I wrote a simple Message Driven Bean and want to send her a Message!
      The client program, which should send the message gets always the following Exception:

      javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.jms.client.JBossConnectionFactory (no security manager: RMI class loader disabled)]
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at Client.main(Client.java:47)
      Caused by: java.lang.ClassNotFoundException: org.jboss.jms.client.JBossConnectionFactory (no security manager: RMI class loader disabled)
      at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
      at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
      at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
      at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
      at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
      at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
      at java.io.ObjectInputStream.readClassDesc(Unknown Source)
      at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      at java.io.ObjectInputStream.readObject0(Unknown Source)
      at java.io.ObjectInputStream.readObject(Unknown Source)
      at java.rmi.MarshalledObject.get(Unknown Source)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
      ... 3 more

      My configuration:
      I use JBoss AS 4.0.4 and installed the JBoss Messaging plugin (Version 1.0.1 GA)

      The Deployment:
      The MDB is correct deployed by JBoss (i use a JAR file which contains the bean).

      I tried a lof of things, but nothing helped:
      - Tried to use a SecurityManager
      - Tried to use an ear file with the following jboss-app.xml file:

      <jboss-app>
      <loader-repository>
      jboss.messaging:loader=ScopedLoaderRepository <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
      </loader-repository>
      </jboss-app>

      The Code for the Message Driven Bean looks like:

      import javax.jms.Message;
      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.MessageDriven;
      import javax.annotation.*;
      import javax.jms.*;
      
      @MessageDriven(
       activationConfig = {
       @ActivationConfigProperty(propertyName = "destinationType",
       propertyValue = "javax.jms.Topic"),
       @ActivationConfigProperty(propertyName = "destination",
       propertyValue = "testTopic"),
       @ActivationConfigProperty(propertyName = "acknowledgeMode",
       propertyValue = "Auto-acknowledge")
      
       }
      )
      public class LogBean implements MessageListener
      {
       /*
       @Resource(mappedName="ConnectionFactory")
       private ConnectionFactory connectionFactory;
       */
      
       public LogBean()
       {
       System.out.println("LogBean created ...");
       }
      
       public void onMessage(Message msg) {
       if (msg instanceof TextMessage)
       {
       TextMessage tm = (TextMessage)msg;
       try
       {
       String text = tm.getText();
       System.out.println("Received new message: " + text);
      
       }
       catch (JMSException e)
       {
       e.printStackTrace();
       }
       }
       }
      
       @PreDestroy
       public void remove()
       {
       System.out.println("LogBean destroyed!");
       }
      }
      


      The Code for the Client looks like:

      import java.rmi.RMISecurityManager;
      import java.util.Properties;
      
      import javax.annotation.*;
      import javax.jms.Topic;
      import javax.jms.ConnectionFactory;
      import javax.jms.Connection;
      import javax.jms.MessageProducer;
      import javax.jms.Session;
      import javax.jms.TextMessage;
      import javax.jms.JMSException;
      import javax.jms.TopicConnectionFactory;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      
      public class Client
      {
       @Resource(mappedName = "testTopic")
       private static Topic topic;
      
       public static void main(String args[])
       {
       Connection connection = null;
       Session session = null;
       MessageProducer messageProducer = null;
       TextMessage message = null;
       final int NUM_MSGS = 3;
      
       try
       {
       InitialContext ctx = new InitialContext();
       if (ctx == null)
       {
       System.out.println("Kein gültiger Kontext!");
       System.exit(1);
       } else
       {
       System.out.println("Kontext gefunden (" + ctx.toString() + ")!");
       }
       TopicConnectionFactory factory = (TopicConnectionFactory)ctx.lookup("/ConnectionFactory");
      
       // Connection factory benutzen, um eine JMS Connection zu erzeugen
       connection = factory.createConnection();
      
       // Connection benutzen, um eine Session zu erzeugen
       session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      
       // Sender für einen Topic erzeugen
       messageProducer = session.createProducer(topic);
      
       // Nachricht, die gesendet werden soll erzeugen
       message = session.createTextMessage();
      
       for (int i = 0; i < NUM_MSGS; i++)
       {
       message.setText("This is message " + (i + 1));
       System.out.println("Sending message: " + message.getText());
       messageProducer.send(message);
       }
       }
       catch (Exception e)
       {
       e.printStackTrace();
       }
       finally
       {
       if (connection != null)
       {
       try
       {
       connection.close();
       }
       catch (JMSException e)
       {
       }
       }
       } // finally
       } // main
      } // class
      


      Need urgent help, because i need this bean to work ahaed on my current project @work.

      Thank you very much!

      Best regards
      Björn Wilken

        • 1. Re: Exception by getting a reference to the ConnectionFactor
          Tim Fox Master

          Hi Bjorn-

          Is the client a standalone client? If so, have you included jboss-messaging-client.jar in the classpath?

          • 2. Re: Exception by getting a reference to the ConnectionFactor
            Björn Wilken Newbie

            Hey Tim!

            The Client is a Program running from Exclipse, that means a stand alone Client. You are right, i didn't include the jboss-messaging-client.jar.

            Now i have included the jboss-messaging-client.jar.
            But I got a new Exception:

            java.lang.RuntimeException: Failed to config client side AOP
            at org.jboss.jms.client.JBossConnectionFactory.ensureAOPConfigLoaded(JBossConnectionFactory.java:251)
            at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:196)
            at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:96)
            at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:91)
            at Client.main(Client.java:49)
            Caused by: java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
            java.io.EOFException
            at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:306)
            at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
            at org.jboss.remoting.Client.invoke(Client.java:525)
            at org.jboss.remoting.Client.invoke(Client.java:488)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.invoke(ClientConnectionFactoryDelegate.java:199)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$getClientAOPConfig_8697532701842707646.invokeNext(ClientConnectionFactoryDelegate$getClientAOPConfig_8697532701842707646.java)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.getClientAOPConfig(ClientConnectionFactoryDelegate.java)
            at org.jboss.jms.client.JBossConnectionFactory.ensureAOPConfigLoaded(JBossConnectionFactory.java:233)
            ... 4 more
            Caused by: java.io.EOFException
            at java.io.DataInputStream.readByte(Unknown Source)
            at org.jboss.serial.io.JBossObjectInputStream.readByte(JBossObjectInputStream.java:225)
            at org.jboss.jms.server.remoting.JMSWireFormat.read(JMSWireFormat.java:411)
            at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
            ... 11 more

            Hum?

            Thanks for help!

            Björn

            • 3. Re: Exception by getting a reference to the ConnectionFactor
              vasu vanam Newbie

              were you able to resolve the error received below, I also getting similar error.

              java.lang.RuntimeException: Failed to config client side AOP
              at org.jboss.jms.client.JBossConnectionFactory.ensureAOPConfigLoaded(JBossConnectionFactory.java:251)
              at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:196)
              at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:108)
              at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:103)
              at com.sterlingcommerce.woodstock.services.jms.JmsQueueAdapterServerImpl.createConnection(JmsQueueAdapterServerImpl.java:66)
              at com.sterlingcommerce.woodstock.services.jms.AbstractServerImpl.openSession(AbstractServerImpl.java:212)
              at com.sterlingcommerce.woodstock.services.jms.AbstractServerImpl.startupAdapter(AbstractServerImpl.java:181)
              at com.sterlingcommerce.woodstock.services.jms.JmsQueueAdapterServerImpl.startupAdapter(JmsQueueAdapterServerImpl.java:55)
              at com.sterlingcommerce.woodstock.services.IAdapterImpl.startAdapter(IAdapterImpl.java:168)
              at com.sterlingcommerce.woodstock.services.controller.StartAdapterThread.run(StartAdapterThread.java:69)
              at java.lang.Thread.run(Thread.java:567)

              • 4. Re: Exception by getting a reference to the ConnectionFactor
                Ovidiu Feodorov Master

                Looks like Remoting incompatiblity to me. Have you included the right jboss-messaging-client.jar in your classpath?

                The jboss-remoting.jar in the messaging class loading domain on the server-side and jboss-remoting.jar included with jboss-messaging-client.jar must be the same.

                • 5. Re: Exception by getting a reference to the ConnectionFactor
                  vasu vanam Newbie

                  once I changed the order of jboss-messaging-client.jar in the classpath,
                  it cleared the issue.

                  Thanks