Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

tomcat7 - Deploy application on custom host of Tomcat

I got some issues to deploy my application.

Environment: Ubuntu 10.04, Tomcat 7.02 (Install from archive from tomcat site, not from repositories), server is run and stoped manualy, not using any IDE.

For the first I've created host in $CATALINA_HOME/conf/server.xml:

<Host name="java.dev"  
      appBase="/home/krasilich/java/"  
      autoDeploy="true" >  
    <Alias>www.java.dev</Alias>  
</Host>

Then create a context in $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml:

<Context docBase="siloc/web/" />

And got the error

A docBase /home/krasilich/java/siloc/web/ inside the host appBase has been specified, and will be ignored

But, if I copy manager.xml to $CATALINA_HOME/conf/Catalina/java.dev/ I can run manager app. If I deploy my application through manager - it says that everything is going well, but I still see the 404 on java.dev:8080/siloc/

That's all about custom host.

I've tried to deploy application through manager on localhost also and it works, I can see my "Hello Word" on localhost:8080/siloc/

But, if I change the text in my index.jsp it'll not affected on frontend. The "Redeploy" button isn't help for me.

As I mentioned manager just copy application files to webapps directory, and don't make any changes in config files.

All I need that I can deploy application in any directory in my filesystem (actually it will be /home/krasilich/java/).

And it would be great if I can do this on custom host like java.dev I need the answer, why the context in $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml isn't working for me, and what shall I do to make it consistent?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have been able to replicate your problem.

There are 2 workaround I can suggest after tinkering around with combinations of appBase and docBase. Looks like the two do not operate together.

Option 1 - remove appBase

Remove the appBase from server.xml and specify the full path to the web app in docBase in the $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml

I assume your value will be /home/krasilich/java/siloc/web/siloc.

Note: specifying only up to the parent folder /home/krasilich/java/siloc/web/ will show you a directory listing of the parent folder

Option 2 - Remove docBase

In $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml

remove the docBase and keep only <Context/>

Tomcat infers the webapp name siloc from the $CATALINA_HOME/conf/Catalina/java.dev/siloc.xml and it looks for the webapp named siloc in the appBase.

This allows java.dev:8080/siloc/ to work provided you also change the appBase in server.xml to the parent folder of your webapp siloc.

In response to why manager works, same reason - there is no docBase in the manager.xml

I am trying other combinations of docBase but any value I give throws the

WARNING: A docBase ... inside the host appBase has been specified, and will be ignored

So my conclusion is to remove the docBase. This is not a good idea - since the full path to parent folder is then hardcoded in server.xml.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...