使用JNDI连接的Grails 3.1.1部署

时间:2016-10-25 04:44:35

标签: tomcat grails jndi

我正在使用grails 3.1.1,我试图用这样的jndi连接配置我的应用程序..我在日志中看到,说

25-Oct-2016 11:41:03.764 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8090] 25-Oct-2016 11:41:03.770 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009] 25-Oct-2016 11:41:03.771 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 36712 ms

Like this

因为我使用的是tomcat 8,所以我的代码就像这样

package accounter

import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.jndi.JndiObjectFactoryBean;

class Application extends GrailsAutoConfiguration {
    static void main(String[] args) {
        GrailsApp.run(Application, args)
    }


    @Bean(destroyMethod="")
    public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
        JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
        bean.setJndiName("java:comp/env/jdbc/akyDS");
        bean.setProxyInterface(DataSource.class);
        bean.setLookupOnStartup(false);
        bean.afterPropertiesSet();
        return (DataSource)bean.getObject();
    }
}

然后在context.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

    <Resource name="jdbc/akyDS"
                auth="Container"
                type="javax.sql.DataSource"
                maxIdle="25"
                minIdle="5"
                initialSize="5"
                validationQuery="SELECT 1"
                timeBetweenEvictionRunsMillis="60000"
                minEvictableIdleTimeMillis="60000"
                username="root"
                password="root"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost:3306/accounter?autoReconnect=true"
    />

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

但是当我尝试运行我的tomcat时,我得到了这样的日志..

catalina log

但是当我访问localhost:8090/

时,我无法看到我的项目成功启动

将设置级别日志设置为DEBUG

时出现此错误
 initialSize=5; maxWait=10000; testOnBorrow=true; testOnReturn=false; timeBetwee
nEvictionRunsMillis=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=6
0000; testWhileIdle=true; testOnConnect=false; password=********; url=jdbc:mysql
://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding
=UTF-8; username=root; validationQuery=SELECT 1; validationQueryTimeout=3; valid
atorClassName=null; validationInterval=15000; accessToUnderlyingConnectionAllowe
d=true; removeAbandoned=false; removeAbandonedTimeout=60; logAbandoned=false; co
nnectionProperties=null; initSQL=null; jdbcInterceptors=ConnectionState; jmxEnab
led=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=60
0000; useLock=false; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alt
ernateUsernameAllowed=false; commitOnReturn=false; rollbackOnReturn=false; useDi
sposableConnectionFacade=true; logValidationErrors=false; propagateInterruptStat
e=false; ignoreExceptionOnPreLoad=false; }]]
DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager - Releasi
ng JDBC Connection [Lazy Connection proxy for target DataSource [org.apache.tomc
at.jdbc.pool.DataSource@2a6e9140{ConnectionPool[defaultAutoCommit=null; defaultR
eadOnly=false; defaultTransactionIsolation=2; defaultCatalog=null; driverClassNa
me=com.mysql.jdbc.Driver; maxActive=50; maxIdle=25; minIdle=5; initialSize=5; ma
xWait=10000; testOnBorrow=true; testOnReturn=false; timeBetweenEvictionRunsMilli
s=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=60000; testWhileIdl
e=true; testOnConnect=false; password=********; url=jdbc:mysql://localhost:3306/
accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8; username=r
oot; validationQuery=SELECT 1; validationQueryTimeout=3; validatorClassName=null
; validationInterval=15000; accessToUnderlyingConnectionAllowed=true; removeAban
doned=false; removeAbandonedTimeout=60; logAbandoned=false; connectionProperties
=null; initSQL=null; jdbcInterceptors=ConnectionState; jmxEnabled=true; fairQueu
e=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=600000; useLock=fals
e; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alternateUsernameAllo
wed=false; commitOnReturn=false; rollbackOnReturn=false; useDisposableConnection
Facade=true; logValidationErrors=false; propagateInterruptState=false; ignoreExc
eptionOnPreLoad=false; }]] after transaction
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Conne
ction to DataSource

application.yml

中删除此代码后出现错误
dataSource:
    jndiName: java:comp/env/akyDS
#    pooled: true
#    jmxExport: true
#    driverClassName: com.mysql.jdbc.Driver
#    username: dddd
#    password: ddd@
#      username: ddddg
#        password: ddd@


#dataSource:
#        pooled: true
#        jmxExport: true
#        driverClassName: "oracle.jdbc.OracleDriver"
#        dialect: org.hibernate.dialect.Oracle10gDialect
#        username: "accounter"
#        password: "root"

environments:
    development:
        dataSource:
            dbCreate: update
#            url: jdbc:oracle:thin:@localhost:1521:xe
            url: jdbc:mysql://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8

    test:
        dataSource:
            dbCreate: update
#            url: jdbc:oracle:thin:@localhost:1521:accounter
            url: jdbc:mysql://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
    production:
        dataSource:
            dbCreate: update
#            url: jdbc:oracle:thin:@localhost:1521:accounter
#            jndiName: java:comp/env/akyDS
            url: jdbc:mysql://localhost:3306/accounter?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
            properties:
                jmxEnabled: true
                initialSize: 5
                maxActive: 50
                minIdle: 5
                maxIdle: 25
                maxWait: 10000
                maxAge: 600000
                timeBetweenEvictionRunsMillis: 5000
                minEvictableIdleTimeMillis: 60000
                validationQuery: SELECT 1
                validationQueryTimeout: 3
                validationInterval: 15000
                testOnBorrow: true
                testWhileIdle: true
                testOnReturn: false
                jdbcInterceptors: ConnectionState
                defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

删除此代码,之后我运行grails prod war,我再次尝试部署。

我收到此错误..

.java:724) [catalina.jar:8.5.6]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70
0) [catalina.jar:8.5.6]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
 [catalina.jar:8.5.6]
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
 [catalina.jar:8.5.6]
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:
1823) [catalina.jar:8.5.6]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1) [na:1.8.0_101]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_10
1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142) [na:1.8.0_101]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617) [na:1.8.0_101]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'transactionManager' defined in class path resource [org/sprin
gframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration
.class]: Bean instantiation via factory method failed; nested exception is org.s
pringframework.beans.BeanInstantiationException: Failed to instantiate [org.spri
ngframework.jdbc.datasource.DataSourceTransactionManager]: Factory method 'trans
actionManager' threw exception; nested exception is java.lang.IllegalArgumentExc
eption: Property 'dataSource' is required
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.4.RELEAS
E.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:11
23) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[sprin
g-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans
-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4
.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEAS
E]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEA
SE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:202) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.grails.transaction.TransactionManagerPostProcessor.initialize(Tra
nsactionManagerPostProcessor.java:75) ~[grails-core-3.1.1.jar:3.1.1]
        at org.grails.transaction.TransactionManagerPostProcessor.setBeanFactory
(TransactionManagerPostProcessor.java:53) ~[grails-core-3.1.1.jar:3.1.1]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597) ~[sprin
g-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565) ~[spring-be
ans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans
-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        ... 29 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to insta
ntiate [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Facto
ry method 'transactionManager' threw exception; nested exception is java.lang.Il
legalArgumentException: Property 'dataSource' is required
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.4.RELEASE.
jar:4.2.4.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.4.RELEAS
E.jar:4.2.4.RELEASE]
        ... 42 common frames omitted
Caused by: java.lang.IllegalArgumentException: Property 'dataSource' is required

        at org.springframework.jdbc.datasource.DataSourceTransactionManager.afte
rPropertiesSet(DataSourceTransactionManager.java:167) ~[spring-jdbc-4.2.4.RELEAS
E.jar:4.2.4.RELEASE]
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.<ini
t>(DataSourceTransactionManager.java:124) ~[spring-jdbc-4.2.4.RELEASE.jar:4.2.4.
RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration.transactionManager(DataSourceTransactionManagerAutoConfigur
ation.java:56) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.CGLIB$transactionManager$0
(<generated>) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5$$FastClassBySpringCGLIB$$6
2dee341.invoke(<generated>) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.
RELEASE]
        at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.j
ava:228) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.context.annotation.ConfigurationClassEnhancer$Bea
nMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355) ~[spring-conte
xt-4.2.4.RELEASE.jar:4.2.4.RELEASE]
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.transactionManager(<genera
ted>) ~[spring-boot-autoconfigure-1.3.2.RELEASE.jar:1.3.2.RELEASE]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.
0_101]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62) ~[na:1.8.0_101]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43) ~[na:1.8.0_101]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.4.RELEASE.
jar:4.2.4.RELEASE]
        ... 43 common frames omitted
26-Oct-2016 16:35:15.533 SEVERE [localhost-startStop-1] org.apache.catalina.core
.ContainerBase.addChildInternal ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngi
ne[Catalina].StandardHost[localhost].StandardContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:724)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70
0)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)

        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)

        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:
1823)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        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)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'transactionManagerPostProcessor': Initialization of bean fail
ed; nested exception is org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'transactionManager' defined in class path resour
ce [org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAuto
Configuration.class]: Bean instantiation via factory method failed; nested excep
tion is org.springframework.beans.BeanInstantiationException: Failed to instanti
ate [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Factory
method 'transactionManager' threw exception; nested exception is java.lang.Illeg
alArgumentException: Property 'dataSource' is required
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:202)
        at org.springframework.context.support.PostProcessorRegistrationDelegate
.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:207)
        at org.springframework.context.support.AbstractApplicationContext.regist
erBeanPostProcessors(AbstractApplicationContext.java:687)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:523)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.refresh(EmbeddedWebApplicationContext.java:118)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:766)
        at org.springframework.boot.SpringApplication.createAndRefreshContext(Sp
ringApplication.java:361)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java
:307)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:55)
        at org.springframework.boot.context.web.SpringBootServletInitializer.run
(SpringBootServletInitializer.java:149)
        at org.grails.boot.context.web.GrailsAppServletInitializer.createRootApp
licationContext(GrailsAppServletInitializer.groovy:57)
        at org.springframework.boot.context.web.SpringBootServletInitializer.onS
tartup(SpringBootServletInitializer.java:85)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(S
pringServletContainerInitializer.java:175)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:5178)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'transactionManager' defined in class path resource [org/sprin
gframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration
.class]: Bean instantiation via factory method failed; nested exception is org.s
pringframework.beans.BeanInstantiationException: Failed to instantiate [org.spri
ngframework.jdbc.datasource.DataSourceTransactionManager]: Factory method 'trans
actionManager' threw exception; nested exception is java.lang.IllegalArgumentExc
eption: Property 'dataSource' is required
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:599)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:11
23)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:202)
        at org.grails.transaction.TransactionManagerPostProcessor.initialize(Tra
nsactionManagerPostProcessor.java:75)
        at org.grails.transaction.TransactionManagerPostProcessor.setBeanFactory
(TransactionManagerPostProcessor.java:53)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        ... 29 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to insta
ntiate [org.springframework.jdbc.datasource.DataSourceTransactionManager]: Facto
ry method 'transactionManager' threw exception; nested exception is java.lang.Il
legalArgumentException: Property 'dataSource' is required
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:189)
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:588)
        ... 42 more
Caused by: java.lang.IllegalArgumentException: Property 'dataSource' is required

        at org.springframework.jdbc.datasource.DataSourceTransactionManager.afte
rPropertiesSet(DataSourceTransactionManager.java:167)
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.<ini
t>(DataSourceTransactionManager.java:124)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration.transactionManager(DataSourceTransactionManagerAutoConfigur
ation.java:56)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.CGLIB$transactionManager$0
(<generated>)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5$$FastClassBySpringCGLIB$$6
2dee341.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.j
ava:228)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$Bea
nMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionMana
gerAutoConfiguration$$EnhancerBySpringCGLIB$$ec1411b5.transactionManager(<genera
ted>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:162)
        ... 43 more

26-Oct-2016 16:35:15.535 SEVERE [localhost-startStop-1] org.apache.catalina.star
tup.HostConfig.deployWAR Error deploying web application archive C:\apache-tomca
t-8.5.6\webapps\ROOT.war
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.cata
lina.LifecycleException: Failed to start component [StandardEngine[Catalina].Sta
ndardHost[localhost].StandardContext[]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:728)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:70
0)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)

        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)

        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:
1823)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        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)

26-Oct-2016 16:35:15.537 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deployment of web application archive C:\apache-tomcat-8.
5.6\webapps\ROOT.war has finished in 48,325 ms
26-Oct-2016 16:35:15.539 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler [http-nio-8090]
26-Oct-2016 16:35:15.547 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler [ajp-nio-8009]
26-Oct-2016 16:35:15.548 INFO [main] org.apache.catalina.startup.Catalina.start
Server startup in 48378 ms

1 个答案:

答案 0 :(得分:0)

顶部的三个日志语句与此无关,而且是INFO语句,而不是错误。

您显示的其他输出同样不是错误,它告诉您(连同一堆配置设置)它已完成一些MySQL连接并将它们返回到连接池,正好< / em>使用连接池时要查看的内容。它将数据库的URL显示为jdbc:mysql://localhost:3306/accounter?autoReconnect=true,这是您在context.xml中配置的数据源中显示的内容。

省略所有连接细节,基本上说

Releasing JDBC Connection ... after transaction
Returning JDBC Connection to DataSource

这里没有任何内容表明您可能无法从浏览器访问您的应用程序,但就数据库连接而言,一切看起来都不错。