2017-03-18 117 views
0

我得到這個錯誤時openshift JBoss服務器上建立自己的應用程序7.OpenShift與JBOSS服務器7.1.1.Final java.lang.NoSuchMethodError:javax.persistence.JoinColumn.foreignKey()Ljavax /持久/ ForeignKey的;

2017/03/17 22:02:37,944 WARN [org.springframework.context.support.ClassPathXmlApplicationContext] (MSC service thread 1-5) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [hibernate-bean.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey; 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834) [spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) [spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) [spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) [spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at com.vietcamthai.services.model.dao.HibernateUtil.<clinit>(HibernateUtil.java:17) [classes:] 
    ..... 
Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey; 
     at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2888) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.cfg.AnnotationBinder.bindOneToOne(AnnotationBinder.java:3065) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1791) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:904) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:731) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) [hibernate-core-5.0.2.Final.jar:5.0.2.Final] 
     at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:416) [spring-orm-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:401) [spring-orm-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) [spring-beans-4.2.1.RELEASE.jar:4.2.1.RELEASE] 
     ... 42 more 
.... 
2017/03/17 22:02:37,964 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-5) Skipped installing application listeners due to previous error(s) 
2017/03/17 22:02:37,964 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Error listenerStart 
2017/03/17 22:02:37,965 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Context [] startup failed due to previous errors 
2017/03/17 22:02:37,972 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.web.deployment.default-host./ROOT: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ROOT: JBAS018040: Failed to start context 
     at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95) 
     at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] 
     at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_131] 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_131] 
     at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_131] 
2017/03/17 22:02:38,022 INFO [org.jboss.as] (MSC service thread 1-1) JBAS015951: Admin console listening on http://127.7.170.129:9990 
2017/03/17 22:02:38,023 ERROR [org.jboss.as] (MSC service thread 1-1) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 52973ms - Started 428 of 549 services (2 services failed or missing dependencies, 116 services are passive or on-demand) 
2017/03/17 22:02:38,179 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ROOT.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ROOT" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ROOT: JBAS018040: Failed to start context"}} 
2017/03/17 22:02:38,180 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report 
JBAS014777: Services which failed to start:  service jboss.web.deployment.default-host./ROOT: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ROOT: JBAS018040: Failed to start context 
2017/03/17 22:02:38,190 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ROOT" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ROOT: JBAS018040: Failed to start context"}}}} 
2017/03/17 22:02:38,447 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment ROOT.war in 266ms  

和我的pom.xml文件是:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>database</groupId> 
    <artifactId>database</artifactId> 
    <packaging>war</packaging> 
    <version>1.0</version> 
    <name>database</name> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.6</maven.compiler.source> 
     <maven.compiler.target>1.6</maven.compiler.target> 
     <org.springframework-version>4.2.1.RELEASE</org.springframework-version> 
     <org.aspectj-version>1.6.10</org.aspectj-version> 
     <org.slf4j-version>1.6.6</org.slf4j-version> 
     <jackson.databind-version>2.2.3</jackson.databind-version> 
     <hibernate-version>5.0.2.Final</hibernate-version> 
    </properties> 

    <repositories> 
     <repository> 
      <id>JBoss repository</id> 
      <url>http://repository.jboss.com/maven2/</url> 
     </repository> 
    </repositories> 

    <dependencies> 
     <!-- <dependency> --> 
     <!-- <groupId>org.jboss.spec</groupId> --> 
     <!-- <artifactId>jboss-javaee-6.0</artifactId> --> 
     <!-- <version>1.0.0.Final</version> --> 
     <!-- <type>pom</type> --> 
     <!-- <scope>provided</scope> --> 
     <!-- </dependency> --> 

     <!-- Jackson --> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
      <version>${jackson.databind-version}</version> 
     </dependency> 

     <!-- Spring --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${org.springframework-version}</version> 
      <exclusions> 
       <!-- Exclude Commons Logging in favor of SLF4j --> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context-support</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${org.springframework-version}</version> 
     </dependency> 

     <!-- AspectJ --> 
     <dependency> 
      <groupId>org.aspectj</groupId> 
      <artifactId>aspectjrt</artifactId> 
      <version>${org.aspectj-version}</version> 
     </dependency> 

     <!-- Logging --> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>${org.slf4j-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>jcl-over-slf4j</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>${org.slf4j-version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.15</version> 
      <exclusions> 
       <exclusion> 
        <groupId>javax.mail</groupId> 
        <artifactId>mail</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>javax.jms</groupId> 
        <artifactId>jms</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jdmk</groupId> 
        <artifactId>jmxtools</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>com.sun.jmx</groupId> 
        <artifactId>jmxri</artifactId> 
       </exclusion> 
      </exclusions> 
      <scope>runtime</scope> 
     </dependency> 

     <!-- @Inject --> 
     <dependency> 
      <groupId>javax.inject</groupId> 
      <artifactId>javax.inject</artifactId> 
      <version>1</version> 
     </dependency> 

     <!-- Servlet --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <!-- Test --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.7</version> 
      <scope>test</scope> 
     </dependency> 

     <!-- MySQL database driver --> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.36</version> 
     </dependency> 

     <!-- Hibernate framework --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 

     <!-- for JPA, use hibernate-entitymanager instead of hibernate-core --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.hibernate.javax.persistence</groupId> 
      <artifactId>hibernate-jpa-2.1-api</artifactId> 
      <version>1.0.0.Final</version> 
     </dependency> 

     <!-- optional --> 

     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-osgi</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-envers</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-c3p0</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-proxool</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-infinispan</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-ehcache</artifactId> 
      <version>${hibernate-version}</version> 
     </dependency> 

     <!-- End Hibernate framework --> 


     <dependency> 
      <groupId>javax.persistence</groupId> 
      <artifactId>persistence-api</artifactId> 
      <version>1.0</version> 
     </dependency> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib</artifactId> 
      <version>2.2</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.transaction</groupId> 
      <artifactId>transaction-api</artifactId> 
      <version>1.1-rev-1</version> 
     </dependency> 

     <!-- Hibernate library dependecy start --> 
     <dependency> 
      <groupId>dom4j</groupId> 
      <artifactId>dom4j</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
      <version>1.1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-collections</groupId> 
      <artifactId>commons-collections</artifactId> 
      <version>3.2.1</version> 
     </dependency> 
     <dependency> 
      <groupId>antlr</groupId> 
      <artifactId>antlr</artifactId> 
      <version>2.7.7</version> 
     </dependency> 

     <!-- Common codec --> 
     <dependency> 
      <groupId>commons-codec</groupId> 
      <artifactId>commons-codec</artifactId> 
      <version>1.10</version> 
     </dependency> 



    </dependencies> 
    <profiles> 
     <profile> 
      <!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. --> 
      <!-- Use this profile for any OpenShift specific customization your app will need. --> 
      <!-- By default that is to put the resulting archive into the 'deployments' folder. --> 
      <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html --> 
      <id>openshift</id> 
      <build> 
       <finalName>database</finalName> 
       <plugins> 
        <plugin> 
         <artifactId>maven-eclipse-plugin</artifactId> 
         <version>2.9</version> 
         <configuration> 
          <additionalProjectnatures> 
           <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> 
          </additionalProjectnatures> 
          <additionalBuildcommands> 
           <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> 
          </additionalBuildcommands> 
          <downloadSources>true</downloadSources> 
          <downloadJavadocs>true</downloadJavadocs> 
         </configuration> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-compiler-plugin</artifactId> 
         <version>2.5.1</version> 
         <configuration> 
          <source>1.6</source> 
          <target>1.6</target> 
          <compilerArgument>-Xlint:all</compilerArgument> 
          <showWarnings>true</showWarnings> 
          <showDeprecation>true</showDeprecation> 
         </configuration> 
        </plugin> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>exec-maven-plugin</artifactId> 
         <version>1.2.1</version> 
         <configuration> 
          <mainClass>org.test.int1.Main</mainClass> 
         </configuration> 
        </plugin> 

        <plugin> 
         <artifactId>maven-war-plugin</artifactId> 
         <version>2.1.1</version> 
         <configuration> 
          <outputDirectory>deployments</outputDirectory> 
          <warName>ROOT</warName> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 
</project> 

,當我在關鍵的運行我的代碼可以正常使用的工具套件。 但它出現在OpenShift的JBOSS 7錯誤。我也嘗試使用JBOSS 6服務器,但它仍然有相同的錯誤。

我試着在谷歌搜索很多很多次,看到了同樣的錯誤,但我想盡解決方案,我仍然沒有工作在互聯網上找到。

回答

0

我嘗試了很多方法,我在網上和錯誤上看到我時其部署使用JBoss 7服務器openshift仍會發生。所以我嘗試的最終解決方案是使用Wildfly 10.並且我的代碼完美工作。

如果有人使用openshift和jboss7作爲服務器時具有相同的錯誤我,嘗試使用其他服務器一樣wildfly 10.支持java-EE-7和JDK-8還

相關問題