Cannot validate 3.0 web.xml descriptor

Hello,

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="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://java.sun.com/xml/ns/javaee"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
             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 'http://java.sun.com/xml/ns/javaee,web-app'.

Any idea what is misconfigured?

10 comments

Hello.

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.

Regards,
Alexander.

1

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?

0

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?

Regards,
Alexander.

0

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.

0

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.

Alexander.

0

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.

0

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?

Thanks,
Alexander.

0

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:
     <dependencies>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.19</version>
        </dependency>
    </dependencies>



Attachment(s):
test.zip
0

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.

Regards,
Alexander.

0

Please sign in to leave a comment.