aspose file tools*
The moose likes Tomcat and the fly likes when configure tomcat new Context tomcat creates me 2 web apps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "when configure tomcat new Context tomcat creates me 2 web apps" Watch "when configure tomcat new Context tomcat creates me 2 web apps" New topic
Author

when configure tomcat new Context tomcat creates me 2 web apps

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
in my tomcat i need to create url to access that is different from my web app name so according to the web info i found , in server.xml in tomcat i added :



where MyAppGW is the directory of my web app then in MyAppGW web.xml i added :


so when i give to external client the url http://xx.xx.xx.xx:8888/console/ws/WsEndpoint it connects to my web app. every thing is working fine and great except that when i look in my tomcat webapps i see 2 directors is this normal ?:
MyAppGW
console

the console is the same as the MyAppGW. i suspect this give me problems with other frameworks in my web app like log4j not Rolling and creating duplication of log files .
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

I think what you mean is that you have a console.war file and a console directory in TOMCAT_HOME/webapps. This is normal.

Under Tomcat's default settings, if you deploy a war file into TOMCAT_HOME/webapps, Tomcat will unpack (explode) it, creating a directory with the same basename as the war file.

The actual executing copy of the app will be the exploded WAR.

It's important to know this, because Tomcat will not automatically update the exploded WAR if you update the war file. Instead, it will continue to use the old, out-of-date code in the exploded WAR.

So when deploying a war file, you should delete the old exploded copy.


Customer surveys are for companies who didn't pay proper attention to begin with.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hi
Thanks for the replay , but no . my war is MyAppGW.war .
it creates me and i dont know why another directory called "console"
i dont have any console.war .
and i dont know why could be because i configured in the server.xml
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Don't put webapp Contexts in server.xml. That's been considered bad practice since Tomcat V4 or earlier. Put them as individual XML files in TOMCAT_HOME/catalina/localhost or in the WAR in META-INF/context.xml.

However, the process I described still applies. Tomcat is simply exploding the WAR under its context pathname instead of using the WAR basename.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Can you please tell me how should this configuration look like , in for example i want to create file under : META-INF/context.xml?
just simple create context.xml file and put this: init :
<Context docBase="MyAppGW" path="/console" reloadable="true" /> ?
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hi
i did what you say and created the file under META-INF/context.xml
looks like this :

when tomcat starts it creates me the dirctory under conf\Catalina\localhost\
called : MyAppGW.xml with the context.xml content.
the problem is when i try to invoke the method to the old url , it failed and gives me :

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Tomcat doesn't do exactly what I want/expect as far as context names go when using a context xml file.

In fact, it ignores the name given in the context xml file when that file is placed in the TOMCAT_HOME/conf/Catalina/localhost/ directory and deploys using the name of the context file itself.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
in simple words if i like to serve in this url : http://xx.xx.xx.xx:8888/console/ws/WsEndpoint
and my webapp called MyAppGW what shell i do ?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Meir Yan wrote:in simple words if i like to serve in this url : http://xx.xx.xx.xx:8888/console/ws/WsEndpoint
and my webapp called MyAppGW what shell i do ?


If you're using a META-INF/context.xml, rename the WAR to console.war. If you use your own Context xml file in TOMCAT_HOME/conf/Catalina/localhost, name it console.xml.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
thanks for the fast reply
so if i can't rename the main war file, i just need to rename the context.xml to console.xml
great i will try it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: when configure tomcat new Context tomcat creates me 2 web apps