Frank
Frank

Reputation: 31086

Tomcat context.xml seems to be broken, how to set sessionCookiePath properly?

This question is related to a previous question : Java servlet session not working properly with NGinx, how to fix?

I solved the above question when I changed "<Context>" to :

<Context sessionCookiePath="/">
...
</Context>

That change took place in /opt/tomcat85/conf/context.xml, which is not in my .war file.

Now I want the change to take place in my own application, so I need to change "context.xml" in my C:\Dir_GATE_Web\web\META-INF [ so this change only affects my own application. ]

Before the change, my C:\Dir_GATE_Web\web\META-INF\context.xml looked like this :

<?xml version="1.0" encoding="UTF-8"?>
<Context path=""/>

After the change, it looks like this :

<?xml version="1.0" encoding="UTF-8"?>
<Context path=""/>
<Context sessionCookiePath="/">    
</Context>

But after I compiled it, I got the following error :

[Fatal Error] :3:2: The markup in the document following the root element must be well-formed.
C:\Dir_GATE_Web\nbproject\build-impl.xml:1048: Deployment error: Tomcat configuration file C:\Dir_GATE_Web\web\META-INF\context.xml seems to be broken. Please make sure it is parseable and valid.

I'm not familiar with the proper format of the context.xml file, what is the correct way to do it ?

Upvotes: 1

Views: 2088

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201447

The Apache Tomcat Configuration - Common Attributes documents sessionCookiePath and path (context path) at the same level. You have two contexts, you want one (per application). Change it to something like

<Context path="" sessionCookiePath="/" />

Upvotes: 1

Related Questions