Some updated info to deploy to Amazon?

I’m trying to deploy a project in Amazon and I’m going crazy with this.

First, I tried with Ubuntu Linux, and tomcat installation based on several guides I readed. I end with a working Tomcat but my project don’t end working/deploying.

Then, after several hours without success, I saw a topic about deploying using elasticbean ( Deploying to Amazon Elastic Beanstalk for 7.2? - CUBA.Platform )

I did all steps, and I ended with an enviroment, my project published, and so on. But I get a
HTTP ERROR 503
Problem accessing /backend/. Reason:
Service Unavailable

This is my web.stdout.log
web.stdout.log (135.7 KB)

I have my Procfile ( web: java -Dspring.profiles.active=amazon -jar backend.jar ) pointing to my backend.jar all in one zip as previous link explains.

imagen

And this is my amazon-app.properties

Don’t know what more to do.

Hi,

In the logs it says the App cannot connect to the main datastore. It also says the url: local host:5432.

Probably you don’t have Postgres running locally on the beanstalk box, right?

Then you need to correct the connection settings to the Postgres DB.

Cheers
Mario

As far as I understand Cuba app must use the environment variables configured as explained , right? And the environment has postgres enabled… is what I understood

Well, I tried other several things, and I almost copied the settings of sample linked in the post of my first post. Nothing, and log don’t say anything about database connection. I only see exceptions

BTW, first error is in line 164

Sep 26 19:18:52 ip-172-31-45-138 web: 2020-09-26 19:18:52.332 ERROR [main] com.haulmont.addon.restapi.api.rest.RestAPIDispatcherServlet - Context initialization failed
Sep 26 19:18:52 ip-172-31-45-138 web: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.security.filterChains’: Cannot resolve reference to bean ‘org.springframework.security.web.DefaultSecurityFilterChain#0’ while setting bean property ‘sourceList’ with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.security.web.DefaultSecurityFilterChain#0’: Cannot create inner bean ‘(inner bean)#4939e1d8’ of type [org.springframework.security.web.authentication.www.BasicAuthenticationFilter] while setting constructor argument with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘(inner bean)#4939e1d8’: Cannot resolve reference to bean ‘clientAuthenticationEntryPoint’ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘clientAuthenticationEntryPoint’ defined in class path resource [com/haulmont/addon/restapi/rest-dispatcher-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/UnmarshalException

AFAIR something similar happened when tried on a Linux instance directly with tomcat. No database connection errors, just NoClassDefFound exceptions. Tomorrow will try again on Linux instance with tomcat anyway.2-web.stdout.log (104.7 KB)

That is probably true. I just mentioned what is written in the logs:

Sep 26 16:13:12 ip-172-31-45-138 web: Some environment checks failed on core module:
Sep 26 16:13:12 ip-172-31-45-138 web: Exception occurred while connecting to data store _MAIN_
Sep 26 16:13:12 ip-172-31-45-138 web: java.sql.SQLException: Cannot create PoolableConnectionFactory (Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.)

Regarding the env variables: I guess you can look into the guide on how to deploy to heroku I did some time ago. It also used this exact env variable substitution to define the connection to the DB: Deploy CUBA to Heroku in ten steps - CUBA.Platform

If it does not work at all, you can just switch to the old way (JNDI based). This will work for sure. I also used it quite regularly on AWS with ECS (Fargate) and jetty-env.xml.

This is happening because of a mismatch of Java versions that you are using. See: HTTP Error 404 on jelastic cloud - #9 от пользователя umeshhodwala - CUBA.Platform and jaxb - How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException - Stack Overflow

CUBA supports Java 8 / Java 11. Which one have you configured in beanstalk?

I will check your info and see.

This is happening because of a mismatch of Java versions that you are using. See: HTTP Error 404 on jelastic cloud and jaxb - How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException - Stack Overflow

CUBA supports Java 8 / Java 11. Which one have you configured in beanstalk?

Good question, don’t remember right now. I will delete the instance and create it again and check all of this. because can’t get it working with tomcat and ubuntu in EC2 either

Ok, one step forward. I changed platform to Corretto 8 running on 64bit Amazon Linux 2/3.1.1, and now seems to “work”, now investigating this new issue.

imagen

This just says that the backend still is not able to start. You have to look into the logs to find out what Is the problem on the backend.

Yes, some issue with database, investigating it right now. But now app is deployed, better than before :stuck_out_tongue:

Just for your information, Java version did the job. Now works as expected.