Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when configure tomcat new Context tomcat creates me 2 web apps

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic