Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to suggest correct JAVA_HOME configuration for tomcat #2222

Closed
jasonsydes opened this issue Aug 29, 2019 · 9 comments · Fixed by #2224
Closed

Update docs to suggest correct JAVA_HOME configuration for tomcat #2222

jasonsydes opened this issue Aug 29, 2019 · 9 comments · Fixed by #2224
Milestone

Comments

@jasonsydes
Copy link

Hi Apollo!

We had recently upgraded to Ubuntu 18.04, and when we did, our longtime Apollo installation stopped working. I just spent the last several days banging my head against the problem, and I finally figured it out. I'm hoping you can make a minor tweak to your docs to help prevent others from experiencing the same.

In the end, it turned out to be conflicting installations of Java that did it in. Probably the Ubuntu upgrade to 18.04 installed Java11 alongside our existing Java8 install.

I was getting errors like the one I copy/pasted at the bottom. After many unsuccessful dead ends, I finally somehow stumbled upon a couple of comments by @nathandunn:

#1521 (comment)
#1521 (comment)

That lead me to try the following:

apt remove openjdk-11-jre:amd64 openjdk-11-jre-headless:amd64

And that solved the problem.

But it's actually totally ok to have two different versions of Java installed, so long as you configured tomcat to use the correct Java, per Nathan's comments. Unfortunately, your docs here seem to imply that the following is sufficient to do so:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/  # or set in .bashrc / .project

But it's not. On Ubuntu systems at least, you need to configure JAVA_HOME in /etc/default/tomcat8. For me, that looks like the following:

In /etc/default/tomcat8:

# The home directory of the Java development kit (JDK). You need at least
# JDK version 8. If JAVA_HOME is not set, some common directories for
# OpenJDK and the Oracle JDK are tried.
#JAVA_HOME=/usr/lib/jvm/java-8-openjdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

If you could update your docs to reflect that requirement, I think it could help many.

Thank you so much for developing Apollo for the community!!

Configuring Shiro ...

Shiro Configured
2019-08-28 19:33:01,256 [localhost-startStop-4] ERROR context.GrailsContextLoaderListener  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	... 5 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	... 5 more
Caused by: org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	... 5 more
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
	at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276)
	at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	... 5 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationException
	... 9 more
2019-08-28 19:33:01,257 [localhost-startStop-4] ERROR context.GrailsContextLoaderListener  - Error initializing Grails: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	... 5 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	... 5 more
Caused by: org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
	... 5 more
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
	at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276)
	at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	... 5 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationException
	... 9 more
28-Aug-2019 19:33:01.257 SEVERE [localhost-startStop-4] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
28-Aug-2019 19:33:01.258 SEVERE [localhost-startStop-4] org.apache.catalina.core.StandardContext.startInternal Context [/apollo] startup failed due to previous errors
28-Aug-2019 19:33:01.289 WARNING [localhost-startStop-4] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [apollo] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
28-Aug-2019 19:33:01.290 WARNING [localhost-startStop-4] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [apollo] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@11.0.4/java.lang.Object.wait(Native Method)
 java.base@11.0.4/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
28-Aug-2019 19:33:01.311 INFO [localhost-startStop-4] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/var/lib/tomcat8/webapps/apollo.war] has finished in [21,000] ms
28-Aug-2019 19:35:21.823 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/apollo]


@jasonsydes jasonsydes changed the title Update docs to suggest removing conflicting Javas Update docs to suggest correct JAVA_HOME configuration for tomcat Aug 29, 2019
@nathandunn nathandunn added this to the 2.4.2 milestone Aug 29, 2019
@nathandunn
Copy link
Contributor

thanks . . . I'll try to get that updated by next week

@nathandunn
Copy link
Contributor

but feel free to issue a PR if you want to edit in the doc directly

nathandunn added a commit that referenced this issue Sep 5, 2019
nathandunn added a commit that referenced this issue Sep 5, 2019
@lfaino
Copy link

lfaino commented Oct 29, 2019

Dear,
i tried this option and it is not working. I set the JAVA path in tomcat8 and when I run apollo run-local i get:
Grails not found using grailsw
Using gradlew
Gradle version: 2.11
Node Version: 8
Npm Version: 3
Yarn Version: 1
javac 11.0.4 found
javac installed
You must install JDK 1.8

any other solution?

Cheers
Luigi

@nathandunn
Copy link
Contributor

If you type:

  • echo $JAVA_HOME
  • javac -version
  • which javac

what do you see?

@lfaino
Copy link

lfaino commented Oct 29, 2019

here you are

lfaino@ZeusPV:$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/bin/
lfaino@ZeusPV:
$ javac -version
javac 11.0.4
lfaino@ZeusPV:~$ which javac
/usr/bin/javac

@nathandunn
Copy link
Contributor

I see @lfaino . You need to build with javac 8

You'll need to update your symlinks to use javac 8 version, or simply uninstall java / javac 11 in order to build it.

Is it mac or linux? For mac homebrew has some nice workarounds.

Conversely, you can also use Docker.

@nathandunn
Copy link
Contributor

@lfaino
Copy link

lfaino commented Oct 29, 2019

I tried with docker and it works but how can I run the instance on the server and have it running after I close the terminal?

@nathandunn
Copy link
Contributor

@lfaino I would remove java / javac 11 unless you actually are using those features. You need javac version 8 to build it. If you want to run it somewhere else, you need to follow those instructions:

  • Install tomcat8
  • set JAVA_HOME as you did, in /etc/default/tomcat8
  • You copy your war file into tomcat's webapp directory (usually /var/lib/tomcat8/webapp)

You can do all of this with docker as well, just depends on how many people you're trying to support.

If you have still have trouble, if you provide more details on the installation that would be helpful (operation system, number of users, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants