使用jetty-maven-plugin运行webapp的Hibernate错误

时间:2012-05-04 13:04:08

标签: hibernate maven jetty maven-jetty-plugin

我有一个使用Hibernate的Maven构建的Web应用程序。它在Tomcat中成功运行,但在jetty-maven-plugin

中执行时失败并出现以下异常
java.lang.TypeNotPresentException: Type org.hibernate.collection.PersistentCollection not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:98)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:50)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:120)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:82)
at java.lang.Class.getGenericInterfaces(Class.java:794)
at org.springframework.core.GenericTypeResolver.doResolveTypeArguments(GenericTypeResolver.java:170)
at org.springframework.core.GenericTypeResolver.resolveTypeArguments(GenericTypeResolver.java:164)
<snip>
Caused by: 
java.lang.ClassNotFoundException: org.hibernate.collection.PersistentCollection
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:95)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:50)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:120)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:82)
at java.lang.Class.getGenericInterfaces(Class.java:794)

org.hibernate.collection.PersistentCollection位于hibernate-core中,它作为Web应用程序的传递依赖项包含在内。它绝对可以在WAR中访问,因为应用程序在放入Tomcat时可以正确运行。

POM包含以下插件配置:

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>8.1.3.v20120416</version>

    <configuration>
        <jettyXml>src/main/jetty/jetty-env.xml</jettyXml>
    </configuration>

    <dependencies>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.9</version>
        </dependency>
    </dependencies>
</plugin>

为什么jetty-maven-plugin无法解决org.hibernate.collection.PersistentCollection

1 个答案:

答案 0 :(得分:0)

事实证明,这是Spring Flex和Hibernate 4之间不兼容的问题:https://jira.springsource.org/browse/FLEX-220