简体   繁体   中英

Running a standalone Java application within Jboss/Jetty

I have a standalone application which will be listening for messages from ActiveMQ and process the message.

This is not a web application. It is just a listener for ActiveMQ messages.

Can I deploy this application in Jboss/Jetty?

Not as far as I know, I think you should convert it to a web application (ie no main() method, and a lot of other changes). However, it shouldn't be too hard to do in any modern IDE. If you want to run the code that is in your main method, once you have the application converted toa web app, you can wrap the code in a Listener, eg

In your web.xml

<listener>
   <listener-class>my.Listener</listener-class>
</listener>

and

package my;

public class Listener implements javax.servlet.ServletContextListener {

   public void contextInitialized(ServletContext context) {
      // code of your main() goes here
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM