1

I created a simple application with a main class that start a camel route. I can run it from my IDE.

This might sound like a stupid question, but how can I make the main class be executed when i deploy the application in Jboss?

Mike
  • 157
  • 1
  • 11
  • Well, you should pass your main class code to a singleton EJB and annotate it with @Startup. Then the EJB will be triggered upon application startup. Take a look at the [documentation](https://docs.oracle.com/javaee/7/tutorial/ejb-basicexamples002.htm). – António Ribeiro Mar 13 '16 at 19:14
  • Can you write your comment in an answer so i can accept it, please? – Mike Mar 13 '16 at 21:52
  • Unfortunately, since the question was marked as a duplicate, I can not. But I'm glad you've followed my suggestion and that it worked! – António Ribeiro Mar 13 '16 at 22:04

1 Answers1

0

Assuming you deploying a web application to JBoss. If you are using plain servlets then in the init method of servlet call the main class method which you want to execute. Configure the servlet to load on startup in your web.xml.

If using spring framework then there are many ways lie init-method, InitialzingBean, @PostConstruct.

Bhushan Bhangale
  • 10,921
  • 5
  • 43
  • 71
  • The OP isn't using servlets nor Spring... Can't you take a closer look at the question and try to provide an answer purely based on JavaEE? – António Ribeiro Mar 13 '16 at 19:18