a122178
asked on
Upgrade to Tomcat 5.5: Problem in context.xml
Hi,
I used to have different context path in Tomcat 5.0. But how can I do the same thing in Tomcat 5.5. I got an XML error if I do this:
<context path="" ...>
...
</context>
<context path="" ...>
...
</context>
Error: XML has to be well-formated.
Any idea?
I used to have different context path in Tomcat 5.0. But how can I do the same thing in Tomcat 5.5. I got an XML error if I do this:
<context path="" ...>
...
</context>
<context path="" ...>
...
</context>
Error: XML has to be well-formated.
Any idea?
Are you sure that you are using the same server.xml file for both tomcat5.0 and 5.5. Because what I am expecting is that your server.xml file is not welformed. Check for its welformedness using any of the XML editor like XML Spy.
ASKER
I checked. And context.xml is not well-formed because the <context>s tag should be under a parent in a valid xml. And that's the reason that I want to ask whether it is a way to have multiple <context> tag. How should I do the multiple context like
<context path="" docBase="/myapp">
</context>
<context path="likeit" docBase="/myapp">
</context>
So when user type: http://localhost or http://localhost/likeit will redirect to http://localhost/myapp
The file is context.xml in Tomcat 5.5. I have the <context>(s) tag in server.xml in Tomcat 5.0 because I think context has moved to context.xml in Tomcat 5.5.
Need more help on that.
<context path="" docBase="/myapp">
</context>
<context path="likeit" docBase="/myapp">
</context>
So when user type: http://localhost or http://localhost/likeit will redirect to http://localhost/myapp
The file is context.xml in Tomcat 5.5. I have the <context>(s) tag in server.xml in Tomcat 5.0 because I think context has moved to context.xml in Tomcat 5.5.
Need more help on that.
Try:
<Host name="localhost" >
<context path="" docBase="/myapp">
</context>
<context path="likeit" docBase="/myapp">
</context>
</Host>
<Host name="localhost" >
<context path="" docBase="/myapp">
</context>
<context path="likeit" docBase="/myapp">
</context>
</Host>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for both fargo and gksinghiet. I will try both of your solutions. Let you know later.
ASKER
-- For gksinghiet's solution,
sorry that It does not work.
-- For fargo's solution,
It seems it work. But I got another error
Apr 27, 2006 9:56:08 AM org.apache.catalina.startu p.HostConf ig deployDescriptor
WARNING: A docBase C:\Program Files\Application\Enterpri se\TOMCAT\ webapps\my app inside the host appBase has been specified, and will be ignored
Apr 27, 2006 9:56:08 AM org.apache.catalina.core.S tandardCon text resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentE xception: Document base C:\Program Files\Application\Enterpri se\TOMCAT\ webapps\en terprise does not exist or is not a readable directory
Which I create the enterprise.xml
<context docBase="/myapp">
</context>
And I do not have a folder called enterprise inside webapps and that's the reason why I need to use the context path.
sorry that It does not work.
-- For fargo's solution,
It seems it work. But I got another error
Apr 27, 2006 9:56:08 AM org.apache.catalina.startu
WARNING: A docBase C:\Program Files\Application\Enterpri
Apr 27, 2006 9:56:08 AM org.apache.catalina.core.S
SEVERE: Error starting static Resources
java.lang.IllegalArgumentE
Which I create the enterprise.xml
<context docBase="/myapp">
</context>
And I do not have a folder called enterprise inside webapps and that's the reason why I need to use the context path.
myapp was just for an example. You should replace myapp with the source for your enterprise application.
with my solution, u need not to modify the server.xml
with my solution, u need not to modify the server.xml
ASKER
I know.. what I have is a folder myapp under
webapps
--> myapp
But I want to make the URL http://localhost/enterprise, which enterprise folder does not exist, pointed to http://localhost/myapp.
webapps
--> myapp
But I want to make the URL http://localhost/enterprise, which enterprise folder does not exist, pointed to http://localhost/myapp.
make enterprise.xml as
<context path="/enterprise" docBase="/myapp">
</context>
This should anyway work.
<context path="/enterprise" docBase="/myapp">
</context>
This should anyway work.
OK. got it. One should not use path attribute unless the context is defined in server.xml. Moreover, if u define the context with an xml file, the docBase should only be used if the sources are outside of webapps. Use docBase only if the sources are NOT in webapps.
if u want path other than the name of the source dir. for webapps. Try keeping the sources outside, define the docBase accordingly and put the path attribute in the context file.
if u want path other than the name of the source dir. for webapps. Try keeping the sources outside, define the docBase accordingly and put the path attribute in the context file.
ASKER
So, I tried to make enterprise.xml. But it doesn't work too.
For the second suggestion, are you saying that I cannot do such a thing in Tomcat 5.5? Or how do I define the context in server.xml?
For the second suggestion, are you saying that I cannot do such a thing in Tomcat 5.5? Or how do I define the context in server.xml?
don't define context definition in server.xml, it is really discouraged. Have u tried it with keeping sources outside of tomcat and defining the docBase?
have a look here, it is clearly defined
http://www.dinero.com/tomcat-docs/deployer-howto.html#A%20word%20on%20Contexts
http://www.dinero.com/tomcat-docs/deployer-howto.html#A%20word%20on%20Contexts
ASKER
Yeah. I haven't defined anything in server.xml.
Thanks for the reference. I understand what is context now. But it doesn't tell whether I can do the thing that I want. I cannot keep sources outside of tomcat and defining the docBase. As I said, I want to have a reference link that the folder does not exist in tomcat webapps.
Thanks for the reference. I understand what is context now. But it doesn't tell whether I can do the thing that I want. I cannot keep sources outside of tomcat and defining the docBase. As I said, I want to have a reference link that the folder does not exist in tomcat webapps.
ASKER
Thanks for fargo. I give up with the context path. I will use redirect in the jsp file.
But you provide the great information about this.
But you provide the great information about this.
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
http://tomcat.apache.org/faq/deployment.html