Tomcat catalina logging - java

I am using SpringMVC framework and Java 8 for development. In the Tomcat catalina.out file, the date timestamp and threadid are not added along with my application logs.
I am getting the logs as below
INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-9090"]
INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["https-jsse-nio-8443"]
INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
java.io.FileNotFoundException: /apps/opt/sws/logs
Request SecurityContextHolderAwareRequestWrapper
Beginning of the api method
I need to have the date timestamp and threadid be added along with my application
example:-
2022-01-08 12:51:23:986[Thread - http-nio-exec-4id] INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-9090"]
2022-01-08 12:52:56:986[Thread - http-nio-exec-8id] INFO Request SecurityContextHolderAwareRequestWrapper
2022-01-08 12:58:45:986[Thread - http-nio-exec-9id] INFO Beginning of the api method
2022-01-08 12:58:55:986[Thread - http-nio-exec-47id] ERROR Exception happened while loading
Please help me, where I need to change the settings and provide any samples.

You could do the followings to achieve this. Add the following line to log4j.properties.
java.util.logging.SimpleFormatter.format=%1$tF %1$tT [%4$-7s] %5$s %n
else you can also change Tomcat logging to log4j. You may refer here.

Related

Tomcat server not shutting down during first time

I am developing a Queue message proof of concept on Spring-MVC 5.x, Java 8 and Tomcat server 9.x. While reading the queue messages from the Oracle table, thread warning messages appending in the Catalina log file.
If I try to shutdown and start the tomcat server, the tomcat server is not shutting down during the first time but on the next call tomcat server is shutting down and a memory leak warning message is logged in the log file.
Please help why I am unable to shutdown the tomcat server during the first time.
Log details
INFO [main] org.apache.catalina.core.Aprlifecyclelistener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path
INFO [main] org.apache.coyote.Abstract Protocol.init Initializing ProtocolHandler ["http-nio-9090"]
INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"]
INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 912 ms
INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.53]
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/apps/opt/tomcat/webapps/Books.war]
WARNING [localhost-startStop-1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used.
INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup: time and JSP compilation time.
INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/apps/opt/tomcat/webapps/Books.war] has finished in [62,365] ms
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-9090"]
INFO [main] org.apache.coyote.AbstractProtocol.start Starting Protocollandler ["https-jsse-nio-8443"]
INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 82019 ms
INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-9090"]
INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["https-jsse-nio-8443"]
INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferences Threads The web application [Books] appears to have started a thread named [AQThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Thread.sleep(Native Method)
WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferences Threads The web application [Books] appears to have started a thread named [AQThread] but has failed to stop it. This is very likely to create a nemory leak. Stack trace of thread:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
java.net.SocketInputStream.read(SocketInputStream.java:171)
java.net.SocketInputStream.read(SocketInputStream.java:141)
oracle.net.ns.Packet.receive(Packet.java:282)
oracle.net.ns.DataPacket.receive(DataPacket.java:103)
oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:230)
oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamwWrapper.java:122)
oracle.jdbc.driver.T4CSocketInputStreamwrapper.read(T4CSocketInputStreamWrapper.java:78)
oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1179)
oracle.jdbc.driver.T4CMAREngine.unmarsha1SB1(T4CMAREngine.java:1155)
oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:279)
oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:202)
oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1005)
oracle.jdbc.driver.OracleStatement.doExecutewithTimeout(OracleStatement.java:1307)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3493)
oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
oracle.AQ.AQOracleQueue.dequeue(AQOracleQueue.java:1625)
oracle.AQ.AQOracleQueue.dequeue(AQOracleQueue.java:1326)
INFO [AQThread] org.apache.catalina.loader WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [oracle.AQ.AQOracleQueue]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [oracle.AQ.AQOracleQueue]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1435)
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1423)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1262)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1223)
Code sample
public void deQueMsg() throws AQException, SQLException {
java.sql.Connection dqConn = QueueConnection.getConnection(); // DB call
dqConn.setAutoCommit(false);
AQSession dqSess = null;
object
}
//db connection
public Connection QueueConnection(String strJdbc)
{
OracleDataSource OraDs;
OraDs = new OracleDataSource();
OraDs.setDriverType("thin");
OraDs.setServerName("test");
OraDs.setPortNumber(1521);
OraDs.setDatabaseName("booksdb");
OraDs.setUser("testusr");
OraDs.setPassword("test123");
return OraDs();
}

Configure Apache Web Server with Tomcat and trying to Deploy war file

I am not getting my project on my domain name. It gives me Apache Test Page instead of my project which i have added in webapps.
I have my war file FINAL_WE.war in /opt/code/apache-tomcat-8.5.54/webapps/
And I have started my tomcat server. using sh startup.sh from /bin/ folder.
Log gives me tail -f catalina.out
20-Apr-2020 04:06:13.733 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
20-Apr-2020 04:06:13.837 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
20-Apr-2020 04:06:13.879 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Apr-2020 04:06:13.909 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1307 ms
20-Apr-2020 04:06:14.001 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
20-Apr-2020 04:06:14.004 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.54
20-Apr-2020 04:06:14.038 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/opt/code/apache-tomcat-8.5.54/webapps/FINAL_WE.war]
20-Apr-2020 04:06:14.602 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/code/apache-tomcat-8.5.54/webapps/FINAL_WE.war] has finished in [564] ms
20-Apr-2020 04:06:14.609 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
20-Apr-2020 04:06:14.623 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 714 ms
I have executed the following commands
1. cd /usr/local/apache/modules
2. cd /usr/local/apache/conf
3. vim workers.properties
worker.list=we-matter
worker.we-matter.type=ajp13
worker.we-matter.port=8009
worker.we-matter.host=192.169.217.121
4. Apache Web Server file:
vim /usr/local/apache/conf/httpd.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /usr/local/apache/conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel emerg
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T %p %q %r %v %U"
<VirtualHost *:80>
ServerName www.we-matter.com
RewriteEngine on
RewriteRule ^/(.*)$ /we-matter/$1 [L,PT]
JkMount /* we-matter
</VirtualHost>
6. service httpd stop
service httpd start
You're creating a named virtual host in Apache httpd.
<VirtualHost *:80>
ServerName www.upyourcode.com
RewriteEngine on
RewriteRule ^/(.*)$ /upyourcode/$1 [L,PT]
JkMount /* upyourcode
</VirtualHost>
This will cover every request coming in with the Host header to www.upyourcode.com. Any other host name will fall back to the default virtual host, which likely does not have your JkMount configuration, but is rather configured to the default content, e.g. httpd's "Success" page, rather than your own content.
You'll need to either configure the default virtual host, add a ServerAlias to the virtual host you mention in this question, or add yet another virtual host with the ServerName that you're expecting to see your content on.

OSX El Cap, Apache2, Tomcat 8, Lucee 5

I have posted in the Lucee google group, but after four days, i'm just not getting the support I need. I have a feeling a Tomcat expert will be able to point me in the right direction fairly quickly, so I'm posting here.
OSX El Cap, Apache2, Tomcat 8, Lucee 5.
On http://localhost, i get the Apache "It Works!" page.
on http://localhost:8080, i get the default Lucee page, served from
/usr/local/Cellar/tomcat/8.5.3/libexec/apps/lucee
On http://localhost:8080/manager/html and http://localhost:8080/host-manager/html, I get the Tomcat admin pages.
I have a directory, /Volumes/Storage/{companyname}/sites/www-test-app/www that contains index.cfm and index.htm
I have www-test-app set up in my HOSTS file.
I have a host entry in httpd-vhosts.conf for www-test-app
I have an entry in tomcat's server.xml file:
<Host name="www-test-app" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/Volumes/Storage/{companyname}/sites/_test-app/www/">
<JarScanner scanClassPath="false"/>
</Context>
</Host>
When i call up http://www-test-app/index.htm, I get my static test page.
When I call up http://www-test-app/index.cfm I get this error:
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
Apache Tomcat/8.5.3
I have stopped and restarted apache and tomcat to make sure config files are read.
THE BIGGEST CLUE:
I do not see WEB-INF being created under
/Volumes/Storage/{companyname}/sites/www-test-app/www
My directory permissions are 777 for this directory and all subdirectories:
/Volumes/Storage/{companyname}/sites
I'm not sure if I need to make ownership changes though.
Apache2 was included with El Cap. Apache testconfig yields "syntax OK".
Tomcat was installed via Homebrew.
Lucee was installed via WAR file per this page:
http://brianflove.com/2015/03/05/lucee-on-mac-os-x-yosemite-quick-start/
I am stuck from here... but oh so close, since the default Lucee page looks great, including any cfoutput/variables.
Here's is a sample from catalina.{date}.log:
13-Jul-2016 12:06:02.381 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.3
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 9 2016 11:16:29 UTC
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.3.0
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Mac OS X
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.11.5
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86_64
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_65-b17
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/Cellar/tomcat/8.5.3/libexec
13-Jul-2016 12:06:02.383 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/Cellar/tomcat/8.5.3/libexec
13-Jul-2016 12:06:02.384 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/Cellar/tomcat/8.5.3/libexec/conf/logging.properties
13-Jul-2016 12:06:02.384 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
13-Jul-2016 12:06:02.384 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
13-Jul-2016 12:06:02.384 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/Cellar/tomcat/8.5.3/libexec
13-Jul-2016 12:06:02.385 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/Cellar/tomcat/8.5.3/libexec
13-Jul-2016 12:06:02.385 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/Cellar/tomcat/8.5.3/libexec/temp
13-Jul-2016 12:06:02.385 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/marc/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
13-Jul-2016 12:06:02.578 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
13-Jul-2016 12:06:02.619 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
13-Jul-2016 12:06:02.623 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
13-Jul-2016 12:06:02.624 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
13-Jul-2016 12:06:02.625 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 702 ms
13-Jul-2016 12:06:02.654 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
13-Jul-2016 12:06:02.655 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.3
13-Jul-2016 12:06:02.665 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor /usr/local/Cellar/tomcat/8.5.3/libexec/conf/Catalina/localhost/ROOT.xml
13-Jul-2016 12:06:03.183 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
13-Jul-2016 12:06:08.815 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor /usr/local/Cellar/tomcat/8.5.3/libexec/conf/Catalina/localhost/ROOT.xml has finished in 6,149 ms
13-Jul-2016 12:06:08.816 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/docs
13-Jul-2016 12:06:08.837 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/docs has finished in 21 ms
13-Jul-2016 12:06:08.837 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/examples
13-Jul-2016 12:06:09.079 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/examples has finished in 241 ms
13-Jul-2016 12:06:09.079 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/host-manager
13-Jul-2016 12:06:09.104 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/host-manager has finished in 25 ms
13-Jul-2016 12:06:09.104 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/manager
13-Jul-2016 12:06:09.123 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/Cellar/tomcat/8.5.3/libexec/webapps/manager has finished in 19 ms
13-Jul-2016 12:06:09.157 INFO [www-test-app-startStop-1] org.apache.catalina.core.ApplicationContext.log Marking servlet CFMLServlet as unavailable
13-Jul-2016 12:06:09.157 SEVERE [www-test-app-startStop-1] org.apache.catalina.core.StandardContext.loadOnStartup Servlet [CFMLServlet] in web application [] threw load() exception
java.lang.ClassNotFoundException: lucee.loader.servlet.CFMLServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1282)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1116)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1061)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1000)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4902)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5212)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1405)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1395)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Can't find the disconnect... where do i go from here?
RESOLVED {sigh}
Well, I’m totally ready to kick my own a$$. The solution was way more simple than I thought.
My (mis)understanding was that configuring the Lucee EXPRESS to use the local Apache install on the mac just wasn’t going to work – that I had to use the tomcat built-in web server. The tomcat web server, because it’s based on Java, is in fact case-sensitive when it comes to filenames in the URL – “Foo.jpg” is NOT the same as “foo.jpg” in the eyes of the ‘cat. This is why I had given up on Lucee Express.
I do recall trying to get local Apache to work with Lucee Express, but since so much time has passed since that attempt, I couldn’t begin to tell you what I was doing wrong. I just know I couldn’t get it to work – probably mucking with config files that I actually didn’t need to.
Anyway, the solution is simple as all heck… download Lucee Express. Then just configure virtual hosts in apache as one normally would, as Apache needs to be told to proxy any coldfusion requests to tomcat/lucee… like so:
<Directory "/Volumes/Storage/company/sites/_test-app/www">
Allow From All
AllowOverride All
Options +Indexes
Require all granted
DirectoryIndex index.cfm
</Directory>
<VirtualHost *:80>
ServerName "www-test-app"
ServerAlias "www-test-app.*.*.*.*.xip.io"
DocumentRoot "/Volumes/Storage/company/sites/_test-app/www"
<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
</VirtualHost>
Then on the other side, add a similar entry for the Tomcat server.xml file:
<Host name="www-test-app" appBase="webapps" autoDeploy="true" unpackWARs="true">
<Context path="" docBase="/Volumes/Storage/company/sites/_test-app/www">
<JarScanner scanClassPath="false"/>
</Context>
</Host>
Then (damn it!!!) just start Apache and start Tomcat/Lucee. That’s it. Tomcat will create the WEB-INF files in each virtual host specified. The tomcat web server is still running on port 8888, and the ajp connector is still running on 8009.
http://www-test-app gives the result via Apache (case-insensitive urls).
Since Apache has root permission to listen on port 80, it does so… and passes CF requests on to port 8009.
BONUS: One can still test via the Tomcat web server…
http://www-test-app:8888 gives the result via Tomcat web server.
If one wanted to bypass/refrain from Apache and use the Tomcat web server, completely self-contained, BUT not have to add “:8888” to all their urls, homebrew for mac can install “haproxy” which, when run as root and configured using a simple config file, can receive requests on port 80 and forward them to port 8888.
For any NEW sites where the desire is to make sure file names are properly specified in code (case sensitivity-wise), this would be my ultimate solution. For legacy apps that were originally run on a case-insensitive stack, the use of the local Apache web server is the way to go.

IntelliJ IDEA 13.0.3 and Tomcat 8.0.9. Cant get it to work

I'm trying to deploy a Java web application running on Tomcat. I got the book
Professional Java for Web Applications: Featuring Websockets, Spring Framework, JPA Hibernate, and Spring Security
and I've done everything said to get IntelliJ IDEA 13 work together with Tomcat 8.0.9. I've tested the server container manually and it works great, even deploying .war files works great. However when i move on to start/debug a web application - in this case the first example form the book - from IntelliJ the application wont start. The output in the Tomcat Log doesn't say much.
Server output tells me this:
Connected to server
[2014-08-08 09:17:35,075] Artifact Sample-Debug-IntelliJ:war exploded: Artifact is being deployed, please wait...
[2014-08-08 09:17:35,097] Artifact Sample-Debug-IntelliJ:war exploded: Error during artifact deployment. See server log for details.
[2014-08-08 09:17:35,098] Artifact Sample-Debug-IntelliJ:war exploded: com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionException: L:\java-dev\java_web_apps_chapter_code\9781118656464 Full Code\Chapter 02\Sample-Debug- IntelliJ\target\sample-debug-intellij-1.0.0.SNAPSHOT not found for the web module.
08-Aug-2014 21:17:44.671 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager
08-Aug-2014 21:17:44.939 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager has finished in 268 ms
Tomcat Catalina Log output this:
08-Aug-2014 22:56:35.843 INFO [main] org.apache.catalina.core.AprLifecycleListener.init Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8.
08-Aug-2014 22:56:35.846 INFO [main] org.apache.catalina.core.AprLifecycleListener.init APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
08-Aug-2014 22:56:36.652 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
08-Aug-2014 22:56:36.738 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
08-Aug-2014 22:56:36.746 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
08-Aug-2014 22:56:36.747 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1060 ms
08-Aug-2014 22:56:36.771 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
08-Aug-2014 22:56:36.771 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.9
08-Aug-2014 22:56:36.778 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
08-Aug-2014 22:56:36.784 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
08-Aug-2014 22:56:36.785 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 38 ms
08-Aug-2014 22:56:46.785 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager
08-Aug-2014 22:56:47.035 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager has finished in 251 ms
I've tried on both Windows and OSX and it's the same story on both with the exact same error.
When i access http://localhost:8080/i can see that the server is up and running. However, the application isn't deployed.
Anyone experiencing the same error as me and/or know a solution?
I'm running IntelliJ IDEA 13.0.3, Java 1.8.0_11 and Tomcat 8.0.9.
EDIT: I've also tried with IntelliJ IDEA 13.1.4. Didn't make any difference.
Steps taken
Downloaded Java 1.8.0_11, installed it and added it to environment variables.
Downloaded Tomcat, unpacked it and made the following changes to it (step 2-4);
In conf/tomcat-users.xml i added this user:
<user username="admin" password="admin" roles="manager-gui,admin-gui" />
In conf/web.xml i added the code below beneath the org.apache.jasper.servlet.jspServlet element
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compiler</param-name>
<param-value>modern</param-value>
</init-param>
Downloaded apache-ant and added a setenv.bat file in the apache-tomcat/bin directory with the following script
export CLASSPATH=L:/java-dev/jdk8/lib/tools.jar:L:/java-dev/apache-ant/lib/ant.jar:L:/java-dev/apache-ant/lib/ant-launcher.jar
Started IntelliJ and added the Tomcat application server.
Then i imported the project and set it to use the Tomcat server that I just added.
UPDATE: 2014-08-09 16:22
I tried to deploy a JavaEE web application that IntelliJ created itself, and that worked right away. Seems like it's something wrong with the source code that the book references.
I had similar problem. The problem was in artifact configuration in Run/Debug Configurations. I had to remove the project artifact and readd it. The important thing is to choose Web Application: Exploded, From Modules...
You can read my blog post that contains screenshots about this issue.
For me it worked with:
File >Project Structure >Artifacts
In the
Output Layout on the right side >"Available Elements?"
right click on the available libraries ( for me it was "Spring MVC-4.2.4.RELEASE")
Put into Lib ( actually click on the fix warning button )
And it worked.
Open "Debug Configuration" in IntelliJ IDEA and make sure that "Deploy applications configured in Tomcat" checkbox is checked as it shown on the screenshot
open the artifact config dialog (artifact > edit...)
check 'Show contents of elements' in the dialogs bottom section
highlight the 'WEB-INF' directory
right click on the library container (on the right pane)
select from context menu 'put into /WEB-INF/lib'
the lib folder is added in the output layout
rebuild artifact
restart webserver
Hope it helps.

Java web-app debugging not possible due to direct undeploy on debug

When i try to debug my webapp it starts up the tomcat server and the application, but shuts down the debugger shortly before the app gets usable. I see the debugging toolbar for a second before it vanishes again, though the app keeps running.
Tomcat-log:
Listening for transport dt_socket at address: 11555
23.03.2010 01:24:35 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: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
23.03.2010 01:24:35 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8084
23.03.2010 01:24:35 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 847 ms
23.03.2010 01:24:35 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
23.03.2010 01:24:35 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
23.03.2010 01:24:41 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8084
23.03.2010 01:24:41 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
23.03.2010 01:24:41 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/78 config=null
23.03.2010 01:24:41 org.apache.catalina.startup.Catalina start
INFO: Server startup in 5855 ms
23.03.2010 01:24:42 org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context []
23.03.2010 01:24:45 org.apache.catalina.core.StandardContext start
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/] has already been started
Debugging log:
Attached JPDA debugger to localhost:11555
Checking data source definitions for missing JDBC drivers...
Deploying JDBC driver to /Applications/NetBeans/apache-tomcat-6.0.20/lib/mysql-connector-java-5.1.6-bin.jar
Stopping Tomcat process...
Waiting for Tomcat...
Tomcat server stopped.
Starting Tomcat process...
Waiting for Tomcat...
Tomcat server started.
Undeploying ...
OK - Undeployed application at context path /
In-place deployment at /path/to/project/dir/build/web
deploy?config=file%3A%2Fvar%2Ffolders%2FZP%2FZPbqxGrbHFaUlXzAfgWV1%2B%2B%2B%2BTQ%2F-Tmp-%2Fcontext734173871283203218.xml&path=/
OK - Deployed application at context path /
start?path=/
Start is in progress...
OK - Started application at context path /
debug-display-browser:
Browsing: http://localhost:8084/
connect-client-debugger:
BUILD SUCCESSFUL (total time: 18 seconds)
System is Netbeans 6.8 on MacOS 10.6.2.
You should see if the TC server is still in debug mode. The easiest way to do that is to Debug->Attach Debugger to localhost;11555. If it is still running 'debuggable', you will be able to do a fair bit of debugging that way.
I had similar problem where debugging started but kind of stopped immediately. The application was deployed however. I was not even able to attach to debugger manually, even if the Tomcat was running in debug mode. By creating a simple debuggable hello world project and starting debugging it also made debugger to break to my "problem project"'s break points as well.. But this was not really way to work.
My problem was "solved" by dropping mysql-connector-java.jar from my web project. I don't see any reasoning, but it simply works now. FYI also, the Netbean's Tomcat config's property "Enable JDBC driver deployment" did not have effect.
My environment was Netbeans 6.9.1 and project type was maven2, run on on Win7.

Categories