Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Unable to use .war in Apache Tomcat
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
alogim
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2015
Posts: 95

PostPosted: Mon Sep 24, 2018 6:43 pm    Post subject: Unable to use .war in Apache Tomcat Reply with quote

I installed www-servers/tomcat. I then created a new instance running the following command:
Code:
sudo /usr/share/tomcat-9/gentoo/tomcat-instance-manager.bash --create --user michael
Successfully created instance 'tomcat-9'
It's strongly recommended for production systems to go carefully through the
configuration files at '/etc/tomcat-9'.
The generated initial configuration is close to upstreams default which
favours the demo aspect over hardening.
I ran this with sudo because otherwise it cannot create the various files under /var/lib/tomcat-9/.
I then ran
Code:
sudo /etc/init.d/tomcat-9 start
 * Caching service dependencies ...                                       [ ok ]
 * Executing: /lib64/rc/sh/openrc-run.sh /lib64/rc/sh/openrc-run.sh /etc/init.d/tomcat-9 start
 * Starting tomcat-9 ...
 * start-stop-daemon: fopen `/var/run/tomcat-9.pid': No such file or directory
 * Detaching to start `/opt/icedtea-bin-3.8.0/bin/java' ...   

The server now is running and is accessible from the browser through the localhost:8080 or 127.0.0.1:8080 address.
I then downloaded WebGoat from this page (the .war file called WebGoat-5.4.war), renamed it to WebGoat.war and copied it into /var/lib/tomcat-9/webapps.

As you can see, it is correctly detected by Tomcat, however when I click on it, it asks for a user and a password, I enter 'webgoat' as user and 'webgoat' as password and then this page is shown.

My /usr/share/tomcat-9/conf/tomcat-users.xml contains the following:
Code:
<role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <user username="admin" password="admin" roles="manager-gui,adm$

  <role rolename="webgoat_basic"/>
  <role rolename="webgoat_admin"/>
  <role rolename="webgoat_user"/>

  <user username="webgoat" password="webgoat" roles="webgoat_admin"/>
  <user username="basic" password="basic" roles="webgoat_user,webgoat_basic"/>
  <user username="guest" password="guest" roles="webgoat_user"/>


EDIT: if I try to add a new server from Netbeans, passing /usr/share/tomcat-9/ as main directory and admin as user and password and then I click on Start, I get this:
Code:
24-Sep-2018 20:55:28.244 WARNING [main] org.apache.catalina.startup.ClassLoaderFactory.validateFile Problem with directory [/usr/share/tomcat-9/bin/${gentoo.classpath}], exists: [false], isDirectory: [false], canRead: [false]
24-Sep-2018 20:55:28.268 SEVERE [main] org.apache.catalina.startup.Catalina.initDirs Cannot find specified temporary folder at [/usr/share/tomcat-9/temp]
24-Sep-2018 20:55:28.520 SEVERE [main] org.apache.tomcat.util.digester.Digester.startElement Begin event threw error
 java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
   at java.lang.Class.privateGetPublicMethods(Class.java:2902)
   at java.lang.Class.getMethods(Class.java:1615)
   at org.apache.tomcat.util.IntrospectionUtils.findMethods(Unknown Source)
   at org.apache.tomcat.util.IntrospectionUtils.setProperty(Unknown Source)
   at org.apache.tomcat.util.IntrospectionUtils.setProperty(Unknown Source)
   at org.apache.catalina.startup.SetAllPropertiesRule.begin(Unknown Source)
   at org.apache.tomcat.util.digester.Digester.startElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
   at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1339)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
   at org.apache.tomcat.util.digester.Digester.parse(Unknown Source)
   at org.apache.catalina.startup.Catalina.load(Unknown Source)
   at org.apache.catalina.startup.Catalina.load(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.apache.catalina.startup.Bootstrap.load(Unknown Source)
   at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
   at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   ... 41 more

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
   at java.lang.Class.privateGetPublicMethods(Class.java:2902)
   at java.lang.Class.getMethods(Class.java:1615)
   at org.apache.tomcat.util.IntrospectionUtils.findMethods(Unknown Source)
   at org.apache.tomcat.util.IntrospectionUtils.setProperty(Unknown Source)
   at org.apache.tomcat.util.IntrospectionUtils.setProperty(Unknown Source)
   at org.apache.catalina.startup.SetAllPropertiesRule.begin(Unknown Source)
   at org.apache.tomcat.util.digester.Digester.startElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
   at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1339)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
   at org.apache.tomcat.util.digester.Digester.parse(Unknown Source)
   at org.apache.catalina.startup.Catalina.load(Unknown Source)
   at org.apache.catalina.startup.Catalina.load(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.apache.catalina.startup.Bootstrap.load(Unknown Source)
   at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
   at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   ... 41 more

_________________
Desktop: i5-3570k - 2x4 GB - Sapphire HD 7950 Dual-X - 500 GB WD Caviar Black - Dell SE2717H 27"
Laptop: HP EliteBook 850 G5 - i7-8550U - 1x16GB - Intel UHD 620 - 512 GB Samsung NVMe SSD
Phone: OnePlus 5T - SD835 - 8 GB - Adreno 540 - 128 GB
Back to top
View user's profile Send private message
ShadowCat8
Apprentice
Apprentice


Joined: 07 Oct 2008
Posts: 161
Location: San Bernardino, CA, USA

PostPosted: Mon Oct 08, 2018 8:31 pm    Post subject: Reply with quote

alogim wrote:
Code:
24-Sep-2018 20:55:28.244 WARNING [main] org.apache.catalina.startup.ClassLoaderFactory.validateFile Problem with directory [/usr/share/tomcat-9/bin/${gentoo.classpath}], exists: [false], isDirectory: [false], canRead: [false]
24-Sep-2018 20:55:28.268 SEVERE [main] org.apache.catalina.startup.Catalina.initDirs Cannot find specified temporary folder at [/usr/share/tomcat-9/temp]
...<snip>...

So, what directories do you have under "/usr/share/tomcat-9/"? Do you have a "bin" or "temp" directory underneath it, and if so, what permissions and ownerships are on them?

Hope that helps. Let us know.
_________________
________________________

"As far as the laws of mathematics refer to reality, they are not
certain, and as far as they are certain, they do not refer to reality."

-- Albert Einstein
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum