Spring 引导和 JBoss 作为 7.1.1

Spring Boot and JBoss As 7.1.1

版本 Spring Boot 1.3.3 版本和 JBoss AS 7.1.1

我正在尝试在 JBoss AS 7.1.1 中将 spring 引导应用程序部署为 war,我正在使用 JPA spring 引导 api。当 war 部署时,它无法成功部署并抛出如下错误。

我预计 class 加载存在一些问题。 JBoss 开箱即用 JPA2.0,但 spring 引导解决了对 JPA 2.1 的依赖性。是否有人使用最新的 Spring 启动在 JBOSS 上部署了他们的应用程序?请帮助解决这个问题。

====错误======================================== 13=]

> 01:14:14,945 INFO 
> [org.springframework.boot.context.embedded.FilterRegistrationBean]
> (MSC service thread 1-1) Mapping filter: 'hiddenHttpMethodFilter' to:
> [/*] 01:14:14,957 INFO 
> [org.springframework.boot.context.embedded.FilterRegistrationBean]
> (MSC service thread 1-1) Mapping filter: 'httpPutFormContentFilter'
> to: [/*] 01:14:14,968 INFO 
> [org.springframework.boot.context.embedded.FilterRegistrationBean]
> (MSC service thread 1-1) Mapping filter: 'requestContextFilter' to:
> [/*] 01:14:17,197 INFO 
> [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]
> (MSC service thread 1-1) Building JPA container EntityManagerFactory
> for persistence unit 'default' 01:14:19,520 WARN 
> [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext]
> (MSC service thread 1-1) Exception encountered during context
> initialization - cancelling r efresh attempt:
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'entityManagerFactory' defined in class path
> resource [com/caiso/settlements/api/SettlementsServi ceConfig.class]:
> Invocation of init method failed; nested exception is
> java.lang.NoSuchMethodError:
> javax.persistence.Table.indexes()[Ljavax/persistence/Index;
> 01:14:19,595 ERROR [org.springframework.boot.SpringApplication] (MSC
> service thread 1-1) Application startup failed:
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with n ame 'entityManagerFactory' defined in class path
> resource [com/caiso/settlements/api/SettlementsServiceConfig.class]:
> Invocation of init method failed; nested exception is
> java.lang.NoSuchMethodError: 
> javax.persistence.Table.indexes()[Ljavax/persistence/Index;
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
> [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829)
> [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
> [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:149)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:129)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85)
> [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
>         at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
> [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.jboss.as.web.deployment.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:148)
> [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
>         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115)
> [jbossweb-7.0.13.Final.jar:]
>         at org.apache.catalina.core.StandardContext.start(StandardContext.java:3845)
> [jbossweb-7.0.13.Final.jar:]
>         at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
> [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
>         at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
>         at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [rt.jar:1.7.0_71]
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [rt.jar:1.7.0_71]
>         at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71] Caused by: java.lang.NoSuchMethodError:
> javax.persistence.Table.indexes()[Ljavax/persistence/Index;
>         at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:973)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.perform(EntityManagerFactoryBuilderImpl.java:857)
> [hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.perform(EntityManagerFactoryBuilderImpl.java:850)
> [hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
> [hibernate-core-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
> [hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
>         at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
> [hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
>         at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
> [spring-orm-4.2.5.RELEASE.jar:4.2.5.RELE ASE]
>         at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)
> [spring-orm-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
> [spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
>         ... 26 more

我能够通过使用依赖管理的maven 功能来控制hibernate 版本和JPA2.0 版本。在依赖管理部分,如果我们想使用 JBoss AS 7.1.1

中可用的开箱即用的 jpa 和 hibernate,我确保包含以下内容
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.hibernate.common</groupId>
                <artifactId>hibernate-commons-annotations</artifactId>
                <version>4.0.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>4.0.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>4.0.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
                <version>1.0.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>4.2.0.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>
                    hibernate-validator-annotation-processor
                </artifactId>
                <version>4.1.0.Final</version>
            </dependency>
        </dependencies>
    </dependencyManagement>