Tomcat 7 with Java 8 on Raspberry Pi

UPDATE tomcat8 seems to work in this scenario, since I could open / manager / page as needed. Although this does not solve the initial state of the problem here, I advise you to use tomcat8 from debian backports in this scenario!

Raspbian provides the current version of Java 8 in version

root@raspberrypi :/etc/apt# java -version java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode) 

after installing tomcat 7, I returned to the tomcat7 version provided by debian backports, which

 root@raspberrypi :/etc/apt# dpkg -l |grep tomcat ii libtomcat7-java 7.0.56-1~bpo70+2 all Servlet and JSP engine -- core libraries ii tomcat7 7.0.56-1~bpo70+2 all Servlet and JSP engine ii tomcat7-admin 7.0.56-1~bpo70+2 all Servlet and JSP engine -- admin web applications ii tomcat7-common 7.0.56-1~bpo70+2 all Servlet and JSP engine -- common files 

which according to tomcat7 does not compile jsp examples , should work. This, however, is not the case, as the manager page leaves me with the following error:

 org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [1] in the generated java file: [/var/lib/tomcat7/work/Catalina/localhost/manager/org/apache/jsp/index_jsp.java] The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:477) org.apache.jasper.compiler.Compiler.compile(Compiler.java:379) org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213) org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108) 

Does anyone know what could be a pressing issue?

+7
java tomcat7 raspbian
source share
1 answer

As pointed out in the question, Tomcat provided by Raspbian does not work with Java 8. I was able to install Tomcat 8 in accordance with the instructions of this blog . To avoid the link and fix a small error, I will give the text there almost literally (updated for version 8.0.24):

Install Apache Tomcat 8 on Raspberry Pi

I have already installed the Apache 2 HTTP server on my raspberry Pi, and therefore, this article does the basic installation and configuration of Tomcat. First, update all installed packages:

 $ sudo apt-get update 

Confirm that Java is already installed:

 pi@raspberrypi /usr/bin $ java -version java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode) 

Enter the pi user home directory and download the required Tomcat release:

 $ wget http://mirrors.axint.net/apache/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz 

Extract the archived archive:

 $ tar xvf apache-tomcat-8.0.24.tar.gz 

Add the following custom XML element as the last child element to the parent element tomcat-users ~/apache-tomcat-8.0.24/conf/tomcat-users.xml (this creates an administrator account "system" whose password is "crimson"):

 <user username="system" password="raspberry" roles="manager-gui"/> 

Change the directory permissions in the following directories, as default, the pi Linux user cannot write to them:

[NB: I did not need to do this step, as in version 8.0.24, there was no apache-tomcat-8.0.24/work/Catalina directory]

Add a start script called tomcat to the /etc/init.d directory, which has the following contents:

 #!/bin/sh # /etc/init.d/tomcat # starts the Apache Tomcat service ### BEGIN INIT INFO # Provides: tomcat # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # X-Interactive: true # Short-Description: Start/stop tomcat application server ### END INIT INFO export CATALINA_HOME="/home/pi/apache-tomcat-8.0.24" case "$1" in start) if [ -f $CATALINA_HOME/bin/startup.sh ]; then echo $"Starting Tomcat" /bin/su pi $CATALINA_HOME/bin/startup.sh fi ;; stop) if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then echo $"Stopping Tomcat" /bin/su pi $CATALINA_HOME/bin/shutdown.sh fi ;; *) echo $"Usage: $0 {start|stop}" exit 1 ;; esac 

Use the update-rc.d command to add the appropriate links to the /etc/rc?.d directories:

 $ sudo update-rc.d tomcat defaults 

Check if the tomcat server starts:

 $ sudo /etc/init.d/tomcat start 

In the web client, specify the browser at http://"Raspberry Pi IP Address":8080

Tomcat screenshot

Verify that the tomcat server is stopping:

 $ sudo /etc/init.d/tomcat stop 

Finally, reboot the system, and the Tomcat application server should now start automatically at startup, as well as when the system shuts down.

All loans go to the project "Friday night."

One note: for me, as a hardcore Linux user, this solution sounds a bit hacky by installing software in the user's home directory, but it works.

+19
source share

All Articles