Search code examples
javajbossprogram-entry-pointear

Run main in a project from EAR project


I am working on an EAR project for jboss eap 6.4, and I need to run some lines of code upon deployment of the project. I was trying to add to a project belonging to the EAR project, a java main class, and setting it on this project on the Run/Debug Settings. But it is not working.

So the question is, how can I run a main class, or a piece of code upon the EAR project deployment.

Thanks!!


Solution

  • So in the end I created a class in my web project within the EAR project as follows:

    import javax.ws.rs.ApplicationPath;
    import javax.ws.rs.core.Application;
    
    @ApplicationPath("/")
    public class RestApplication extends Application {
    
        public RestApplication(){
            /* Code to be executed upon deployment */
        }
    }