I have a maven application running on tomcat, I start it using cargo:
mvn cargo:run
Inside the webapps folder, there is a symlink that points to an important folder:
ls /usr/local/Cellar/tomcat/8.0.15/libexec/webapps/ROOT/WEB-INF/views
admin 898 Jul 21 2016 notImplemented.jsp
admin 3355 Oct 3 15:13 genericError.jsp
admin 41 Mar 21 18:43 vhosts -> /Users/me/Project/important/folder <<<<<< HERE
The problem is that when I start the server, tomcat follow the symlink and delete everything contained in the folder.
When I start tomcat via intellij, there is no issue. I noticed from the logs that the deletion is occurring at line 4 (Trying to delete WAR from /ROOT):
1 [INFO] [stalledLocalDeployer] Undeploying context [] from [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps]...
2 [INFO] [stalledLocalDeployer] The WAR file has its context set to / and will therefore be deployed as ROOT.war
3 [INFO] [stalledLocalDeployer] Trying to delete WAR from [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps/ROOT.war]...
4 [INFO] [stalledLocalDeployer] Trying to delete WAR from [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps/ROOT]...
5 [INFO] [stalledLocalDeployer] Deploying [/Users/.....war] to [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps]...
6 [INFO] [stalledLocalDeployer] The WAR file has its context set to / and will therefore be deployed as ROOT.war
I am running tomcat 8.0.15 on OSX 10.11.3 and use cargo-maven2-plugin v1.6.1.
Could you please suggest a solution to prevent symlinks content to be deleted when tomcat is starting ?
Thanks
Solution
At the end, I am deleting all the symlinks contained inside tomcat working directory before starting tomcat. It fixes the problem.
find ${TOMCAT_HOME}/webapps -type l -delete
Related
Help please. In our workflow we only work with pre-packaged offline deploys where we do not have root access and therefore use supervisord to stop start ALL packages. We deploy all our packages under a user account. I have created a custom Jenkins package. Its basically its a folder containing the Jenkins war file and configurations from when I tool a vanilla initial setup.
My installation has worked up until now. Seems trying to get things running for the first time seems flaky. Once running Jenkins is fine. This time I am trying to deploy the packages (they have not changed) however I cannot start Jenkins and get and error:
jenkins.model.InvalidBuildsDir: does not contain ${ITEM_FULL_NAME} or ${ITEM_ROOTDIR}, cannot distinguish between projects
So what I did was get a clean fresh install running and packaged it up. Basically I untar the jenkins directory then use supervisord to control start/stop.
Supervisord config:
[program:jenkins]
autorestart = true
autostart = true
command = /bin/bash -c "set JENKINS_HOME=/opt/home/svc_user/opskit/jenkins; /opt/home/svc_user/opskit/jdk/bin/java -Djava.awt.headless=true -Djenkins.model.Jenkins.buildsDir=/opt/home/svc_user/data/jenkins/builds/${ITEM_FULL_NAME} -Djenkins.model.Jenkins.workspacesDir=/opt/home/svc_user/data/jenkins/workspace/${ITEM_FULL_NAME} -jar /opt/home/svc_user/opskit/jenkins/bin/jenkins.war -path=/opt/home/svc_user/opskit/jenkins"
directory = /opt/home/svc_user/opskit/jenkins
redirect_stderr = true
stdout_logfile = /opt/home/svc_user/opskit/log/jenkins.log
stdout_logfile_backups = 5
stdout_logfile_maxbytes = 10MB
stopwaitsecs = 300
Full error:
jenkins.model.InvalidBuildsDir: /opt/home/svc_user/data/jenkins/builds does not contain ${ITEM_FULL_NAME} or ${ITEM_ROOTDIR}, cannot distinguish between projects
at jenkins.model.Jenkins.checkRawBuildsDir(Jenkins.java:3179)
at jenkins.model.Jenkins.setBuildsAndWorkspacesDir(Jenkins.java:3135)
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3123)
Caused: java.io.IOException
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3125)
at jenkins.model.Jenkins.access$1200(Jenkins.java:320)
at jenkins.model.Jenkins$13.run(Jenkins.java:3219)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1133)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
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)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:50)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1166)
at jenkins.model.Jenkins.<init>(Jenkins.java:966)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:250)
Jenkins config.xml:
<workspaceDir>/opt/home/svc_user/data/jenkins/workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>/opt/home/svc_user/data/jenkins/builds/${ITEM_FULL_NAME}</buildsDir>
Folder permissions (install dir):
lrwxrwxrwx 1 svc_user svc_user 39 Jun 4 02:51 jenkins -> /opt/home/svc_user/opskit/jenkins-2.222.3
drwxr-xr-x 13 svc_user svc_user 4096 May 1 05:07 jenkins-2.222.3
Folder permissions (custom dir for builds and workspaces):
lrwxrwxrwx 1 svc_user svc_user 37 Jun 4 02:51 jenkins -> /opt/home/svc_user/data/jenkins-2.222.3
drwxr-xr-x 4 svc_user svc_user 37 Jun 4 16:39 jenkins-2.222.3
|-nginx-1.16.1
|-jdk-8u91
|-jenkins-2.222.3
| |-builds
| |-workspace
Help would be greatly appreciated. Thank you in advance.
Modified this:
command = /bin/bash -c "JENKINS_HOME=/opt/home/svc_user/opskit/jenkins /opt/home/svc_user/opskit/jdk/bin/java...
^^
Nothing to do with the fix, just launches 1 java process instead of 2.
Deleted:
-Djenkins.model.Jenkins.buildsDir=/opt/home/svc_user/data/jenkins/builds/${ITEM_FULL_NAME}
-Djenkins.model.Jenkins.workspacesDir=/opt/home/svc_user/data/jenkins/workspace/${ITEM_FULL_NAME}
^^
Fixed my startup issue. Not sure why these had no negative effects on previous installations.
Also deleted:
path=/opt/home/svc_user/opskit/jenkins
Seemed isnt necessary.
¯_(ツ)_/¯
I am deploying an executable jar file but keep getting the app staging buildpack error. I see my JavaMain is coming back as nil when I have a java_main.yml file saved in my config/ folder.
---
java_main_class:com.rft.rfda.gaia.Launcher
arguments:201610 2016 10 1 2500
Example output:
2017-05-12T16:55:51.11-0400 [STG/0] ERR [ConfigurationUtils] DEBUG Configuration from /var/vcap/data/deanext/adminbuildpacks/4dc31dfa-b83a-4f54-a7c5-123bf8b43ec373d57decf22d07d3d78e63a5797feb6c7ad97083/config/javamain.yml: {"javamainclass"=>nil, "arguments"=>nil}
I am pushing my application as below:
cf push gaia-bbrm-poc -p ./ -c "/bin/java -cp ./target/GAIAPOC-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.rft.rfda.gaia.Launcher" -b java_buildpack --no-route
Any input would be appreciated?
I am fairly new to IntelliJ. I am trying to deploy a simple application(Spring) with a minimal configuration classes from a book and a single home controller.
The problem is that it blocks here:
INFO: Server startup in 90 ms
Connected to server
[2015-03-10 01:26:17,221] Artifact Projefic:war exploded: Artifact is being deployed, please wait...
[2015-03-10 01:26:18,312] Artifact Projefic:war exploded: Artifact is deployed successfully
[2015-03-10 01:26:18,313] Artifact Projefic:war exploded: Deploy took 1,092 milliseconds
Mar 10, 2015 2:26:27 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory E:\Work\Tools\apache-tomcat-7.0.47-projefic\webapps\manager
And there is no error and I can't make it to work. I tried to delete the manager folder from webapps but it's not working either.
These are my configurations:
I can provide the code from the classes but the problem shouldn't be from there..
I added a jar file mysql-connector-java-5.1.34-bin.jar to my $CATALINA_HOME/lib/ folder so I could use this library for connection pooling for mysql.
I running a dedicated server with Centos 6.6 X64 with Cpanel.
I installed jdk8 in /opt/jdk1.8.0_25 and installed tomcat 8 by untarring the download in the /home/username/ folder. I followed this tutorial:
http://tecadmin.net/install-tomcat-8-on-centos-rhel-and-ubuntu/
A simple "Hello World" servlet is running by deploying a .war file in the public_html folder
However now when I start up Tomcat (8.0.15) in the catalina.out file I see the error:
09-Dec-2014 17:45:49.152 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.15
09-Dec-2014 17:45:49.182 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /home/username/public_html/J.war
09-Dec-2014 17:45:49.592 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.
09-Dec-2014 17:46:04.623 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [14,997] milliseconds.
09-Dec-2014 17:46:04.657 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /home/username/public_html/J.war has finished in 15,474 ms
And the connection pooling doesn't work. At my previous server the hosting company had setup tomcat with Cpanel and this worked just fine. I did not change the servlets so that cannot be the problem either.
My environment variables are:
CATALINA_HOME=/home/username/apache-tomcat-8.0.15
JRE_HOME=/opt/jdk1.8.0_25/jre
JAVA_PATH=/opt/jdk1.8.0_25/jre
PATH=/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr
/bin:/opt/jdk1.8.0_25/jre/bin:/opt/jdk1.8.0_25/bin:/usr/local/bin:/usr/X11R6/bin
:/root/bin:/opt/jdk1.8.0_25/bin
JAVA_HOME=/opt/jdk1.8.0_25
CLASSPATH=.:/usr/local/jdk/lib/classes.zip
The last CLASSPATH I do not understand because there is no file classes.zip on the server.
I also tried adding the jar file directly in the WEB-INF/lib folder of the deployed war file but this also did not work (the error in catalina.out was gone though).
Can somebody explain what I'm doing wrong with adding the library?
Thanks
With reference to tomcat and extracted files
I have configured server.xml to auto deploy : true.
My war file name is ROOT.war as I do not want /subdir after the site.com.
But I dont see the .css .js .java or .class files in /webappts/ROOT or any where. (I have them in the ROOT.war and the site is running fine with reflecting them)
I only see .class and .java in
/var/cache/tomcat7/Catalina/localhost/_/org/apache/jsp/
/var/cache/tomcat7/Catalina/localhost/_/WEB-INF/classes/
how to configure tomcat to explode the .war file?
Update I
I have Host name="localhost" appBase="/home/ubuntu/www" unpackWARs="true" autoDeploy="true"
and I still dont see unpacking . My ROOT.war is in /home/ubuntu/www
Update II
One problem I see is that:
Feb 27, 2013 6:29:02 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /home/ubuntu/www/ROOT.war
Feb 27, 2013 6:29:02 PM org.apache.catalina.startup.ContextConfig init
SEVERE: Exception fixing docBase for context []
java.io.IOException: Unable to create the directory [/home/ubuntu/www/ROOT]
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:100)
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:720)
at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:843)
If i manually make ROOT in /home/ubuntu/www/ with chmod 777 . it gives 404 error (doesnt exists)
Your /home/ubuntu/www folder needs to be writable by Tomcat process. The owner and group should be tomcat6/tomcat7 (depending on which TC you use). Like this:
drwxrwxr-x 4 tomcat7 tomcat7 4096 Feb 27 14:08 webapps
You shouldn't chmod 777 the folder, this is a security risk as you correctly surmised. chown tomcat7:tomcat7 should work.
You need to ensure that unpackWARs==true is set.
Set to true if you want web applications that are placed in the
appBase directory as web application archive (WAR) files to be
unpacked into a corresponding disk directory structure, false to run
such web applications directly from a WAR file. WAR files located
outside of the Host's appBase will not be expanded.
Source: http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Standard_Implementation