开发者

Eclipse reporting problem in my web.xml, but it is processed fine

开发者 https://www.devze.com 2023-03-22 14:13 出处:网络
I\'m using Google App Engine with the Google plugin in Eclipse, here is the header of my web.xml: <?xml version=\"1.0\" encoding=\"utf-8\"?>

I'm using Google App Engine with the Google plugin in Eclipse, here is the header of my web.xml:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

Based on some of the GAE documentation, I added this:

<security-constraint>
    <web-resource-collection>
        <url-pattern>/tasks/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

However Eclipse reports an error at "url-pattern":

cvc-complex-type.2.4.a: Invalid content was found starting with element 'url-pattern'.

One of '{"http://java.sun.com/xml/ns/javaee":web-resource-name}' is expected.

I can start the app and it seems to process the web.xml file just fine, but I do开发者_如何学Cn't like the fact that Eclipse is reporting an error. What is the problem?


well, the error seems pretty straightforward - a web-resource-name tag it expected before the url-pattern :)

cheers


Just to add exact code

<security-constraint>
    <web-resource-collection>
        <web-resource-name>tasks</web-resource-name>
        <url-pattern>/tasks/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>


As @peshkira says, the problem is a missing parameter. But since the web.xml file is generated by Google tools, I thought there might be something wrong with the Google tools that were generating the files.

For my part, I was following https://developers.google.com/appengine/docs/java/dataprocessing/mapreduce_config#the_webxml_file to try out Google Modules (https://developers.google.com/appengine/docs/java/modules/) and the Web Tools Platform (WTP) (https://developers.google.com/appengine/docs/java/webtoolsplatform) for Eclipse.

So I filed a support ticket with Google Cloud Support and here is the answer they provided:

After some research, this is due to the <web-resource-name> actually missing. It's not absolutely needed within the code, but is recommended as per our documentation[1].

Here's an example of how to resolve it. I've also confirmed it fixes the error on my end:

<web-resource-collection>
    <web-resource-name>all</web-resource-name>
    <url-pattern>/*</url-pattern> </web-resource-collection>
</web-resource-collection>

I'll also go ahead and make a recommendation to add this to our source files, as they should technically be there.

Thank you for reporting this.

Sincerely,

Albert Cloud Platform Support

[1] Security and Authentication: https://developers.google.com/appengine/docs/java/config/webxml#Security_and_Authentication

0

精彩评论

暂无评论...
验证码 换一张
取 消