1

我正在尝试基于博客http://blog.cloudfoundry.org/2012/06/18/deploying-tomcat-7-using-the-standalone-framework/ 将tomcat 7.0 Web 应用程序部署为独立应用程序-sql 服务。虽然此应用程序在没有服务的情况下运行良好,但当我将 MySQL 服务绑定到该应用程序时,服务器无法启动。以下是我在服务器启动时遇到的异常:

 Mar 22, 2013 8:03:49 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: contextInitialized()
 Mar 22, 2013 8:03:49 AM org.apache.catalina.core.ApplicationContext log
 INFO: SessionListener: contextInitialized()
 Mar 22, 2013 8:03:49 AM org.apache.catalina.core.ApplicationContext log
 INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCa
 che', 'org.apache.jasper.compiler.TldLocationsCache@2fe6e305')
 Mar 22, 2013 8:03:49 AM org.apache.catalina.core.ApplicationContext log
 INFO: Set web app root system property: 'webapp.root' = [/var/vcap/data/dea/apps
 /log-app-0-0466f9837a2ada3db95aef1b77a78787/app/webapps/ROOT/]
 Mar 22, 2013 8:03:49 AM org.apache.catalina.core.ApplicationContext log
 INFO: Initializing Spring root WebApplicationContext
 Mar 22, 2013 8:03:50 AM org.apache.catalina.core.StandardContext listenerStart
 SEVERE: Exception sending context initialized event to listener instance of clas
 s org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.BeanCreationException: Error creating bean wit
 h name 'mysql1': Invocation of init method failed; nested exception is java.lang
 .NullPointerException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
 Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
 Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
 Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
 ject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
 y.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
 an(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
 (AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.
 preInstantiateSingletons(DefaultListableBeanFactory.java:563)
    at org.springframework.context.support.AbstractApplicationContext.finish
 BeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refres
 h(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationCon
 text(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationConte
 xt(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitiali
 zed(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
 t.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContex
 t.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
 .java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
 7)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
 a:1114)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig
 .java:1673)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44
1)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
 utor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
 .java:908)
    at java.lang.Thread.run(Thread.java:662)
 **Caused by: java.lang.NullPointerException
    at org.cloudfoundry.runtime.env.CloudEnvironment.getServiceInfo(CloudEnv
 ironment.java:150)**
    at org.cloudfoundry.runtime.service.AbstractCloudServiceFactory.createIn
 stance(AbstractCloudServiceFactory.java:54)
    at org.springframework.beans.factory.config.AbstractFactoryBean.afterPro
 pertiesSet(AbstractFactoryBean.java:130)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
 Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBean
 Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 26 more
 Mar 22, 2013 8:03:50 AM org.apache.catalina.core.ApplicationContext log
 INFO: Closing Spring root WebApplicationContext
 Mar 22, 2013 8:03:50 AM org.apache.catalina.core.ApplicationContext log
 INFO: Shutting down log4j

这是使用获取的 localhost 日志

 vmc files log-app app/logs/localhost.2013-03-22.log

非常感谢有关此问题的任何帮助和见解。

另外,我想补充一点,我在推送期间将服务绑定到应用程序。这是 vmc app log-app 命令的结果:

C:\Users\kinjal.doshi\apache-tomcat-7.0.35>vmc app log-app log-app: running platform: Standalone on java usage: 256M x 1 instance urls: log-app.cloudfoundry.com services: mysql -2

4

1 回答 1

0

我已经能够解决这个问题。只需将mysql连接器jar添加到tomcat 7.0 lib文件夹

于 2013-04-17T09:00:28.413 回答