XmlBeanDefinitionStoreException - >找不到标签

时间:2014-09-10 06:58:43

标签: java spring jaxb portlet spring-ws

当尝试部署我的portlet时,我使用了一个webservice,我得到了这个异常:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 7 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'oxm:jaxb2-marshaller'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

我搜索了谷歌,并没有找到解决方案..

我的applicationContext.xml如下所示:

<?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:context="http://www.springframework.org/schema/context"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd 
    http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-4.1.xsd" >

    <context:annotation-config />
    <context:component-scan base-package="be.icredit.einvoice.service" />
    <context:component-scan base-package="be.icredit.einvoice.webserviceTest" />

    <oxm:jaxb2-marshaller id="marshaller" context-path="be.icredit.einvoice.proxy.CustomerDaoService"/>
    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
         <property name="marshaller" ref="marshaller" /> 
         <property name="unmarshaller" ref="marshaller" /> 
        <property name="defaultUri"
            value="http://localhost:8081/ws-demo/account-balance-service" />
    </bean>

</beans>

我知道oxm有问题:jaxb2-marshaller标签......但是什么?我按照一些教程中列出的说明进行操作。

看起来编译器确实找不到声明oxm:jaxb2 marshaller,但它已在上面定义。

下面你可以找到我的POM:

<?xml version="1.0"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>be.icredit</groupId>
    <artifactId>einvoice</artifactId>
    <packaging>war</packaging>
    <name>einvoice Portlet</name>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <liferay.maven.plugin.version>6.2.10.6</liferay.maven.plugin.version>
        <liferay.version>6.2.1</liferay.version>
        <spring.suite.version>3.2.10.RELEASE</spring.suite.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.liferay.maven.plugins</groupId>
                <artifactId>liferay-maven-plugin</artifactId>
                <version>${liferay.maven.plugin.version}</version>
                <executions>

                </executions>
                <configuration>
                    <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
                    <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
                    <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
                    <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
                    <liferayVersion>${liferay.version}</liferayVersion>
                    <pluginType>portlet</pluginType>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.9.0</version>

                <executions>
                    <execution>
                        <id>BatchDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.BatchDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>BatchDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerAccountDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.CustomerAccountDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>CustomerAccountDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.CustomerDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>CustomerDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.DocumentDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>DocumentDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.DocumentTemplateDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>DocumentTemplateDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailStatusDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.EmailStatusDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>EmailStatusDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.EmailTemplateDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>EmailTemplateDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>FileService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.FileService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>FileService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>SenderDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.SenderDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>SenderDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>portal-service</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-bridges</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-taglib</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-java</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws</artifactId>
            <version>1.5.8</version>
            <classifier>all</classifier>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>
</project>

任何人都知道解决方案吗?

提前致谢

2 个答案:

答案 0 :(得分:1)

查看您正在使用的Spring版本

<spring.suite.version>3.2.10</spring.suite.version>

查看架构位置版本

http://www.springframework.org/schema/oxm/spring-oxm-4.1.xsd

你正在使用4.1。您的春季版本3.2.10将不具有4.1的xsd,仅为3.2及以下。您可以排除版本

http://www.springframework.org/schema/oxm/spring-oxm.xsd

Spring将在spring-oxm jar中找到最新的xsd版本,即where you will find the jaxb2-marshaller element


实际上

最重要的是,我运行了你的pom(至少只是带有Spring依赖项),并且你声明的那些依赖项都没有spring-oxm传递依赖,并且你没有显式声明{{1} }。所以你也需要这样做。

spring-oxm

更新

基于Can Spring-WS 1.5 be used with Spring 3?和给出的答案,它看起来像<dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${spring.suite.version}</version> </dependency> 1.5与Spring 3不兼容。但this answer提供了解决方法

答案 1 :(得分:0)

在xml中,为

提供的架构位置
      xmlns:oxm="http://www.springframework.org/schema/oxm  http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd"