3

JBoss にデプロイする Web サービス アプリがあります。1.4.0 にアップグレードした後、新しいクラス ProjectInfoAutoConfiguration に関するエラーが表示されます。

21:25:32,965 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 71) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration$$EnhancerBySpringCGLIB$$eeae8143]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration$$EnhancerBySpringCGLIB$$eeae8143.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482).....

これが私のConfigクラスです:

package com.xx.validation.service.config;

import java.util.Properties;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
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.jndi.JndiTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = "com.xx.validation.service")
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = "com.xx.validation.service.db")
public class ValidationServicesConfig {

     @Bean(name = "entityManagerFactory")
      public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
          final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
          em.setDataSource(getDataSourceXX());
          em.setPackagesToScan("com.xx.validation.service.db.domain");
          em.setJpaVendorAdapter(getVendorAdapter());
          em.setPersistenceUnitName( "ValidationServicesPU" );
          em.setJpaProperties(getJpaProperties());
          return em;
      }

      Properties getJpaProperties() {
          Properties properties = new Properties();
          properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
          properties.put("hibernate.show_sql", "false");
          return properties;
       }

      public JpaVendorAdapter getVendorAdapter() {
          HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
          vendorAdapter.setDatabase(Database.MYSQL);
          vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5Dialect");
          vendorAdapter.setShowSql(true);         
          return vendorAdapter;
      }

    @Bean
//  @Inject
    public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
        JpaTransactionManager tm = new JpaTransactionManager(entityManagerFactory);
        return tm;
    }

      @Bean(name = "dataSource")
      public DataSource getDataSourceXX() {

          try {
              JndiTemplate jndi = new JndiTemplate();
              return (DataSource) jndi.lookup("java:jboss/datasources/emailwsxaDS");
          } catch (Throwable t) {
              t.printStackTrace();
          }
          return null;
      }
}

そして私のservlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.2.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">

      <context:component-scan base-package="com.xx.validation" />

     <mvc:annotation-driven />

</beans>

Gradleを使用して構築しています。Spring Framework 4.2.5/Spring Boot 1.3.6 ではすべて正常に動作しますが、Framework 4.3.2/Spring Boot 1.4.0 では失敗します。

Gradle スクリプト:

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse'
// for local repository
apply plugin: 'maven'
// for xx-maven repository
apply plugin: 'maven-publish'


sourceCompatibility = 1.8
targetCompatibility = 1.8

group = 'com.xx'
version = '1.0.1.RELEASE'

// AWS_ACCESS_KEY and AWS_SECRET_KEY are properties in $HOME/.gradle/build.gradle
// Requires environment variable GRADLE_USER_HOME set to $HOME/.gradle

def accessKeyValue = AWS_ACCESS_KEY
def secretKeyValue = AWS_SECRET_KEY

repositories {
    mavenCentral()
    // AWS repository
     maven {
        url "s3://xx-maven/snapshot"
       credentials(AwsCredentials) {
             accessKey accessKeyValue
             secretKey secretKeyValue
            }
    mavenLocal()
}

compileJava {
// AWS repository
     maven {
        url "s3://xx-maven/snapshot"
       credentials(AwsCredentials) {
             accessKey accessKeyValue
             secretKey secretKeyValue
            }
     }
}

war {
    exclude 'WEB-INF/lib/*.jar' 
}


task sourceSetJavaProperties  {
       sourceSets {
           main {
               println "java.srcDirs = ${java.srcDirs}"
               println "resources.srcDirs = ${resources.srcDirs}"
               println "java.files = ${java.files.name}"
               println "allJava.files = ${allJava.files.name}"
               println "resources.files = ${resources.files.name}"
               println "allSource.files = ${allSource.files.name}"
               println "output.classesDir = ${output.classesDir}"
               println "output.resourcesDir = ${output.resourcesDir}"
               println "output.files = ${output.files}"
 //            println "access key = " + accessKeyValue
            } 
        }
}

configurations.all {
    // check for updates for xx jar files at every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
    compile("com.xx:PlatformCommon:1.0.3") { changing = true }
    compile("com.xx:ValidationCommon:1.0.4") { changing = true }

    compile 'com.amazonaws:amazon-sqs-java-messaging-lib:1.0.0'
    compile 'com.amazonaws:aws-java-sdk:1.10.57'
    compile 'org.springframework:spring-context:4.3.2.RELEASE'
    compile 'org.springframework:spring-core:4.3.2.RELEASE'

    compile 'org.springframework:spring-tx:4.3.2.RELEASE'
    compile 'org.springframework:spring-orm:4.3.2.RELEASE'
    compile 'org.springframework:spring-web:4.3.2.RELEASE'
    compile 'org.springframework:spring-webmvc:4.3.2.RELEASE'

    compile 'org.springframework.data:spring-data-jpa:1.10.2.RELEASE'

    compile 'org.springframework.boot:spring-boot:1.4.0.RELEASE'
    compile 'org.springframework.boot:spring-boot-autoconfigure:1.4.0.RELEASE'

    //compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0.api:1.0.1.Final'
    compile 'org.hibernate:hibernate-entitymanager:5.1.0.Final'
    compile 'org.hibernate:hibernate-java8:5.1.0.Final'
    compile 'org.hibernate:hibernate-gradle-plugin:5.1.0.Final'
    // https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-util
    // Avoids NoClassDefFoundError: org.apache.tomcat.util.res.StringManager
    compile group: 'org.apache.tomcat', name: 'tomcat-util', version: '8.5.4'

    compile 'javax.xml:jaxrpc-api:1.1'
    compile 'javax:javaee-api:7.0'
    compile 'joda-time:joda-time:2.4'
    compile 'org.jasypt:jasypt:1.9.2'

    //compile 'com.amazonaws:amazon-sqs-java-messaging-lib:1.0.0'
    //compile 'com.amazonaws:aws-java-sdk-sns:1.9.3'
    //compile 'com.amazonaws:aws-java-sdk-s3:1.10.58'

    compile 'org.apache.commons:commons-dbcp2:2.1.1'
    compile 'org.apache.logging.log4j:log4j-core:2.5'
    compile 'org.apache.axis:axis:1.4'

    compile 'com.sun.jersey:jersey-json:1.18'
    compile 'com.sun.jersey:jersey-client:1.18'
    compile 'redis.clients:jedis:2.8.0'
    compile 'org.apache.commons:commons-lang3:3.0'
    compile 'commons-io:commons-io:2.4'
    compile 'commons-fileupload:commons-fileupload:1.3.1'
    compile 'commons-validator:commons-validator:1.5.0'
    compile 'commons-discovery:commons-discovery:0.5'

    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

    // configurations {
    //  compile.exclude module: 'dom4j'
    //} 

     testCompile(
    ['junit:junit:4.11'],
    ['org.uncommons:reportng:1.1.4'],
    ['org.mockito:mockito-all:1.9.5'],
    ['org.easytesting:fest-assert-core:2.0M10'],
    ['org.springframework:spring-test:4.3.2.RELEASE'],
    // workaround for a known issue with TestNG 6.x: explicitly add Guice (Gradle will fail to run tests otherwise)
    ['com.google.inject:guice:3.0']
    )
}
// end::dependencies
}
4

0 に答える 0