2 Replies Latest reply on May 1, 2008 4:28 AM by timfox

    Problem in creating Jboss Messaging .sar deploying

    ssjboss

      Hi,

      I am trying to implement jboss messaging listener service.


      Content of my .sar file is
      ----------------------------------
      jar -tf message_listener_service.sar
      -------------------------------------------

      META-INF/
      META-INF/MANIFEST.MF
      src/
      src/service/
      META-INF/jboss-service.xml
      commons-io-1.2.jar
      commons-logging-1.1.jar
      javassist.jar
      jboss-aop-jdk50.jar
      jboss-common.jar
      jboss-j2ee.jar
      jboss-jmx.jar
      jboss-messaging-client.jar
      jboss-messaging.jar
      jboss-remoting.jar
      jboss-system.jar
      jboss-xml-binding.jar
      jbossall-client.jar
      log4j.jar
      src/service/Listener.class
      trove.jar
      ------------------------
      Content of -> META-INF/jboss-service.xml is
      ------------------
      <server>
       <mbean code="src.service.Listener"
       name="service.directory.monitor:src.service=Listener">
       </mbean>
      <server>

      ----------------


      Listener code
      ---------------

      package src.service;
      
      /*
      Use source code downloads, example commands,
      and any other techniques at your own risk.
      No warranty is provided.
      */
      
      import java.util.Properties;
      
      import javax.jms.JMSException;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      import javax.jms.TextMessage;
      import javax.jms.Topic;
      import javax.jms.TopicConnection;
      import javax.jms.TopicConnectionFactory;
      import javax.jms.TopicSession;
      import javax.jms.TopicSubscriber;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      public class Listener implements MessageListener {
      
       String url_;
       String name_;
       TopicConnection conn = null;
       TopicSession session = null;
       Topic topic = null;
      
       public Listener(String url, String name) {
       super();
      
       url_ = url;
       name_ = name;
      
       try {
       this.initializeListener();
       } catch (Exception e) {
       System.out.println("Error creating listener: " + e);
       e.printStackTrace();
       }
      
       }
      
       public void onMessage(Message msg) {
      
       TextMessage tm = (TextMessage) msg;
      
       try {
       System.out.println("Incoming message: " + tm.getText());
       } catch (Exception e) {
       e.printStackTrace();
       }
       }
      
       private void initializeListener() throws JMSException, NamingException {
      
       Properties props = new Properties();
       props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
       props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
       props.setProperty("java.naming.provider.url", url_);
      
       Context context = new InitialContext(props);
       System.out.println("performing lookup...");
      
       Object tmp = context.lookup("MyExampleConnectionFactory");
       System.out.println("lookup completed, making topic");
      
       TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
       conn = tcf.createTopicConnection();
       topic = (Topic) context.lookup(name_);
      
       session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
       conn.start();
      
       TopicSubscriber recv = session.createSubscriber(topic);
      
       recv.setMessageListener(this);
       }
      
      
       public void disconnect() throws JMSException {
       if(conn != null) {
       conn.stop();
       }
      
       if(session != null) {
       session.close();
       }
      
       if(conn != null) {
       conn.close();
       }
       }
      
       public static void main(String args[]) {
      
       System.out.println("Starting JMS Example Listener");
       System.out.println("Program will be active for 1 minute.");
      
       //change these values to your situtation:
       Listener listener = new Listener("localhost:1099", "topic/myTopic");
      
      
       //leave it open for 2 minutes:
       try {
       Thread.sleep(97000);
       } catch(Exception e) {
       System.out.println("Error sleeping: " + e);
       e.printStackTrace();
       }
      
       try {
       System.out.println("Listener before Diss");
       listener.disconnect();
       } catch(Exception e) {
       System.out.println("Error terminating listener JMS objects: " + e);
       e.printStackTrace();
       }
      
       System.out.println("Done listening");
       }
      }


      -------------


      I started server as: run -c <my_config_name>


      I am getting fallowing error when i placed message_listener_service.sar in - C:\myjboss-4.2.2\jboss-4.2.2.GA\server\messaging\deploy


      17:55:17,015 ERROR [MainDeployer] Could not create deployment: file:/C:/myjboss-
      4.2.2/jboss-4.2.2.GA/server/messaging/deploy/message_listener_service.sar
      org.jboss.deployment.DeploymentException: src.service.Listener.<init>(); - neste
      d throwable: (java.lang.NoSuchMethodException: src.service.Listener.<init>())
       at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
      :196)
       at org.jboss.system.ServiceController.install(ServiceController.java:226
      )
       at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy4.install(Unknown Source)
       at org.jboss.deployment.SARDeployer.create(SARDeployer.java:249)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
      er.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
      or.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
      BeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy9.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
      tScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
      canner.java:634)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      doScan(AbstractDeploymentScanner.java:263)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      loop(AbstractDeploymentScanner.java:274)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
      run(AbstractDeploymentScanner.java:225)
      Caused by: java.lang.NoSuchMethodException: src.service.Listener.<init>()
       at java.lang.Class.getConstructor0(Class.java:2678)
       at java.lang.Class.getConstructor(Class.java:1629)
       at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:
      1232)
       at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:
      286)
       at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:
      344)
       at org.jboss.system.ServiceCreator.install(ServiceCreator.java:157)
       at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
      tor.java:451)
       at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
      :171)
       ... 33 more



      I tried in google also, it is urgent, please help me , I have to add any jar files, need to change any .xml files (or) I have to change my listener ?




        • 1. Re: Problem in creating Jboss Messaging .sar deploying
          ssjboss

          Still after changing my listener i am getting same error

          jboss-service.xml is able to detect my listener program , after that something wrong happening , I want help in solving this

          i added 3 more classes

          now my jar is as fallows

          -----------------------
          >jar -tf message_listener_service.sar
          ------------------------
          META-INF/
          META-INF/MANIFEST.MF
          src/
          src/service/
          META-INF/jboss-service.xml
          commons-io-1.2.jar
          commons-logging-1.1.jar
          javassist.jar
          jboss-aop-jdk50.jar
          jboss-common.jar
          jboss-j2ee.jar
          jboss-jmx.jar
          jboss-messaging-client.jar
          jboss-messaging.jar
          jboss-remoting.jar
          jboss-system.jar
          jboss-xml-binding.jar
          jbossall-client.jar
          log4j.jar
          src/service/Listener$ScannerThread.class
          src/service/Listener.class
          src/service/ListenerListener.class
          src/service/ListenerMBean.class
          src/service/MethodListener.class
          trove.jar

          please suggest me in this ?

          -----------
          -SS


          • 2. Re: Problem in creating Jboss Messaging .sar deploying
            timfox

            Read the stack trace!


            Caused by: java.lang.NoSuchMethodException: src.service.Listener.<init>()


            It's saying you haven't defined a default constructor in your class.

            I suggest you do a little more research before posting on this forum :)