mercredi 15 juillet 2015

Deploying war with dependency resulting in ClassNotFoundException

I want to use the Enities provided by my data-handler in my controller-test project. The data-handler is set as an dependency in controller-test and I get no compile errors, however, when I want to deploy it I get this exception:

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

When I put SomeEntity and SomeEntityRepo into the Controller-test project everything works as it should.

It's a really simple setup and I just started to work with EE and DI so I am really frustrated.

I copied the key parts of the structure from one of the wildfly quickstart samples.

Please help :(

Project data-handler:

Class: SomeEntity

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

Class: SomeEntityRepo

@Stateless
public class SomeEntityRepo {

    @Inject
    private EntityManager em;

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

Class Resource

public class Resources {

    @PersistenceContext
    @Produces
    private EntityManager entityManager;
}

XML: Persistance

<persistence version="2.1"
    xmlns="http://ift.tt/1cKbVbQ" xmlns:xsi="http://ift.tt/ra1lAU"
    xsi:schemaLocation="
        http://ift.tt/1cKbVbQ
        http://ift.tt/1kMb4sd">
    <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>

Project: Controller-test

@RequestScoped
public class TestClass {

    @Inject
    private SomeEntityRepo repo;

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

Aucun commentaire:

Enregistrer un commentaire