mendix / m2ee-tools

m2ee, the Mendix runtime helper tools for GNU/Linux
Other
27 stars 40 forks source link

ERROR - Core: An exception occurred while running the after-startup-action. #28

Closed wykydtronik closed 6 years ago

wykydtronik commented 6 years ago

Hello,

I am attempting to setup a Mendix instance for testing purposes. I've managed to set it up on EC2 place the database on on RDS instance. I got a dummy application to start/stop with m2ee-tools and I am able to visit it with a public URL.

Once I moved onto uploading the database and inputing in constants for the actual test application, I started running into issues. I don't recall specifically what the prompt mentioned, but it asked to update the database. There were a few options I tried before saying "Yes" to the update. From there I ran into an error starting the application (after said update)..

Attached the full log file, I'll insert a snippet of where the error starts below.

2018-02-05 17:29:01.887 ERROR - Core: An exception occurred while running the after-startup-action. 2018-02-05 17:29:01.887 ERROR - Core: com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.lang.NullPointerException at RestServicesCustomized.ACT_AfterStartup_InitializeREST (JavaAction : 'StartPublishesServicesJava') at Core.AfterStartup (SubMicroflow : 'Start REST')

Full Advanced stacktrace in attachment:

feb-5-logfile-m2ee.txt

Java: 1.8.0_151

knorrie commented 6 years ago

Hi,

The prompt about database updates is a confirmation prompt before changing the structure of tables and columns that exist in your database, because the current database structure is different from the new Mendix application model that you are starting.

However, the error is about the after-startup-action. This is a microflow that is defined in your application model to be executed always directly when starting the application. The fact that this microflow is running tells us that at least updating your database structure was successful. After that, it went on with the startup procedure and executed your microflow.

The problem is that in your own Java code, you're hitting a null pointer exception. This is a problem in your own Mendix project, which I cannot solve for you.

In this case the m2ee-tools program is just the messenger of the startup failure.

Hans

wykydtronik commented 6 years ago

Thanks @knorrie for the quick response. I relayed the message to our lead mendix dev and he will work on debugging the issue. He asked if it's possible to enable debugging on m2ee to access /debugger/ with login credentials. I did not see that in the documentations, do you have recommendations?

knorrie commented 6 years ago

If you start m2ee, do 'help' and it will show you all commands. One of them is ... Oh, wait. enabling and disabling the debugger is listed in the expert commands... I think they better belong in the normal list.

Anyway:

 enable_debugger - enable remote debugger API
 disable_debugger - disable remote debugger API
 show_debugger_status - show whether debugger is enabled or not
knorrie commented 6 years ago

I just added a change to the develop branch to move the debugger commands into the normal help output. Thanks for the feedback.

wykydtronik commented 6 years ago

Hi @knorrie I'm faced with a difficult challenge being that I am unable to enable the debugger because the application is not running, while the application cannot start because of the Afterstartup microflow.

I will try to work with the lead dev to resolve the issue, thanks for the pointers!

wykydtronik commented 6 years ago

Just leaving feedback on this issue for anyone that may run into similar scenario.

In the example file user-specific-m2ee.yaml it does not provide as an example for the ApplicationRootUrl: (which should be defined under mxruntime, please reference full-documented-m2ee.yaml) This is what caused the null point exception.

The issue above is a result of not having the ApplicationRootUrl: defined. Since we are firing up these server instances as public facing test servers, we needed to specify the URL (technically this our scenario is not on-premise).

Also noted, the example for nginx config is unclear. I had issues with rewrite rules (I'm coming from apache mod_rewrite). In /etc/nginx/nginx.conf I defined: include /etc/nginx/conf.d/*.conf and then placed mendix.conf into that directory... below, location{} will give you rewrite rules for mendix apps. I've also commented out the SSL lines since we're only testing. Hopefully these examples will be a good reference for anyone running into similar issues while setting up m2ee, nginx, and java from scratch.

upstream mendix_runtime {
        server 127.0.0.1:8000;
        keepalive 8;
}

server {
        server_name _;

        # Replace the following two lines with the server block above for redirecting all plain http traffic to https
        listen 80 default_server;
        listen [::]:80 default_server;
        # If this server block only includes https, you can uncomment the following line to enable HSTS
        # add_header Strict-Transport-Security "max-age=31536000;";

        # Use your own certificates when going into production
        #ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
        #ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;

        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;

        root /srv/mendix/myapp/web/;

        index index.html;

        client_max_body_size 1024M;

        location / {
                if ($request_uri ~ ^/(.*\.(css|js)|forms/.*|img/.*|pages/.*)\?[0-9]+$) {
                        expires 1y;
                }
                proxy_pass http://mendix_runtime;
        }
}