Tomcat
Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.
Installation on Slackware
Start Tomcat
Add admin user
1 cd /opt/apache-tomcat-7.0.57/conf
Edit tomcat-users.xml
<role rolename="admin"/> <role rolename="manager"/> <role rolename="manager-gui"/> <user username="admin" password="12345678" roles="admin,manager,manager-gui"/>
WebApps location
- /opt/apache-tomcat-7.0.57/webapps
A WAR file can be copied or exploded in the webapps folder.
Sample App
Download http://localhost:8080/docs/appdev/sample/sample.war and deploy in the webapps folder. After the deploy the WAR file is exploded.
Configuration values in web.xml for WAR file
Adapted from http://stackoverflow.com/questions/372686/how-can-i-specify-system-properties-in-tomcat-configuration-on-startup
Get values in code:
Change HTTP from port 8080 to port 8081 and AJP from 8009 to 8010
Edit file conf/server.xml
Change the HTTP Connector from 8080 to 8081. Change AJP1.3 connector from 8009 to 8010.
Copy JBoss5 client libs to Tomcat
1 cd /opt/jboss-5.1.0.GA/client
2 cp commons-logging.jar /opt/apache-tomcat-7.0.53/lib
3 cp concurrent.jar /opt/apache-tomcat-7.0.53/lib
4 cp ejb3-persistence.jar hibernate-annotations.jar /opt/apache-tomcat-7.0.53/lib
5 cp jboss-aop-client.jar /opt/apache-tomcat-7.0.53/lib
6 cp jboss-appclient.jar /opt/apache-tomcat-7.0.53/lib
7 cp jboss-aspect-jdk50-client.jar /opt/apache-tomcat-7.0.53/lib
8 cp jboss-client.jar /opt/apache-tomcat-7.0.53/lib
9 cp jboss-common-core.jar /opt/apache-tomcat-7.0.53/lib
10 cp jboss-deployers-client-spi.jar /opt/apache-tomcat-7.0.53/lib
11 cp jboss-deployers-client.jar /opt/apache-tomcat-7.0.53/lib
12 cp jboss-deployers-core-spi.jar /opt/apache-tomcat-7.0.53/lib
13 cp jboss-deployers-core.jar /opt/apache-tomcat-7.0.53/lib
14 cp jboss-deployment.jar /opt/apache-tomcat-7.0.53/lib
15 cp jboss-ejb3-common-client.jar /opt/apache-tomcat-7.0.53/lib
16 cp jboss-ejb3-core-client.jar /opt/apache-tomcat-7.0.53/lib
17 cp jboss-ejb3-ext-api.jar /opt/apache-tomcat-7.0.53/lib
18 cp jboss-ejb3-proxy-clustered-client.jar /opt/apache-tomcat-7.0.53/lib
19 cp jboss-ejb3-proxy-impl-client.jar /opt/apache-tomcat-7.0.53/lib
20 cp jboss-ejb3-proxy-spi-client.jar /opt/apache-tomcat-7.0.53/lib
21 cp jboss-ejb3-security-client.jar /opt/apache-tomcat-7.0.53/lib
22 cp jboss-ha-client.jar /opt/apache-tomcat-7.0.53/lib
23 cp jboss-ha-legacy-client.jar /opt/apache-tomcat-7.0.53/lib
24 cp jboss-iiop-client.jar /opt/apache-tomcat-7.0.53/lib
25 cp jboss-integration.jar /opt/apache-tomcat-7.0.53/lib
26 cp jboss-j2se.jar /opt/apache-tomcat-7.0.53/lib
27 cp jboss-javaee.jar /opt/apache-tomcat-7.0.53/lib
28 cp jboss-jsr77-client.jar /opt/apache-tomcat-7.0.53/lib
29 cp jboss-logging-jdk.jar /opt/apache-tomcat-7.0.53/lib
30 cp jboss-logging-log4j.jar /opt/apache-tomcat-7.0.53/lib
31 cp jboss-logging-spi.jar /opt/apache-tomcat-7.0.53/lib
32 cp jboss-main-client.jar /opt/apache-tomcat-7.0.53/lib
33 cp jboss-mdr.jar /opt/apache-tomcat-7.0.53/lib
34 cp jboss-messaging-client.jar /opt/apache-tomcat-7.0.53/lib
35 cp jboss-remoting.jar /opt/apache-tomcat-7.0.53/lib
36 cp jboss-security-spi.jar /opt/apache-tomcat-7.0.53/lib
37 cp jboss-serialization.jar /opt/apache-tomcat-7.0.53/lib
38 cp jboss-srp-client.jar /opt/apache-tomcat-7.0.53/lib
39 cp jboss-system-client.jar /opt/apache-tomcat-7.0.53/lib
40 cp jboss-system-jmx-client.jar /opt/apache-tomcat-7.0.53/lib
41 cp jbosscx-client.jar /opt/apache-tomcat-7.0.53/lib
42 cp jbossjts-integration.jar /opt/apache-tomcat-7.0.53/lib
43 cp jbossjts.jar /opt/apache-tomcat-7.0.53/lib
44 cp jbosssx-as-client.jar /opt/apache-tomcat-7.0.53/lib
45 cp jbosssx-client.jar /opt/apache-tomcat-7.0.53/lib
46 cp jmx-client.jar /opt/apache-tomcat-7.0.53/lib
47 cp jmx-invoker-adaptor-client.jar /opt/apache-tomcat-7.0.53/lib
48 cp jnp-client.jar /opt/apache-tomcat-7.0.53/lib
49 cp slf4j-api.jar /opt/apache-tomcat-7.0.53/lib
50 cp slf4j-jboss-logging.jar /opt/apache-tomcat-7.0.53/lib
51 cp xmlsec.jar /opt/apache-tomcat-7.0.53/lib
Windows client copy
cd C:\appsvr\jboss-5.1.0.GA\client copy commons-logging.jar C:\appsvr\apache-tomcat-7.0.29\lib copy concurrent.jar C:\appsvr\apache-tomcat-7.0.29\lib copy ejb3-persistence.jar hibernate-annotations.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-aop-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-appclient.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-aspect-jdk50-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-common-core.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-deployers-client-spi.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-deployers-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-deployers-core-spi.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-deployers-core.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-deployment.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-common-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-core-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-ext-api.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-proxy-clustered-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-proxy-impl-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-proxy-spi-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ejb3-security-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ha-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-ha-legacy-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-iiop-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-integration.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-j2se.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-javaee.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-jsr77-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-logging-jdk.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-logging-log4j.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-logging-spi.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-main-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-mdr.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-messaging-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-remoting.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-security-spi.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-serialization.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-srp-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-system-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jboss-system-jmx-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jbosscx-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jbossjts-integration.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jbossjts.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jbosssx-as-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jbosssx-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jmx-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jmx-invoker-adaptor-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy jnp-client.jar C:\appsvr\apache-tomcat-7.0.29\lib copy slf4j-api.jar C:\appsvr\apache-tomcat-7.0.29\lib copy slf4j-jboss-logging.jar C:\appsvr\apache-tomcat-7.0.29\lib copy xmlsec.jar C:\appsvr\apache-tomcat-7.0.29\lib
Windows remote debug
https://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging comment
C:\tomcat\bin> tomcat5w //ES//Tomcat5 -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Listens on port 5050:
Cmd as admin <...>\apache-tomcat-7.0.29\bin>Tomcat7w.exe //ES//Tomcat7 Java tab Java options: -Xdebug -Xrunjdwp:transport=dt_socket,address=5050,server=y,suspend=n
Tomcat 7 - bin\catalina.bat
Starting with
- set JPDA_SUSPEND=y
- catalinat.bat jpda start
- Remote debug app with eclipse on port 8000. When attached the tomcat server will boot
Linux remote debug
Logging custom logger
Create logger
Configure the logging properties in <Tomcat>/conf/logging.properties
handlers = (...),<digitToHandler><LoggerName>.org.apache.juli.FileHandler handlers = (...),5TestLogger.org.apache.juli.FileHandler 5TestLogger.org.apache.juli.FileHandler.level = FINE 5TestLogger.org.apache.juli.FileHandler.directory = ${catalina.base}/logs 5TestLogger.org.apache.juli.FileHandler.prefix = TestLogger. # configure logger level and handler TestLogger.handlers=5TestLogger.org.apache.juli.FileHandler TestLogger.level=INFO
When no custom handler is defined the Logger outputs to console and to catalina.out in Tomcat 7.0.X. The root logger defines its set of handlers using .handlers.
# default handlers in tomcat 7.X, .handlers sets the handlers for the root logger .handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
The file logging properties file is set with the system property java.util.logging.config.file (-Djava.util.logging.config.file).