Link to home
Start Free TrialLog in
Avatar of a122178
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?
Avatar of rrz
rrz
Flag of United States of America image

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     
Avatar of gksinghiet
gksinghiet

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.
Avatar of a122178

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.
Try:
<Host name="localhost" >
<context path="" docBase="/myapp">

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

</context>
</Host>

ASKER CERTIFIED SOLUTION
Avatar of fargo
fargo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of a122178

ASKER

Thanks for both fargo and gksinghiet. I will try both of your solutions. Let you know later.
Avatar of a122178

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.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.

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
Avatar of a122178

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.
make enterprise.xml as
<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.
Avatar of a122178

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?
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?
Avatar of a122178

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.

Avatar of a122178

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.