软件包名称不包含ObjectFactory.class或jaxb.in​​dex [英] packagename doesnt contain ObjectFactory.class or jaxb.index

查看:652
本文介绍了软件包名称不包含ObjectFactory.class或jaxb.in​​dex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将项目部署到tomcat服务器时,我不断收到此异常:

While deploying my project to a tomcat-server, I get constantly this exception:

由以下原因引起:org.springframework.beans.factory.BeanCreationException:创建名称为"marshaller"的bean时出错:调用init方法失败;嵌套的异常是org.springframework.oxm.UncategorizedMappingException:未知的JAXB异常;嵌套的异常是javax.xml.bind.JAXBException:"be.icredit.einvoice.proxy.customerdaoservice"不包含ObjectFactory.class或jaxb.in​​dex

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller': Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: "be.icredit.einvoice.proxy.customerdaoservice" doesnt contain ObjectFactory.class or jaxb.index

但是它确实有一个ObjectFactory.class!

But it does have an ObjectFactory.class!

我正在使用Spring,Maven和Jaxb2

Im using Spring, Maven and Jaxb2

我的POM:

<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>
                            <generateDirectory>target/batchdaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>BatchDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.batchdaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerAccountDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/customeraccountdaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>CustomerAccountDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.customeraccountdaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/customerdaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>CustomerDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.customerdaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/documentdaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>DocumentDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.documentdaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/documenttemplatedaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>DocumentTemplateDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.documenttemplatedaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailStatusDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/emailstatusdaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>EmailStatusDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.emailstatusdaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/emailtemplatedaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>EmailTemplateDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.emailtemplatedaoservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>FileService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/fileservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>FileService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.fileservice</generatePackage>
                        </configuration>
                    </execution>
                    <execution>
                        <id>SenderDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generateDirectory>target/senderdaoservice</generateDirectory>
                            <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
                            <schemaIncludes>
                                <include>SenderDaoService.wsdl</include>
                            </schemaIncludes>
                            <generatePackage>be.icredit.einvoice.proxy.senderdaoservice</generatePackage>
                        </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>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>
</project>

我从字面上是无能为力的.

I am literally clueless..

我的应用程序上下文:

<?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/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
        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">

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


    <oxm:jaxb2-marshaller id="marshaller" contextPath="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>

推荐答案

首先,让我们检查一下Maven构建或IDE是否存在问题.

First of all, let's check if you have the problem with the Maven build or in the IDE.

您是说您的构建似乎工作正常.

You're saying that your build seems to work fine.

  • 您是否有一个简单的解组测试,用于检查解组是否真正有效?做一个并确保它能正常工作.
  • 检查生成的war-它是否在WEB-INF/classes中具有所有生成的类?
  • 您有几次处决,所有生成的程序包都存在(在WEB-INF/classes中)吗?
  • Do you have a simple unmarshalling test which checks that unmarshalling really works? Make one and make sure it works.
  • Check the generated war - does it have all of the generated class in WEB-INF/classes?
  • You have several executions, are all of the generated packages present there (in WEB-INF/classes)?

当排除了Maven构建的问题时,请检查您的IDE.我认为您正在使用Eclipse:

When problems with the maven build are ruled out, check your IDE. I think you're using Eclipse:

  • 您是否将所有生成的目录都视为Eclipse源文件夹?
  • 您简单的解组测试(请参阅上文)是否可以在Eclipse中工作?
  • 您是否需要以某种方式配置将哪些文件夹部署到Tomcat?
  • 您可能需要将编译目标重定向到WEB-INF/classes吗?
  • Do you see all of the generated directories as Eclipse source folders?
  • Does your simple unmarshalling test (see above) work in Eclipse?
  • Do you have to configure somehow, which folders are deployed to Tomcat?
  • Do you maybe need to redirect compilation target to WEB-INF/classes?

有很多地方可能会出错.一个简单的单元测试将帮助检查每个步骤以找出缺失的地方.

There's quite a couple of places this can go wrong. A simple unit test will help check every step to find out what's missing.

正如我之前说过的,maven-jaxb2-plugin确实将目标目录添加为编译源根目录(除非您明确配置了您不需要的目录).因此,Maven集成插件(如Eclipse中的m2eclipse)应该将这些目录添加为源文件夹.从某种意义上说,您有一个war项目并执行了多次执行,您的项目与普通"设置有些不同.但是我仍然认为这必须可行,maven-jaxb2-plugin

As I said before, maven-jaxb2-plugin does add your target directory as a compile source root (unless you explicitly configure it out which you don't do). So Maven integration plugins like m2eclipse in Eclipse are supposed to add these directories as source folders. Your project is a bit different from the 'normal' setup in a sense that you have a war project and multiple executions. But I still think this must work, maven-jaxb2-plugin does pretty standard stuff here:

    if (getAddCompileSourceRoot()) {
        getProject().addCompileSourceRoot(getGenerateDirectory().getPath());
    }

这与build-helper-maven-plugin 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆