当我尝试启动以下持久性单元
时<persistence-unit name="Cibet" transaction-type="JTA">
<jta-data-source>java:/CibetDS</jta-data-source>
<jar-file>lib/cibet-1.5.jar</jar-file>
</persistence-unit>
在JBoss-eap-6.1中我得到:
ERROR 18:32:24,158 -MSC000001: Failed to start service jboss.persistenceunit."cibetArq1.war#Cibet": org.jboss.msc.service.StartException in service jboss.persistenceunit."cibetArq1.war#Cibet": java.lang.NoClassDefFoundError: org/apache/shiro/mgt/DefaultSecurityManager
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.NoClassDefFoundError: org/apache/shiro/mgt/DefaultSecurityManager
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
at org.jboss.as.jpa.classloader.TempClassLoader.findClass(TempClassLoader.java:79)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119)
at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:491)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:866)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:599)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:91)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
缺少的类在这样的一个类中使用:
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.subject.Subject;
public class CibetSecurityManager extends DefaultSecurityManager {
...
但是,CibetSecurityManager是可选的,只有当Shiro库真的在类路径上时才由应用程序使用。如果Shiro不在类路径中,则类加载器不应该尝试加载它。 现在似乎JBoss(或Hibernate,不确定)PersistenceUnit初始化过程试图加载它在jar中找到的所有类。
问题:我可以告诉JBoss / Hibernate在没有类加载jar中所有类的情况下找到@Entity注释类吗?在Tomee / OpenJpa中,这没有问题
感谢您的帮助
答案 0 :(得分:0)
如果其他所有方法都失败了,您可以通过添加:
在persistence.xml中明确列出所有实体类<class>my.example.package.ExampleEntity</class>
...
<exclude-unlisted-classes>true</exclude-unlisted-classes>
哪个应该避免实体扫描。我将查看源代码,看看你是否可以转过来并列出不类来扫描。