• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1240
  • Last Modified:

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?
0
a122178
Asked:
a122178
  • 7
  • 6
  • 2
  • +1
1 Solution
 
rrzCommented:
I don't much about this and I can't really offer a solution.  But I did see these.
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html 
http://tomcat.apache.org/faq/deployment.html     
0
 
gksinghietCommented:
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.
0
 
a122178Author Commented:
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
gksinghietCommented:
Try:
<Host name="localhost" >
<context path="" docBase="/myapp">

</context>
<context path="likeit" docBase="/myapp">

</context>
</Host>

0
 
fargoCommented:
in order to have multiple context u need to have multiple context files to be placed in tomcat/conf/Catalina/localhost folder
--> myapp1.xml
<context path="/myapp1" docBase="/myapp">
</context>

-->myapp2.xml
<context path="/myapp2" docBase="/myapp">
</context>

Moreover, with tomcat 5.5.x you can have your context files name mapped to your path automatically. It means, if u wish to have myapp1 as context path. You just need to put myapp1.xml in the tomcat/conf/Catalina/localhost folder and remove the path entry from the xml like below (automatically mapped)
--> myapp1.xml
<context docBase="/myapp">
</context>
0
 
a122178Author Commented:
Thanks for both fargo and gksinghiet. I will try both of your solutions. Let you know later.
0
 
a122178Author Commented:
-- 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.startup.HostConfig deployDescriptor
WARNING: A docBase C:\Program Files\Application\Enterprise\TOMCAT\webapps\myapp inside the host appBase has been specified, and will be ignored
Apr 27, 2006 9:56:08 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Program Files\Application\Enterprise\TOMCAT\webapps\enterprise 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.

0
 
fargoCommented:
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
0
 
a122178Author Commented:
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.
0
 
fargoCommented:
make enterprise.xml as
<context path="/enterprise" docBase="/myapp">
</context>

This should anyway work.
0
 
fargoCommented:
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.
0
 
a122178Author Commented:
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?
0
 
fargoCommented:
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?
0
 
fargoCommented:
0
 
a122178Author Commented:
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.

0
 
a122178Author Commented:
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now