tomcat published two projects under path "webapps/" - shell

I modified the file conf/server.xml like this below
<Context path="AA" docBase="BB" reloadable="true" />
when I start tomcat from a shell file publish.sh:
#!/bin/bash
#defined
TOMCAT_HOME="/root/software/apache-tomcat-7.0.29"
#start tomcat
cd "$TOMCAT_HOME"/bin
sh startup.sh
echo "tomcat is starting,please try to access $PROJECT console url"
tomcat publish two projects under path "webapps/",AA and BB。And I tracked that BB was published after AA.
If you logged on the terminal , and start tomcat directly in the directory "$TOMCAT_HOME"/bin with command:
>./startup.sh
Only one project "BB" under path "webapps/"。
Who can tell me Why? Thanks!

You have double-deployed your web application.
How? Well, you put BB.war into webapps/ (which will be auto-deployed to /BB) and then you put <Context path="AA" docbase="BB"> into server.xml which deployed BB.war to /AA. What did you expect?
If you just want your application to be deployed to /AA, then just re-name the WAR file to AA.war and be done with it: take-out the <Context> in server.xml because it's just making your job harder. This is why it's explicitly recommended not to do that.

Related

Copying a Java Dynamic Web Project and renaming it to new one causes the error in Tomcat

In eclipse whenever we copying a java dynamic web project into new one by renaming it and trying to run the new copied project in tomcat server it causes below error:
"Could not publish server configuration for Tomcat v9.0 Server at localhost.
Multiple Contexts have a path of "/CopiedParentDynamicProjectName".
Anyone have idea how to overcome this tomcat error after copying the dynamicwebproject while running it server.
Step 1) Open Servers folder and click on server.xml file.
Step 2) Scroll all the way down to find following code
<Context docBase="spring-security-demo-01-base-app" path="/spring-security-demo" reloadable="true" source="org.eclipse.jst.jee.server:spring-security-demo-01-base-app"/>
<Context docBase="spring-security-demo-01-base-app" path="/spring-security-demo" reloadable="true" source="org.eclipse.jst.jee.server:spring-security-demo-01-base-app"/>
Step 3) See the duplicate entry and delete one.
Step 4) Change the path so that we have following code.
<Context docBase="spring-security-demo-01-base-app" path="/spring-security-demo-01-base-app" reloadable="true" source="org.eclipse.jst.jee.server:spring-security-demo-01-base-app"/><Context docBase="spring-security-demo-01-base-app" path="/spring-security-demo" reloadable="true" source="org.eclipse.jst.jee.server:spring-security-demo-01-base-app"/>
Step 5) Save the file.
Step 6) Problem is solved.

not able to set spring active profile in tomcat

Tomcat8 is set to run as a service on ubuntu
I have deployed an application in tomcat8, I want the app to load(dev,local,prod)environment specific propety file
Which config file should I set -Dspring.profiles.active=\"prod\" value so the correct property file is read.
I tried in catalina.sh as JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=\"prod\""
and also in /etc/default/tomcat8
In setenv.sh
CATALINA_OPTS="-Dspring.profiles.active=prod ...a whole bunch of stuff might already be here"

Running iRods Rest in Tomcat 7

I'm trying to run iRods Rest in Tomcat 7. The only problem is that when I'm in the manager page, I have the list of application. All of them runs exept iRods Rest and if I try to push "start" I get:
FAIL - Application at context path /irods-rest could not be started
This is the steps that I had follow:
Installation of Tomcat 7 (https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get)
Installation of maven 3
git clone https://github.com/DICE-UNC/irods-rest.git
cd irods-rest
mvn package -Dmaven.test.skip=true
Upload of the .war file on the manager page host:8080
Tell me if you need more informations or the question is too specific.
I was getting the same error, but then I looked at the logs contained in /var/log/tomcat/localhost.x-x-x.log (CentOS 7):
java.io.FileNotFoundException: /etc/irods-ext/irods-rest.properties (No such file or directory)
So I created the directory and properties file:
mkdir /etc/irods-ext
vi /etc/irods-ext/irods-rest.properties
And added the following contents (found template in https://github.com/DICE-UNC/irods-rest/blob/master/docs/iRODSRESTAPIDocumentation.pdf):
irods.host=localhost
irods.port=1247
irods.zone=tempZone
utilize.packing.streams=true
auth.type=STANDARD
default.storage.resource=
web.interface.url=
cors.allow=true
Now everything seems to be working after I start the irods-rest application from the Tomcat manager page.

How to specify different context path in tomcat

I already read a number of related questions, but i did not get to a solution for my situation.
I have a webapp in a war-file that includes the version number. E.g.,sourceWarName.war. I cannot use remote deployment, the war file will be deployed manually over the tomcat manager web-interface. I would like the webapp to be accessible over a static path (decoupled from the version), e.g, http://someserver:8080/targetPath
As specified in tomcat docs and stack overflow question, it is possible to create a context.xml in my application's META-INF folder like this:
<Context path="targetPath" debug="0" reloadable="true">
...
</Context>
The file is then supposed to be copied to /tomcat7/conf/Cataline/localhost/sourceWarName-1.0.0.xml. This does not work, however. No xml file is copied. I configured the host-entry in the server.xml to make sure we do not run into double-deployment like this:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="false" deployOnStartUp="false" copyXml="true">
The app, however, is still reachable under /sourceWarName-1.0.0.
What did i miss?
I tried the answer to this question, but this did not work out for me. Only difference seems to be the docBase.
Tomcat doc says about docBase:
The value of this field must not be set unless the Context element is
defined in server.xml or the docBase is not located under the Host's
appBase.
I do not have a context element in server.xml and the appBase is the same.
Running Apache Tomcat/7.0.52 (Ubuntu).

Default Web Application URL

Currently, the default url for my sample application is:
http://127.0.0.1:8080/SpringMVC/
Is it possible for my to access it through below url ?
http://127.0.0.1:8080/
How can this be done ?
rename the war file to ROOT.war . Then delete (or rename) the default ROOT tomcat directory and start tomcat.

Resources