1

I am developing a JEE application and I want to do some migration when the application starts. Actually, I am using payara-micro with Docker as a server. For an unknown reason, this code is never executed.

Here is my code :

@Singleton
@Startup
public class FlywayMigration {


    @PostConstruct
    public void startMigration(){
      System.out.println("Starting flyway migration");
    }
} 

I added the javaee-api as dependency in my pom :

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

Here is the content of my Dockerfile :

FROM payara/micro

COPY ./target/mywebapp.war $DEPLOY_DIR

After building and running the docker image, the logs of the application shows that the app started well :

Payara Micro URLs
http://5b258e6a441a:8080/mywebapp

'mywebapp' REST Endpoints
 GET    /mywebapp/api/hello
 GET    /mywebapp/api/myresource

Can anyone help me find a solution ?

Dimitri
  • 8,122
  • 19
  • 71
  • 128
  • *For an unknown reason, this code is never executed.* How are you starting up your application? – Naman Sep 08 '17 at 01:13
  • Yes, the application starts. I even have some rest web services that are accessible – Dimitri Sep 08 '17 at 05:32
  • @Dmitri . I meant how do you start up the application? Using some command line or IDE configuration? – Naman Sep 08 '17 at 05:57
  • Oh ok, I am actually using docker and the war is copied to the container and the deployment is done automatically – Dimitri Sep 08 '17 at 08:02
  • At the bottom of the Payara Micro log file, it gives you a summary of what's deployed. Is that telling you that the app deploys? It would also be useful to see your Dockerfile – Mike Sep 08 '17 at 09:36
  • @mike I have updated the questions – Dimitri Sep 08 '17 at 18:15

1 Answers1

5

I finally make it work. The problem is that I was using the bad @Singleton annotation. Instead of using @javax.ejb.Singleton I used to @javax.inject.Singleton.

Dimitri
  • 8,122
  • 19
  • 71
  • 128