私は問題に直面した、この日の半分の間それをグーグルでした。何も私を助けることができませんでした。動いていた。しかし、その後、何かが起こり、私はそれをキャプチャしませんでした。
Tomcat Catalinaログはこちら
31-Jan-2016 00:35:27.278 INFO [RMI TCP Connection(2)-127.0.0.1] null.null HHH000412: Hibernate Core {5.0.7.Final}
31-Jan-2016 00:35:27.282 INFO [RMI TCP Connection(2)-127.0.0.1] null.null HHH000205: Loaded properties from resource hibernate.properties: {hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.bytecode.use_reflection_optimizer=false, hibernate.hbm2ddl.auto=update}
31-Jan-2016 00:35:27.283 INFO [RMI TCP Connection(2)-127.0.0.1] null.null HHH000021: Bytecode provider name : javassist
31-Jan-2016 00:35:27.376 INFO [RMI TCP Connection(2)-127.0.0.1] null.null HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
31-Jan-2016 00:35:28.170 INFO [RMI TCP Connection(2)-127.0.0.1] <unknown>.<unknown> HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
31-Jan-2016 00:35:29.632 INFO [RMI TCP Connection(2)-127.0.0.1] null.null HHH000228: Running hbm2ddl schema update
31-Jan-2016 00:35:30.331 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.Apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
31-Jan-2016 00:35:30.349 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.Apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
**31-Jan-2016 00:35:30.377 WARNING [RMI TCP Connection(2)-127.0.0.1] org.Apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.**
31-Jan-2016 00:35:32.709 INFO [localhost-startStop-1] org.Apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/Apache-Tomcat-8.0.24/webapps/manager
31-Jan-2016 00:35:32.907 INFO [localhost-startStop-1] org.Apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/Apache-Tomcat-8.0.24/webapps/manager has finished in 197 ms
ローカルホストログ
Java.lang.NoSuchMethodError: org.springframework.util.ReflectionUtils.clearCache()V
at org.springframework.context.support.AbstractApplicationContext.resetCommonCaches(AbstractApplicationContext.Java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:563)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.Java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.Java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.Java:107)
at org.Apache.catalina.core.StandardContext.listenerStart(StandardContext.Java:4727)
at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5167)
at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:150)
at org.Apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.Java:725)
at org.Apache.catalina.core.ContainerBase.addChild(ContainerBase.Java:701)
at org.Apache.catalina.core.StandardHost.addChild(StandardHost.Java:717)
at org.Apache.catalina.startup.HostConfig.manageApp(HostConfig.Java:1648)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:497)
at org.Apache.Tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.Java:300)
at com.Sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.Java:819)
at com.Sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.Java:801)
at org.Apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.Java:463)
at org.Apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.Java:413)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:497)
at org.Apache.Tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.Java:300)
at com.Sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.Java:819)
at com.Sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.Java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.Java:1466)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.Java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.Java:1307)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.Java:1399)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.Java:828)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:497)
at Sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.Java:323)
at Sun.rmi.transport.Transport$1.run(Transport.Java:200)
at Sun.rmi.transport.Transport$1.run(Transport.Java:197)
at Java.security.AccessController.doPrivileged(Native Method)
at Sun.rmi.transport.Transport.serviceCall(Transport.Java:196)
at Sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.Java:568)
at Sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.Java:826)
at Sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$254(TCPTransport.Java:683)
at Sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/2146013565.run(Unknown Source)
at Java.security.AccessController.doPrivileged(Native Method)
at Sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.Java:682)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at Java.lang.Thread.run(Thread.Java:745)
私のDatabaseConfig
@Configuration
@EnableJpaRepositories("cards.server.repository")
@EnableTransactionManagement
@ComponentScan(value = "cards.server")
@PropertySource({
"classpath:database.properties",
"classpath:hibernate.properties"}
)
public class DatabaseConfig extends IOException {
@Autowired
private Environment env;
@Bean(name = "entityManager")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan(env.getRequiredProperty("db.entity.package"));
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(getHibernateProperties());
return em;
}
@Bean(name = "dataSource")
public DataSource dataSource() {
BasicDataSource ds = new BasicDataSource();
ds.setUrl(env.getRequiredProperty("db.url"));
ds.setDriverClassName(env.getRequiredProperty("db.driver"));
ds.setUsername(env.getRequiredProperty("db.username"));
ds.setPassword(env.getRequiredProperty("db.password"));
ds.setInitialSize(Integer.valueOf(env.getRequiredProperty("db.initialSize")));
ds.setMinIdle(Integer.valueOf(env.getRequiredProperty("db.minIdle")));
ds.setMaxIdle(Integer.valueOf(env.getRequiredProperty("db.maxIdle")));
ds.setTimeBetweenEvictionRunsMillis(Long.valueOf(env.getRequiredProperty("db.timeBetweenEvictionRunsMillis")));
ds.setMinEvictableIdleTimeMillis(Long.valueOf(env.getRequiredProperty("db.minEvictableIdleTimeMillis")));
ds.setTestOnBorrow(Boolean.valueOf(env.getRequiredProperty("db.testOnBorrow")));
ds.setValidationQuery(env.getRequiredProperty("db.validationQuery"));
return ds;
}
@Bean(name = "transactionManager")
public PlatformTransactionManager platformTransactionManager() {
JpaTransactionManager manager = new JpaTransactionManager();
manager.setEntityManagerFactory(entityManagerFactory().getObject());
return manager;
}
public Properties getHibernateProperties() {
Properties properties = new Properties();
properties.getProperty(env.getProperty("hibernate.dialect"));
properties.getProperty(env.getProperty("hibernate.show_sql"));
properties.getProperty(env.getProperty("hibernate.hbm2ddl.auto"));
return properties;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cards.server</groupId>
<artifactId>cards.server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<!-- cmd + alt + v -->
<properties>
<spring-core.version>4.2.2.RELEASE</spring-core.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<spring-data-jpa.version>1.9.2.RELEASE</spring-data-jpa.version>
<hibernate-entitymanager.version>5.0.7.Final</hibernate-entitymanager.version>
<mysql-connector-Java.version>5.1.38</mysql-connector-Java.version>
<commons-dbcp2.version>2.1.1</commons-dbcp2.version>
<jta.version>1.1</jta.version>
<postgresql.version>9.1-901-1.jdbc4</postgresql.version>
<junit.version>4.12</junit.version>
<spring-webmvc.version>4.2.4.RELEASE</spring-webmvc.version>
<spring-test.version>4.1.6.RELEASE</spring-test.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-core.version}</version>
</dependency>
<!-- Web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-core.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-webmvc.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet-api.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>jstl</groupId>-->
<!--<artifactId>jstl</artifactId>-->
<!--<version>1.2</version>-->
<!--</dependency>-->
<!-- Database -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data-jpa.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate-entitymanager.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-Java</artifactId>
<version>${mysql-connector-Java.version}</version>
</dependency>
<dependency>
<groupId>org.Apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>${commons-dbcp2.version}</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>${jta.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>postgresql</groupId>-->
<!--<artifactId>postgresql</artifactId>-->
<!--<version>${postgresql.version}</version>-->
<!--</dependency>-->
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-test.version}</version>
</dependency>
</dependencies>
</project>
あなたの助けを願って、ありがとう。
さて、Java.lang.NoSuchMethodErrorは、pom.xmlで非互換バージョンを意味します
修正。 pom.xml:
<properties>
<spring-core.version>4.1.6.RELEASE</spring-core.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<spring-data-jpa.version>1.9.2.RELEASE</spring-data-jpa.version>
<hibernate-entitymanager.version>5.0.7.Final</hibernate-entitymanager.version>
<mysql-connector-Java.version>5.1.34</mysql-connector-Java.version>
<commons-dbcp2.version>2.1.1</commons-dbcp2.version>
<jta.version>1.1</jta.version>
<!--<postgresql.version>9.1-901-1.jdbc4</postgresql.version>-->
<junit.version>4.11</junit.version>
<spring-webmvc.version>4.1.6.RELEASE</spring-webmvc.version>
<spring-test.version>4.1.6.RELEASE</spring-test.version>
<jstl.version>1.2</jstl.version>
</properties>
私もこの問題に苦しんでいました。しかし、春のバージョンとJDKバージョンを変更すると、この問題は解決しました。だから、あなたのためにうまくいくかもしれません