2014-10-16 2 views
1

У меня есть классы сущностей JPA, которые находятся в модуле Wildfly. Хотя в этом модуле есть классы сущностей, в модуле нет дескриптора развертывания JPA (файл persistence.xml). Вот полный путь модуля:Класс сущности JPA, находящийся в модуле Wildfly, не отсканирован

{Wildfly_installation}/modules/system/layers/base/br/edu/ufca/main/ufca.jar 

Дескриптор модуля (находится в той же папке):

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns="urn:jboss:module:1.3" name="br.edu.ufca"> 
    <resources> 
     <resource-root path="ufca.jar"/> 
    </resources> 

    <dependencies> 
     <module name="javax.faces.api"/> 
    </dependencies> 
</module> 

Теперь у меня есть веб-приложение, в котором я объявляю зависимость от этого модуля в мета- INF \ MANIFEST.MF:

Manifest-Version: 1.0 
Class-Path: 
Dependencies: br.edu.ufca export 

у меня также есть, в веб-приложении, файл persistence.xml где я перечислю некоторые классы сущностей, которые расположены в ufca.jar модуле:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence 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" version="2.1"> 
    <persistence-unit name="criacao-email"> 
     <jta-data-source>java:jboss/datasources/CriacaoEmailDS</jta-data-source> 

     <class>br.edu.ufca.modelo.Setor</class> 
     <!-- more classes --> 
    </persistence-unit> 
</persistence> 

Проблема заключается в том, что при запуске веб-приложения исполняемый код, который пытается загрузить некоторые классы сущностей, используя EntityManager, например, я получаю исключения, как это:

Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Setor is not mapped [SELECT s FROM Setor s ORDER BY s.nome] 
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final] 
    at org.jboss.as.jpa.container.AbstractEntityManager.createQuery(AbstractEntityManager.java:443) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_20] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_20] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_20] 
    at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_20] 
    at org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:401) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] 
    at org.jboss.weld.bean.builtin.CallableMethodHandler.invoke(CallableMethodHandler.java:42) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] 
    at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] 
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] 
    at org.jboss.weldx.persistence.EntityManager$911040993$Proxy$_$$_Weld$Proxy$.createQuery(Unknown Source) [hibernate-jpa-2.1-api-1.0.0.Final.jar:] 
    at br.edu.ufca.criacaoemail.negocio.CriadorEmailSetorial.localizarSetores(CriadorEmailSetorial.java:28) [classes:] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_20] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_20] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_20] 
    at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_20] 
    at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407) 
    at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) 
    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407) 
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23] 
    at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) [wildfly-weld-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) 
    at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:59) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] 
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) 
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final] 
    ... 122 more 
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Setor is not mapped [SELECT s FROM Setor s ORDER BY s.nome] 
    at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:96) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final] 
    ... 168 more 
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Setor is not mapped 
    at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:189) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:109) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:95) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:331) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3633) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3522) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) [hibernate-core-4.3.5.Final.jar:4.3.5.Final] 
    ... 176 more 

, который ясно показывает, что Поставщик JPA не просматривал классы сущностей. Но если я получаю доступ из веб-приложения к любому классу из модуля Wildfly без использования JPA, у меня есть успех, который показывает, что модуль действительно находится в пути к классам приложения.

Является ли это поведение по умолчанию или что я делаю неправильно?

Заранее спасибо.

Marcos

ответ

0

модули, определенные в каталоге модулей не являются частью развертывания и, следовательно, не сканируются. Если вам нужны ваши объекты для сканирования, они должны быть включены в ваше развертывание.

+0

Просто, чтобы убедиться: нет ли обходного пути? – Marcos

+0

Не то, чтобы я знал. Я не тестировал, но он может работать, если вы указали объекты в файле persistence.xml. Я не уверен, будут ли добавлены зависимости модулей до этой фазы или нет. –

+0

Вы можете увидеть в моем вопросе, что я с самого начала перечислил классы сущностей в файле persistence.xml. Это не сработало. – Marcos

Смежные вопросы