Apache Tomcat Exception in Console on Startup - java

I'm using tomcat to run a web application. Without any projects added to my Tomcat v6.0 Server at localhost, I start the server and an exception is being thrown. It says there isn't a mapping for class sun.awt.AppContext I'm using jre6 as my runtime. I have my JAVA_HOME environmental variation set to the jre6 folder and I have Eclipse set to the same one. Do you know why I am getting this exception and how to resolve?
Here is my stack trace:
Nov 1, 2011 5:21:36 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\oracle\Ora11g\BIN\;C:\Program Files\Serena\Dimensions 2009 R1\CM\prog;C:\Program Files\Serena\Dimensions 2009 R1\CM\prog\Microsoft.VC80.MFC;C:\Program Files\Serena\Dimensions 2009 R1\CM\prog\Microsoft.VC80.CRT;C:\Program Files\Serena\Dimensions 2009 R1\CM\prog\Microsoft.VC80.ATL;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\OTG;C:\Program Files\Windows Imaging\;C:\Program Files\IBM\Personal Communications\;C:\Program Files\IBM\Trace Facility\;C:\Program Files\HP\QuickTest Professional\bin;c:\PROGRA~1\IBM\SQLLIB\BIN;c:\PROGRA~1\IBM\SQLLIB\FUNCTION;c:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;C:\Program Files\Eclipse 3.7\apache-maven-3.0.3\bin; C:\Program Files\Java\jre6\bin;C:\Program Files\HP\QuickTest Professional\bin
Letting agent QTJA do the transformation
Letting agent QTOR do the transformation
java.util.NoSuchElementException: No mapping for class sun.awt.AppContext
at com.mercury.bcel.TransformerXmlFile$MappingLocator.setMapping(TransformerXmlFile.java:96)
at com.mercury.bcel.TransformerFactory.createTransformer(TransformerFactory.java:56)
at com.mercury.bcel.TransformerMainImpl.transform(TransformerMainImpl.java:33)
at com.mercury.bcel.TransformerMain.transform(TransformerMain.java:35)
at com.mercury.javashared.transform.TransformersChain.transform(TransformersChain.java:32)
at com.mercury.javashared.transform.CommunicationThread.processTransformRequest(CommunicationThread.java:61)
at com.mercury.javashared.transform.CommunicationThread.run(CommunicationThread.java:38)
Thank you for your thoughts!

I'm pretty sure your problem is HP QuickTest.
HP QuickTest sets up JVM options which modify the java bootclasspath - nasty.
I'm not sure exactly how it works, but I'm guessing that it sets an environment variable JAVA_OPTS (which is picked up by Tomcat's startup scripts)
3 options (first is definite, second & third are based on my guess above):
Try uninstalling HP QuickTest
Open up bin\catalina.bat inside your Tomcat installation, and try resetting JAVA_OPTS at the start of the script.
Something like this:
echo "Current JAVA_OPTS (resetting to ''):"
echo %JAVA_OPTS%
set JAVA_OPTS=""
3: Or, try setting JAVA_OPTS variable (to empty string) in your Eclipse server startup dialog

i also faced the same issue, but my Apache Tomcat loaded through Cargo Container wrapper.
So I removed these 2 env. variable to fix the issue
JAVA_TOOL_OPTIONS -agentlib:jvmhook
_classload_hook jvmhook

Related

Running Tomcat9 with dedicated tomcat user: Startup fails with JAVA_HOME or 500 in localhost:8080

I have just installed Apache Tomcat9 on my machine, following mostly these instructions, but I am really stuck with user management here.
My enviroment: Ubuntu 20.04, Java 11 (There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-oracle/bin/java).
Few exceptions: I neither have JAVA_HOME, nor the java home directory in my PATH environment variable.
I also have created a symlink at /opt/tomcat/latest/ for pointing to the right folder for all tomcat files.
Now I want to let tomcat run as a service as user 'tomcat'.
This is how my tomcat.service file looks like:
[Unit]
Description=Tomcat 9 servlet container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-11-oracle/bin/java"
# Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"
Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/tomcat.pid"
# Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
Now, when I comment out the line for the JAVA_HOME environment variable, the startup of the tomcat service fails (journalctl -xe):
Okt 27 17:43:52 my-user startup.sh[7714]: Tomcat started.
Okt 27 17:43:52 my-user shutdown.sh[7737]: PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted.
Okt 27 17:43:52 my-user sudo[7690]: pam_unix(sudo:session): session closed for user root
So there is something running as root, what I don't get.
But when I comment out this line, tomcat runs happily, but on localhost:8080 I am getting this 500:
Message org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
or this 404
Message JSP file [/index.jsp] not found
It is similar like here and here.
I also did sudo chown -R tomcat /opt/tomcat/latest/work/Catalina/localhost, but this did not help.
Any help is appreciated.
Now it works and I'm going to list my changes here, but I'm not sure, which one was crucial and which was unnecessary.
JAVA_HOME in tomcat.service changed to: Environment="JAVA_HOME=/usr/lib/jvm/java-11-oracle"
CATALINA_PID in tomcat.service changed to: Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
give write access to other users to folders work, temp, logs, webapps. Sources here and here.
using this guide: https://www.interserver.net/tips/kb/install-apache-tomcat-on-ubuntu-18-04/

Deployment issue with IntelliJ when moved to open-jdk 8u212

We recently migrated our systems to open-jdk from oracle jdk. When I tried deploying my war application, Facing some issues with the same.
C:\Softwares\apache-tomcat-8.0.24\bin\catalina.bat run
[2019-06-14 05:19:12,449] Artifact expresso:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\Rohit.Bansal.IntelliJIdea2019.1\system\tomcat\Unnamed_expresso_3"
Using CATALINA_HOME: "C:\Softwares\apache-tomcat-8.0.24"
Using CATALINA_TMPDIR: "C:\Users\Rohit.Bansal.IntelliJIdea2019.1\system\tomcat\Unnamed_expresso_3\temp"
Using JRE_HOME: "C:\Program Files\AdoptOpenJDK\jdk-8.0.212.04-openj9"
Using CLASSPATH: "C:\Softwares\apache-tomcat-8.0.24\bin\bootstrap.jar;C:\Softwares\apache-tomcat-8.0.24\bin\tomcat-juli.jar"
port = 81
Error: Password file read access must be restricted:
C:\Users\Rohit.Bansal\.IntelliJIdea2019.1\system\tomcat\Unnamed_expresso_3\jmxremote.password
sun.management.AgentConfigurationError
at sun.management.jmxremote.ConnectorBootstrap.checkPasswordFile(ConnectorBootstrap.java:577)
at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:426)
at sun.management.Agent.startAgent(Agent.java:262)
at sun.management.Agent.startAgent(Agent.java:452)
at java.lang.System.startSNMPAgent(Native Method)
at java.lang.Thread.completeInitialization(Thread.java:168)
at java.lang.J9VMInternals.completeInitialization(J9VMInternals.java:74)
Exception in thread "main" java/lang/RuntimeException: sun.management.AgentConfigurationError
at sun/management/Agent.error (Agent.java:526)
at sun/management/Agent.startAgent (Agent.java:269)
at sun/management/Agent.startAgent (Agent.java:452)
at java/lang/System.startSNMPAgent (NativeMethod:4294967295)
at java/lang/Thread.completeInitialization (Thread.java:168)
at java/lang/J9VMInternals.completeInitialization (J9VMInternals.java:74)
Disconnected from server
I encountered the same issue here: debug a Webapp in Tomcat from IntelliJ, after updating AdoptOpenJDK to jdk-8.0.212.04-openj9 under Windows (in my case Windows 7).
My solution was to add the following parameter to the VM Options of my run config:
-Dcom.sun.management.jmxremote.authenticate=false
Now it works as before.
It was somewhat difficult for me to find references to the problem, as in my case the error message was in German (cited here to augment the chances to get a result for other people searching for the German version):
Fehler: Lesezugriff auf Kennwortdatei muss eingeschränkt werden
Obviously, the chances to get meaningful results are somewhat lower. I have then changed the language to en by setting the VM Option -Duser.language=en.
I haven't found a central location to set these parameters, but what probably comes closest is to set the parameters in the template of the local tomcat run configuration.

STS 3.6 RELEASE error running server

When I run my project, I don't have errors.
But After login, when I try to enter in a form page the application give me the follow error:
GRAVE: Servlet.service() for servlet jsp threw exception
java.util.NoSuchElementException
at java.util.ArrayList$Itr.next(Unknown Source)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1381)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:772)
at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:779)
at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:895)
...
I think the problem is in the configuration of tomcat but I don't understand where.
I have tomcat7.0.52, use java version 1.7.0_60, idem for jdk.
At my colleague work all without problems, we have the same tomcat version, the only difference is that I have STS 3.6 RELEASE, and He have the 3.5.
EDIT:
I try to delete server, and recreate it, but the problem don't change.
I think that the problem is on wrong configuration server because any project I run give me the same error.
This is my catalina arguments:
-Dcatalina.base="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/base-instance"
-Dcatalina.home="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/tomcat-7.0.53.B.RELEASE"
-Dwtp.deploy="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/base-instance/wtpwebapps"
-Djava.endorsed.dirs="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/tomcat-7.0.53.B.RELEASE/endorsed" -Xmx768m -Xss256k -XX:MaxPermSize=256m
-Dinsight.enabled=false -Dspring.profiles.active=dev
Any ideas?
Thank
It looks like the problem is with the version of Tomcat that tcServer is derived from.
This bug which is fixed in Tomcat 7.0.55 is looks like the cause.
I've done some testing and found that the bug is not present in Tomcat 7.0.50, which is used by tcServer Dev Edition 2.9.5.SR1.
So it's either 7.0.51 or 7.0.52 (as you discovered) which introduced the bug.

Hibernate fails with NullPointerException in EntityTuplizerFactory.constructTuplizer? Why?

I have a problem when I try to instantiate Hibernate and connect with a MySQL database (see error message below).
Curiously enough the connection works fine using the exact same hibernate.cfg.xml file when running Junit tests but it refuses to work when run from Tomcat...
I am starting to run out of ideas.
Any clues or tip where to look?
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.DynamicMapEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:69)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at se.fmt.atlantism.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)
... 38 more
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 47 more
I'm writing this for future Googlers and reference.
I've done some more research and the root source of the problem is still not known. However the following article throw me on the right track.
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
It seems like the Tomcat (version 6 at least) packages available in Ubuntu (and Debian) are not working correctly. Instead I installed Tomcat using the following guide:
http://www.ctrip.ufl.edu/tomcat6-debian-lenny-howto
While this might not be the premium choice of installation it seems necessary to get Tomcat version 6 running without problems on Ubuntu and/or Debian Lenny.
In my case, this error was resolved by switching the <dependency/> order in my pom.xml. When hibernate (3.2.7.ga) comes before hibernate-annotations (3.4.0.GA) this error occurs. The other way around, it works fine. This is the case even with scope=compile.
I would guess that you need to tweak your classpath, except that (assuming you've dropped both jars in WEB-INF/lib) it should alpha-sort in the correct order. But maybe this will give someone a hint on how to move forward.
In my case it was a simple mistake - the config file *.hbm.xml had a property that the mapped object didnt have! I also heard of cases of that error apearing when you misspell a get/set function - very similar to my case.
I was facing the same problem. It went away after I downloaded "javassist.jar" and put it in the classpath: http://www.java2s.com/Code/Jar/JKL/Downloadjavassistjar.htm
This is how the Tomcat daemon process looks:
root 2605 0.0 0.0 16584 376 ? Ss 15:39 0:00
/usr/bin/jsvc -user tomcat6
-cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat6/bin/bootstrap.jar
-outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat6.pid
-Djava.awt.headless=true -Xmx128M
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6
-Djava.io.tmpdir=/tmp/tomcat6-temp -Djava.security.manager
-Djava.security.policy=/var/lib/tomcat6/work/catalina.policy
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
org.apache.catalina.startup.Bootstrap
This is how the Tomcat process looks when run from within Eclipse using the Sysdeo Tomcat launcher plugin:
(this one actually works)
jzaruba 2655 19.7 4.5 358304 46152 ? Sl 15:43 0:01
/usr/lib/jvm/java-6-sun-1.6.0.15/bin/java
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37377
-Dcatalina.home=/usr/share/tomcat6
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Djava.io.tmpdir=/var/lib/tomcat6/temp
-Dfile.encoding=UTF-8 -classpath
/usr/share/tomcat6/bin/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar
org.apache.catalina.startup.Bootstrap start
The working one (Eclipse launched) is run using java-6-sun-1.6.0.15, I'm Windows user so I don't know how to tell which JRE is used for /usr/lib/jsvc (looking at it though), but my guess would be it is some OpenJDK... Could this be the difference?
update: jsvc probably uses the same JRE Sysdeo Tomcat launcher does

Tomcat 6 freezes at startup

When I start tomcat 6 it freezes in certain point of the startup and stays there forever (I've waited 3 hours and nothing happened - not even an out of memory error). I don't have any clue of what could cause a behavior like that.
I'm runnig tomcat with Jira and Confluence, and the problem seem to be when tomcat tries to load confluence:
******************************************************************************************************
JIRA 3.13.3 build: 344 (Enterprise Edition) started. You can now access JIRA through your web browser.
******************************************************************************************************
2009-06-02 19:38:21,272 JiraQuartzScheduler_Worker-1 INFO [jira.action.admin.DataExport] Export took 387ms
2009-06-02 19:38:21,291 JiraQuartzScheduler_Worker-1 INFO [jira.action.admin.DataExport] Wrote 392 entities to export
2009-06-02 19:38:21,606 INFO [main] [com.atlassian.confluence.lifecycle] contextInitialized Starting Confluence 2.10.3 (build #1519)
2009-06-02 19:38:21,711 INFO [main] [beans.factory.xml.XmlBeanDefinitionReader] loadBeanDefinitions Loading XML bean definitions from class path resource [bootstrapContext.xml]
2009-06-02 19:38:22,236 INFO [main] [beans.factory.xml.XmlBeanDefinitionReader] loadBeanDefinitions Loading XML bean definitions from class path resource [setupContext.xml]
After this line above nothing more happens.
I thought it could be a problem with permGem or something like that, so to avoid permGem limitations, I configured catalina.sh with:
CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true"
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:PermSize=256m -XX:MaxPermSize=640m -XX:+DisableExplicitGC"
I incresed a lot jvm's space to see if it works, but it didn't help.
Tomcat version: 6.0.18
Jira version: 3.13.3
Confluence Version: 2.10.3
So, anyone have already had this problem before?
Could it be a memory(RAM) problem?
A problem with Spring and Tomcat6?
Or any other kind of problem?
Do you have any errors in your log?
Have you checked if confluence is maybe waiting for the database or network?
Get a thread dump for the application and check for threads which are BLOCKED, WAITING or TIMED_WAITING.
Also beware of threads in RUNNABLE but doing network I/O, e.g InputStream.read().
I checked my database, it was not working at all, but that was not the problem that was making my tomcat freeze.
I had a lack of RAM issue. In that place where tomcat got stuck there was a memory peak to load a lot of stuff from confluence.
I am using a virtual machine(VMware) to run my confluence, jira and svn inside a server with 3 other virtual machines.
To solve the problem I had to increase the memory(RAM) my virtual machine could use, from 2Gb to 4Gb.
please check whether $CATALINA_BASE/common/lib/javaee.jar exists

Categories

Resources