Spring引导,使用JaxB的ClassNotDef错误,包-Info.java

时间:2017-08-07 11:07:04

标签: java maven spring-mvc spring-boot jaxb

我在SpringBoot中使用AJSC框架和JaxB实现。我在项目外部构建了存根,并使用适当的目录将它们复制到项目中。

但是,在API执行期间,我收到classNotDef错误。但我已经看到了我的Jar文件,并且我在目录中有了package-info类文件。

Caused by: java.lang.NoClassDefFoundError: BOOT-INF/classes/com/att/fpp/fpprome/opportunity/package-info (wrong name: com/att/fpp/fpprome/opportunity/package-info)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl.classForName(StandardClassLoaderDelegateImpl.java:57)
    at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl$4.classForName(MetadataBuilderImpl.java:758)
    at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.packageForName(JavaReflectionManager.java:148)
    at org.hibernate.cfg.AnnotationBinder.bindPackage(AnnotationBinder.java:281)
    at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.prepare(AnnotationMetadataSourceProcessorImpl.java:186)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.prepare(MetadataBuildingProcess.java:156)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:253)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at acsi.grid.gridcore.core.sql.EntityManagerHelper.getDefaultEntityManager(EntityManagerHelper.java:250)
    at acsi.grid.gridcore.core.sql.EntityManagerHelper.getEntityManager(EntityManagerHelper.java:174)
    at acsi.grid.gridcore.core.JdbcGridBagImpl.getEntityManager(JdbcGridBagImpl.java:188)
    at acsi.grid.gridcore.core.JdbcGridBagImpl.put(JdbcGridBagImpl.java:163)
    at com.att.fpp.fpprome.dao.impl.OpportunityDaoImpl.updateOpportunityDatabaseROME(OpportunityDaoImpl.java:497)
    at com.att.fpp.fpprome.bo.impl.OpportunityBusinessObjectImpl.getOpptyInfo(OpportunityBusinessObjectImpl.java:78)
    at com.att.fpp.fpprome.service.impl.OpportunityServiceImpl.getOpportunitiesById(OpportunityServiceImpl.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)

另外我注意到我没有在pom的任何地方使用apache.cxf,但它在这里被调用。

2 个答案:

答案 0 :(得分:1)

NoClassDefFoundError类产生的package-info的可能解决方案:Spring boot, runnable jar can't load package-info.class

答案 1 :(得分:1)

发现了这个问题。 实现ADF(基于Hibernate的ORM)的AJSC框架不支持package-info,因此每次都会搜索该类。

唯一的办法是执行命令,以便在存根生成期间不生成package-info。

XJC 实用程序中使用-npa来取消打包信息,一切正常。