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?
LVL 3
a122178Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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     
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.
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.
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

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

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

</context>
</Host>

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>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
a122178Author Commented:
Thanks for both fargo and gksinghiet. I will try both of your solutions. Let you know later.
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.

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

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

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.