Cannot validate 3.0 web.xml descriptor


I have a project with a 2.5 descriptor that is currently working, but would like to change it to version 3.0. However, when I change the header, Idea does not even recognize the version number, complaining that it has the wrong attribute value. If I change it to 2.5 it does work.

This is the current web-app definition I'm trying to use:
<web-app xmlns:xsi=""
             id="straininfo" version="3.0">

Where it says 'version="3.0"', Intellij complains that this is a "Wrong attribute value".

If I try to Validate the file, I get a bunch of errors like:
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of ',web-app'.

Any idea what is misconfigured?



Can't reproduce this, sorry. As a blind guess, edit the web.xml as you wish and try main menu / File / Invalidate Caches with restart.



Thanks, I didn't know about that option. It doesn't help though, still not working. I noticed that if I change it back to 2.5 it also does not validate, so perhaps IDEA is loading the XSDs twice somehow? I did forget to note that I'm using the community edition. I see that that has no specific java EE support, so I suppose this might be the reason validation isn't working?


Thank you for note about community edition, but it also works for me.

When I first create web.xml with web-app_2_5.xsd it is red ("Cannot resolve"). Then I use "Fetch" quick fix, and everything's green. Then change to web-app_3_0.xsd, change version to 3.0, fetch, and all is Ok again.

Do you fetch these resources? Anyway, Settings dialog / Schemas and DTDs page shows what resources are fetched, what are ignored, etc. Please check, is something suspicious there? What if to remove those entries and re-fetch?



Schemas and DTDs shows no entries at all. Only a bunch of ignored entries (of which none match).  When I make a new file with only this header, the problem persists. It appears Intellij is using some sort of built-in validation.


Is the reference to web-app_3_0.xsd red or green? If green, you can Ctrl+B on it to jump to target file. Inside that file Alt+Home to show the path. Maybe it gives a hint.



Aha, this shows what's going on. It's defaulting to using a web-app_2_5.xsd that is in the freemarker package (one of the dependencies). I guess I should force it to ignore this somehow? It appears the external schema files dialog won't let me add files not in the local project/file system.


It may be an IDEA problem. But what is freemarker package? Is that a publically available jar, or a module in your project? How could I reproduce the problem?



Freemarker is depended on by Struts 2. Attached is a sample maven project that triggers this for me. The problem is they bundle the XSD's on the classpath, so it appears intellij is choosing one of these at random (they all provide the same namespace).

Basically all you should need is this dependency:


Thank you, reproduced.

The workaround is to create the same web.xml in another module, without freemarker in the dependencies. The reference will be red, then do Fetch on it. Then return to initial web.xml and make dummy editing. For me the error has gone after that.

I will report the issue into our bugtracker, it's probably common, not related to Maven, web or freemarker.



Please sign in to leave a comment.