Spring 4,Websphere 8.5.5 上的 Hibernate JPA JarInputStreamBasedArchiveDescriptor 错误
Posted
技术标签:
【中文标题】Spring 4,Websphere 8.5.5 上的 Hibernate JPA JarInputStreamBasedArchiveDescriptor 错误【英文标题】:Spring 4, Hibernate JPA JarInputStreamBasedArchiveDescriptor Error on Websphere 8.5.5 【发布时间】:2014-07-09 10:17:47 【问题描述】:我有一个在 Websphere 8.5.5 Liberty Profile 上完美运行的 Spring MVC/Spring-Data-JPA(带有 Hibernate)应用程序。但是,当我部署到 Websphere 8.5.5 的完整版时。我在下面粘贴了错误。
我的其他 bean 自然依赖 EntityManagerFactory
,所以这让我很生气。一直在谷歌上搜索一整天都无济于事。
堆栈跟踪:
[5/20/14 19:29:14:800 EDT] 00000070 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [oceanEAR#ocean.war]:.Initializing Spring root WebApplicationContext
[5/20/14 19:29:14:801 EDT] 00000070 SystemOut O INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
[5/20/14 19:29:14:804 EDT] 00000070 SystemOut O INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue May 20 19:29:14 EDT 2014]; root of context hierarchy
[5/20/14 19:29:14:872 EDT] 00000070 SystemOut O INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Registering annotated classes: [class com.mycompany.myapp.config.AppConfig]
[5/20/14 19:29:15:276 EDT] 00000070 SystemOut O INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
[5/20/14 19:29:15:546 EDT] 00000070 SystemOut O WARN : org.hibernate.ejb.HibernatePersistence - HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
[5/20/14 19:29:15:737 EDT] 00000070 SystemOut O WARN : org.hibernate.jpa.boot.archive.internal.JarInputStreamBasedArchiveDescriptor - HHH015010: Unable to find file (ignored): bundleresource://130.fwk884063730/
java.lang.NullPointerException: in is null
at java.util.zip.ZipInputStream.<init>(ZipInputStream.java:75)
at java.util.jar.JarInputStream.<init>(JarInputStream.java:69)
at java.util.jar.JarInputStream.<init>(JarInputStream.java:55)
at org.hibernate.jpa.boot.archive.internal.JarInputStreamBasedArchiveDescriptor.visitArchive(JarInputStreamBasedArchiveDescriptor.java:73)
at org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:72)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:723)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:219)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:51)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:182)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:177)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:67)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:290)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at com.mycompany.myapp.config.AppConfig.entityManagerFactory(AppConfig.java:59)
at com.mycompany.myapp.config.AppConfig$$EnhancerBySpringCGLIB$$a99458c6.CGLIB$entityManagerFactory$1(<generated>)
at com.mycompany.myapp.config.AppConfig$$EnhancerBySpringCGLIB$$a99458c6$$FastClassBySpringCGLIB$$b6194988.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at com.mycompany.myapp.config.AppConfig$$EnhancerBySpringCGLIB$$a99458c6.entityManagerFactory(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:632)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:442)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:276)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1682)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:414)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1175)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:774)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplicationDynamically(ApplicationMgrImpl.java:1374)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2179)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$1.run(CompositionUnitMgrImpl.java:663)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5474)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5600)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:677)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.startCompositionUnit(CompositionUnitMgrImpl.java:621)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1266)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:69)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:272)
at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1148)
at java.security.AccessController.doPrivileged(AccessController.java:298)
at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30)
at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:41)
at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1142)
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:995)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:847)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:783)
at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1335)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1228)
at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
at com.ibm.ws.management.connector.ipc.CallRouter.route(CallRouter.java:247)
at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.doWork(IPCConnectorInboundLink.java:360)
at com.ibm.ws.management.connector.ipc.IPCConnectorInboundLink.ready(IPCConnectorInboundLink.java:132)
这是我的 AppConfig 类:
package com.mycompany.myapp.config;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup;
import org.springframework.orm.hibernate4.HibernateExceptionTranslator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaDialect;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages="com.mycompany.myapp.repository")
@ComponentScan(basePackages="com.mycompany.myapp.service", "com.mycompany.myapp.domain", "com.mycompany.myapp.transformer")
public class AppConfig
private static final Logger logger = LoggerFactory.getLogger(AppConfig.class);
@Bean
public AbstractPlatformTransactionManager transactionManager()
JpaTransactionManager txManager = new JpaTransactionManager();
EntityManagerFactory emf = entityManagerFactory();
txManager.setEntityManagerFactory(emf);
txManager.setDataSource(dataSource());
return txManager;
@Bean
public EntityManagerFactory entityManagerFactory()
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
//DATA SOURCE
DataSource ds = dataSource();
emf.setDataSource(ds);
//JPA VENDOR ADAPTER
logger.debug("About to create HibernateJpaVendorAdapter.");
HibernateJpaVendorAdapter jpaAdapter = new HibernateJpaVendorAdapter();
emf.setJpaVendorAdapter(jpaAdapter);
//PACKAGES TO SCAN
emf.setPackagesToScan("com.mycompany.myapp.domain", "com.mycompany.myapp.transformer.rule");
//JPA PROPERTIES
Properties jpaProps = new Properties();
jpaProps.put("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
jpaProps.put("hibernate.max_fetch_depth", 3);
jpaProps.put("hibernate.jdbc_fetch_size", 50);
jpaProps.put("hibernate.jdbc_batch_size", 10);
jpaProps.put("hibernate.show_sql", true);
jpaProps.put("hibernate.dynamic-update", true);
//https://hibernate.atlassian.net/browse/HHH-6962 TRYING TO AVOID HIBERNATE ERROR: HHH015010
jpaProps.put("hibernate.exclude-unlisted-classes", true);
emf.setJpaProperties(jpaProps);
emf.afterPropertiesSet();
logger.debug("JPA Property Map:");
for (Entry<String, Object> entry : emf.getJpaPropertyMap().entrySet())
logger.debug("ENTRY: " + entry.getKey() + "=" + entry.getValue().toString());
EntityManagerFactory entityManagerFactory = emf.getObject();
return entityManagerFactory;
@Bean
public DataSource dataSource()
final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
dsLookup.setResourceRef(true);
DataSource dataSource = dsLookup.getDataSource("jdbc/myapp");
return dataSource;
@Bean
public HibernateExceptionTranslator hibernateExceptionTranslator()
return new HibernateExceptionTranslator();
我对 Spring 和 JPA 采用全 JavaConfig 方法(即我没有 persistence.xml 文件。)。
我发现了以下问题,但它并没有解决我的情况:
JPA entities as a shareable jar not working in a WAR file unde Tomcat 7.0.27
有什么想法吗?
【问题讨论】:
您至少应该更改您的entityManagerFactory
方法以返回 LocalContainerEntityManagerFactoryBean
并且不要调用 afterPropertiesSet()
和 getObject()
因为这将由 Spring 处理。让我担心的是警告,因为它表明它找不到较新的休眠 4.3 类(根据您正在使用的帖子)。
我在类路径上有这两个类。我在几个地方读到这是Hibernate bug that was supposed to be fixed in the current version.。整个问题可能只是源于 but 仍然存在这一事实。希望有人知道。
根据hibernate.atlassian.net/browse/HHH-8625 上的cmets 以及hibernate.atlassian.net/browse/HHH-9141 仍然保持打开状态的事实使得这是一个休眠错误。因此,您可以忽略该备注并尝试 HHH-8625 中概述的解决方案。
你找到答案了吗?我逐步调试了调试器,发现 Hibernate JPA 正在尝试扫描丢失的 jar 文件。当我解码 bundleresource URL 时,它说它正在寻找: C:\IBM\WebSphere\AppServer\plugins\com.ibm.ws.runtime.gateway.jar 它没有找到它,只是抛出这个警告并继续。我想知道是否有办法告诉 Spring JPA 或 Hibernate 不要扫描完整的类路径?
嘿,Jeff,从未找到解决方案,退回到更传统的基于 xml 的配置并设法解决它。 :(
【参考方案1】:
试试下面的配置。
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages="com.mycompany.myapp.repository")
@ComponentScan(basePackages="com.mycompany.myapp.service", "com.mycompany.myapp.domain", "com.mycompany.myapp.transformer")
public class AppConfig
private static final Logger logger = LoggerFactory.getLogger(AppConfig.class);
@Bean
@Autowired
public PlatformTransactionManager transactionManager(EntityManagerFactory emf)
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory(emf);
txManager.setDataSource(dataSource());
return txManager;
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory()
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
//DATA SOURCE
emf.setDataSource(dataSource());
//JPA VENDOR ADAPTER
logger.debug("About to create HibernateJpaVendorAdapter.");
emf.setJpaVendorAdapter(jpaVendorAdapter()));
//PACKAGES TO SCAN
emf.setPackagesToScan("com.mycompany.myapp.domain", "com.mycompany.myapp.transformer.rule");
//JPA PROPERTIES
emf.setJpaProperties(jpaProperties());
return emf;
public Properties jpaProperties()
Properties jpaProps = new Properties();
jpaProps.put("hibernate.max_fetch_depth", 3);
jpaProps.put("hibernate.jdbc_fetch_size", 50);
jpaProps.put("hibernate.jdbc_batch_size", 10);
jpaProps.put("hibernate.dynamic-update", "true");
//https://hibernate.atlassian.net/browse/HHH-6962 TRYING TO AVOID HIBERNATE ERROR: HHH015010
jpaProps.put("hibernate.exclude-unlisted-classes", "true");
jpaProps.put("hibernate.archive.autodetection", "false");
return jpaProps;
@Bean
public JpaVendorAdapter jpaVendorAdapter()
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setShowSql(true);
adapter.setDatabasePlatform("org.hibernate.dialect.Oracle10gDialect");
return adapter;
@Bean
public DataSource dataSource()
final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
dsLookup.setResourceRef(true);
DataSource dataSource = dsLookup.getDataSource("jdbc/myapp");
return dataSource;
【讨论】:
几个问题: 1.PlatformTransactionManager.setEntityManagerFactory()
不接受LocalContainerEntityManagerFactoryBean
所以你必须打电话给getObject()
。在此之前,您必须致电afterPropertiesSet()
。 2. hibernate.archive.autodetection 接受一个字符串参数,所以false
不好。我试过给它一个空字符串,但问题仍然存在。除了默认为“class,hbm”link 之外,我还没有找到该选项的有效条目列表
糟糕,刚刚注意到您的 transactionManager
方法上的 @Autowired
。所以你可以忽略第一点。我会试试看。
EntityManagerFactory
自动装配到方法中,spring 负责调用 afterPropertiesSet()
和 getObject()
。所以不,你不需要调用这些方法。关于选项 2,您应该传入 "false"
。
有效值(用于启用)是 class
和/或 hbm
其他任何东西都会禁用它。如果您不指定它,则默认为class,hbm
。所以 false 会禁用任何东西。
这个配置对我有帮助。谢谢@M.Deinum!我想知道为什么它不是一个公认的答案。以上是关于Spring 4,Websphere 8.5.5 上的 Hibernate JPA JarInputStreamBasedArchiveDescriptor 错误的主要内容,如果未能解决你的问题,请参考以下文章
当会话在 websphere 中失效时,Spring 视图范围不会被破坏
Websphere 8.5.5 中的 Corba NameService 配置
监控:嵌入 websphere 8.5.5 的 Tivoli 性能查看器在几分钟后停止
静默部署 WebSphere Application Server V8.5.5.13 环境