当尝试部署我的 portlet(使用 Web 服务)时,我收到此异常:
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>
有人知道解决办法吗?
提前致谢
最佳答案
查看您正在使用的 Spring 版本
<spring.suite.version>3.2.10</spring.suite.version>
并查看您的架构位置版本
http://www.springframework.org/schema/oxm/spring-oxm-4.1.xsd
您使用的是 4.1。你的 spring 版本 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
传递依赖项,并且您没有显式声明 spring-oxm
。所以你也需要这样做。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.suite.version}</version>
</dependency>
<小时/>
更新
基于Can Spring-WS 1.5 be used with Spring 3?以及给出的答案,看起来 spring-ws
1.5 与 Spring 3 不兼容。但是 this answer提供了一种解决方法
关于java - XmlBeanDefinitionStoreException --> 找不到标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25759146/