My JSF application is deployed under tomcat and server.xml is configured as follows for my application
<Host name="myapp.com" appBase="/home/myapp/public_html">
<Alias>www.myapp.com</Alias>
<Context path="" reloadable="true" docBase="/home/myapp/public_html" debug="1"/>
<Context path="/manager" debug="0" privileged="true" docBase="/usr/local/jakarta/tomcat/server/webapps/manager">
</Context>
</Host>
With these settings I can access all the pages under 'web' folder. I have 'app' folder under 'web' and I have couple of jsp pages under 'app', when I try to access some pages available under 'app' with the following URL: www.myapp.com/app/test_page.jsf, I get 'requested resource cannot be found'
What are the changes I need to do in Tomcat`s Server.xml to get this working.
Do I need to add context path for the 'app' subcontext like this mentioned below in Server.xml:
<Context path="/myapp/app" reloadable="true" docBase="/home/myapp/public_html/app" debug="1"/>
Assuming that /web folder is placed in /public_html folder, you need to include the /web folder in either appBase and docBase, or in URL.
Related
I am working on multi profile project and its maven pom file hierarchy parent pom file contailn the tomcat7 plugin.
Parent pom.xml
|--child1 pom.xml
|--child2 pom.xml
|--child3 pom.xml
|--child4 pom.xml
|--child5 pom.xml
Profiles
Parent pom.xml
profiles
profile1 modules
|--child1
|--child2
profile2 modules
|--child1
|--child3
|--child4
I am willing to have following external server.xml file
<?xml version='1.0' encoding='utf-8'?>
<Server port="8080" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Listener className="it.xxx.tomcat.listener.TBXServerLifecycleListener"/>
</Host>
</Engine>
</Service>
</Server>
And i have configured server.xml file location in tomcat plugin itself
<serverXml>${user.dir}\conf\server.xml</serverXml>
Without this external config file tomcat is starting fine but after adding this tomcat plugin doesn't idetify war file in the selected profile,
Acccording to the following answer I must configure webapp paths in this file.
https://stackoverflow.com/a/26004617/1709600
But in my priject i have around 50 profiles and each profile webapps are diffetent. I cannot configure every webapp in this single server.xml file.
Then my question is ,
Is there way to and webapps path in tomcat plugin itself ???
without adding following xml tag to server.xml file server.xml
<Context docBase="../../webapp" path="/webapp" reloadable="true" />
I have already play with following configurations but any of this didn't work for me ... :(
<defaultContextFile>${user.dir}\conf\context.xml</defaultContextFile>
<warSourceDirectory>${project.build.directory}/${project.build.finalName}/</warSourceDirectory>
<warDirectory>${project.build.directory}/${project.build.finalName}/</warDirectory>
<warFile>${project.build.directory}/${project.artifactId}.war</warFile>
My Maven command :
tomcat7:run-war-only -P profileX
I'm doing some deploy / start / stop tests locally on my computer, and it would be very comfortable to have my webapps deployed (so they can be managed throught the Tomcat manager webapp) but not started right away when Tomcat start.
Is this feasible at all?
Within the documentation I only found how to deploy or not deploy a webapp at all (through the "Host" configuration in server.xml).
This is a portion of my server.xml:
<Host name="host1.localpc" appBase="C:\tools\tomcat\webapps\host1" unpackWARs="true" autoDeploy="true" deployIgnore="^(?!ROOT$).*?$" deployOnStartup="true">
<Context docBase="C:\tools\tomcat\runnable\apache-tomcat-7.0.69\webapps\manager" path="/manager" privileged="true" />
</Host>
<Host name="host2.localpc" appBase="C:\tools\tomcat\webapps\host2" unpackWARs="true" autoDeploy="true" deployIgnore="^(?!ROOT$).*?$" deployOnStartup="true">
<Context docBase="C:\tools\tomcat\runnable\apache-tomcat-7.0.69\webapps\manager" path="/manager" privileged="true" />
</Host>
<Host name="host3.localpc" appBase="C:\tools\tomcat\webapps\host3" unpackWARs="true" autoDeploy="true" deployIgnore="^(?!ROOT$).*?$" deployOnStartup="true">
<Context docBase="C:\tools\tomcat\runnable\apache-tomcat-7.0.69\webapps\manager" path="/manager" privileged="true" />
</Host>
Hostnames are handled throught the Windows HOSTS file.
I'm running Tomcat 7.0.69
Hum... Certainly, as far as I know, any war is automatically started by Tomcat just after being deployed. Still, I'd suggest you to take a look at the Tomcat Client Deployer, a module from which you can get an Ant script to deploy-and-stop your application. To accomplish this, you should:
Download the TCD.
Parametrize the build.xml.
Invoke ant deploy stop to deploy and stop.
I cannot find any declaration in server.xml for the "examples" webapp that is installed by default in Tomcat.
So where is the xml fragment in which this declaration had been done if not in server.xml ?
"Examples" is just one of various web applications deployed under Tomcat that loads web applications from folder "webapps" located under $CATALINA_BASE. This location is configured in server.xml, in tag "Host":
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
and can be changed if it is needed.
I have deployed web application on tomcat7 and now I am looking forward to update Virtual host to map domain name with my application by updating server.xml.
Is my approach correct?
I am working on ubuntu OS and not sure how to get the context path for my web app. Any help is greatly appreciated.
The context path of your application will be the name of the war file. If you want to override it, you can follow Tomcat's documentation (https://tomcat.apache.org/tomcat-7.0-doc/config/context.html).
Edit the server.xml in the conf folder of the tomcat installation and make the following changes.
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="/yoururl" docBase="YourApp" useHttpOnly="false">
<Manager pathname="" />
</Context>
</Host>
I want to deploy my app to the server, and then I can visit the app like this:
http://10.10.10.10/index.jsp
but not
http://10.10.10.10/bar/index.jsp
so this is my host configuration in server.xml:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="/home/foo/bar.war" reloadable="false" path=""/>
</Host>
But, after I start up tomcat
sh $CATALINA_HOME/bin/startup.sh
I found that tomcat does not unpack the war file in $CATALINA_HOME/webapps.
then I try to delete all files in $CATALINA_HOME/webapps/ROOT, but it does not matter.
so is there someone come cross this issue before? and how to solve the probelm?
Tomcat 7 does not unpack WAR files from outside the Host's appBase into the appBase.
Tomcat 7 will run your application from the WAR.