Why can't Eclipse resolve the spring-dwr schema?
Asked Answered
M

3

12

Eclipse is showing the following errors in my Spring's applicationContext.xml:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dwr:configuration'.   myappservlet-servlet.xml    MyApp/src/main/webapp/WEB-INF   line 23 XML Problem
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dwr:controller'.  myappservlet-servlet.xml    MyApp/src/main/webapp/WEB-INF   line 21 XML Problem
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dwr:remote'.  myappservlet-servlet.xml    MyApp/src/main/webapp/WEB-INF   line 41 XML Problem

When I hover my mouse over the line-item error, it also says:

    - schema_reference.4: Failed to read schema document 'http://www.directwebremoting.org/
 schema/spring-dwr-3.0.xsd', because 1) could not find the document; 2) the document could not be 
 read; 3) the root element of the document is not <xsd:schema>.

I confirmed that the root element is in fact <xsd:schema>. When I use autocomplete by typing <dwr: Eclipse correctly shows me the various options like <dwr:configuration>, <dwr:controller>, etc. How can Eclipse know this without reading the schema?

I make use of many different namespaces without issue; the DWR schema is the only one that isn't being resolved. Here is the declaration:

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
              http://www.springframework.org/schema/aop 
              http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-2.5.xsd
              http://www.directwebremoting.org/schema/spring-dwr
              http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
    default-autowire="byName">

I have the latest DWR 3.0.0.116.rc1 in my classpath. If I crack open the DWR jar, I find META-INF/spring.handlers containing:

http\://www.directwebremoting.org/schema/spring-dwr=org.directwebremoting.spring.DwrAnnotationNamespaceHandler

and META-INF/spring.schemas containing:

http\://www.directwebremoting.org/schema/spring-dwr-2.0.xsd=org/directwebremoting/spring/spring-dwr-2.0.xsd
http\://www.directwebremoting.org/schema/spring-dwr-3.0.xsd=org/directwebremoting/spring/spring-dwr-3.0.xsd

The escaping of the colon threw me off a bit, but I assume it's all correct, otherwise everyone's DWR would be broken.

Before I was grabbing this particular schema in real time from the DWR website, but I got bit by this when my production system crashed because the DWR site was down.

Miscreant answered 23/5, 2009 at 9:56 Comment(0)
S
10

You could try adding a user specified catalog contribution to Eclipse. Under Window->Preferences->XML->XML Catalog select User Specified Entries and then the Add button.

You can then add the details for the schema (you could copy the file locally in case of dropped connection). Eclipse will then have access to the schema during validation.

Scyphozoan answered 2/7, 2009 at 15:23 Comment(1)
Is there any way to do this when the .xsd are inside a .jar file? Should the config in /META-INF/spring.schemas be taking care of this already?Chondro
M
2

I'm not sure what your question is here. You seem to answer it yourself in the last paragraph - DWR site goes down, schema validation in Eclipse fails. Note that Eclipse (even with the Spring IDE plugin) doesn't use META-INF/spring.schemas to resolve the namespaces, that's done by the Eclipse platform. If the schema can't be found at the schema location, then you get these errors.

As for the auto-complete, Eclipse will still provide this by inferring from existing structures in your document, if it can't find the schema.

This isn't a problem in the application itself, since Spring will use the META-INF/spring.schemas file to resolve schemas from the JAR.

Maghutte answered 25/5, 2009 at 15:58 Comment(0)
S
2

This is a common problem when using Eclipse offline. It's trying to grab the schema from the net. When it can't find it, it indicates a validation error.

I just ignore these errors. When you are back online, clean the project and they go away.

Shewmaker answered 23/7, 2009 at 3:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.