使用依赖项部署war导致ClassNotFoundException

时间:2015-07-15 15:49:15

标签: java maven java-ee deployment wildfly

我想使用我的数据处理程序提供的Enities 我的控制器测试项目。数据处理程序设置为依赖项 在控制器测试中,我没有得到编译错误,但是,当我想要 部署它我得到这个例外:

Caused by:java.lang.ClassNotFoundException: org.test.SomeEntityRepo from [Module deployment.controller-test.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.as.ejb3.deployment.processors.BusinessViewAnnotationProcessor.getEjbClass(BusinessViewAnnotationProcessor.java:229)
    ... 7 more

当我将SomeEntity和SomeEntityRepo放入Controller-test项目时 一切都按预期工作。

这是一个非常简单的设置,我刚开始使用EE和DI 所以我真的很沮丧。

我从一个wildfly快速启动示例中复制了结构的关键部分。 Wildfly 8.2和9.0给出了相同的例外。

请帮助:(

项目数据处理程序:

类:SomeEntity

@Entity
public class SomeEntity implements Serializable
{
  @Id
  protected long id;
  // Getter and Setter
}

类:SomeEntityRepo

@Stateless
public class SomeEntityRepo {

    @Inject
    private EntityManager em;

    public SomeEntity findOne(long id) {
        return em.find(SomeEntity.class, id);
    }
}

课程资源

public class Resources {

    @PersistenceContext
    @Produces
    private EntityManager entityManager;
}

XML:持久性

<persistence version="2.1"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="primary">
        <jta-data-source>java:jboss/datasources/TestDS</jta-data-source>
        <properties>
            <!-- Properties for Hibernate -->
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
            <property name="hibernate.show_sql" value="false" />
        </properties>
    </persistence-unit>
</persistence>

项目:控制器测试

@RequestScoped
public class TestClass {

    @Inject
    private SomeEntityRepo repo;

    public void test() {
        repo.find(0L);
    }
}

增加:

之后我的战争看起来像这样:

   controller-test.war
   ^-- WEB-INF
       ^-- classes
       ^-- lib
           ^-- data-handler.0.0.1-SNAPSHOT.jar
               ^-- com
                   ^--test
                      ^-- SomeEntity
                      ^-- SomeEntityRepo

0 个答案:

没有答案