# [Solved] Problems getting Tomcat server working

## reichmyu

Hi!

I'm having some problems getting Tomcat to work on my gentoo installation. Whenever I try to launch it using startup.sh it says that it has started successfully but logs do not say the same  :Razz: 

I have tried some googling and some searching in this forum but couln't come up with a solution.

Here is my log:

```
17-Oct-2018 00:45:49.866 ADVERTENCIA [main] org.apache.catalina.startup.ClassLoaderFactory.validateFile Problem with directory [/usr/share/tomcat-9/bin/${gentoo.classpath}], exists: [false], isDirectory: [false], canRead: [false]

17-Oct-2018 00:45:49.942 GRAVE [main] org.apache.catalina.startup.Catalina.initDirs No puedo hallar carpeta temporal especificada en [/usr/share/tomcat-9/temp]

17-Oct-2018 00:45:50.328 GRAVE [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

```

It looks like the servlet api is missing but dev-java/tomcat-servlet-api is installed in my system.

Any ideas?

Thanks in advance   :Very Happy: Last edited by reichmyu on Wed Oct 17, 2018 9:44 pm; edited 1 time in total

----------

## fedeliallalinea

Why you not start tomcat with /etc/init.d/tomcat-9 ?

----------

## reichmyu

 *fedeliallalinea wrote:*   

> Why you not start tomcat with /etc/init.d/tomcat-9 ?

 

Same results when executing it using the .init file

----------

## fedeliallalinea

I found this, but not sure if can help

----------

## reichmyu

 *fedeliallalinea wrote:*   

> I found this, but not sure if can help

 

I had already read that thread before, it helped me placing the config and init files where they should be but couldn't get it fully working though.

Thank you very much anyway  :Smile: 

----------

## Anon-E-moose

Don't know if this is the answer but seems similar to your problem

https://qiita.com/tkprof/items/d71af7899c9df96444cc

 *Quote:*   

> with running Tomcat 7 and Tomcat 8 with same conf/ files, the change has been made as following:
> 
> http://tomcat.apache.org/tomcat-8.0-doc/changelog.html
> 
> 55620: Enable Tomcat to start when either $CATALINA_HOME and/or $CATALINA_BASE contains a comma character. Prevent Tomcat from starting when $CATALINA_HOME and/or $CATALINA_BASE contains a semi-colon on Windows. Prevent Tomcat from starting when $CATALINA_HOME and/or $CATALINA_BASE contains a colon on inux/FreeBSD/etc.`
> ...

 

Edit to add: also this although it's from tomcat 7

https://stackoverflow.com/questions/38135009/catalina-configuration-test-catalina-sh-configtest

----------

## reichmyu

Finally found it!

In the file /usr/share/tomcat-9/package.env the servlet jar file was not appearing inside the CLASSPATH variable. Added its location and now it works perfectly!

Thank you all very much  :Very Happy: 

----------

## *zensiert*

 *reichmyu wrote:*   

> In the file /usr/share/tomcat-9/package.env the servlet jar file was not appearing inside the CLASSPATH variable. Added its location and now it works perfectly!

 

Thank you, I had the same problem, that also fixed it.

However, I'm not sure this is the right place to fix it, as this file gets overwritten after every update of the package. Therefore, I raised a bug:

https://bugs.gentoo.org/734948

----------

