java 在Windows 10上运行的Tomcat/Spring webapp无法启动

mspsb9vt  于 2023-05-05  发布在  Java
关注(0)|答案(1)|浏览(178)

java/Tomcat/Spring上运行的ZKTeco BioSecurity(基于Web的访问控制应用程序)无法启动。
$PATH = C:\Program Files\BioSecurity\MainResource
从位于$PATH/tomcat/logs/的日志文件中,我看到以下错误:org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [applicationContext.xml]: Could not resolve placeholder 'datasource.driverClassName' in string value "${datasource.driverClassName}"
然而,我是java/Tomcat/Spring的新手,我似乎找不到有问题的“applicationContext.xml”文件。我在webapps web.xml文件中看到了“applicationcontext.xml”。

<listener>
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>

请参阅下面的日志:

  • /tomcat/logs/localhost.2023-05-04.log
May 04, 2023 12:46:17 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
May 04, 2023 12:46:17 PM org.apache.catalina.core.ApplicationContext log
INFO: excute WebFilterInitializer...
May 04, 2023 12:46:19 PM org.apache.catalina.core.ApplicationContext log
INFO: do init shiroFilter in WebApplicationInitializer
May 04, 2023 12:46:19 PM org.apache.catalina.core.ApplicationContext log
INFO: do init langSessionFilter in WebApplicationInitializer
May 04, 2023 12:46:19 PM org.apache.catalina.core.ApplicationContext log
INFO: do init OAuth2Filter in WebApplicationInitializer
May 04, 2023 12:46:19 PM org.apache.catalina.core.ApplicationContext log
INFO: do init OAuth2Filter in WebApplicationInitializer
May 04, 2023 12:46:19 PM org.apache.catalina.core.ApplicationContext log
INFO: do init CheckFilter in WebApplicationInitializer
May 04, 2023 12:46:19 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
May 04, 2023 12:46:29 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [applicationContext.xml]: Could not resolve placeholder 'datasource.driverClassName' in string value "${datasource.driverClassName}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'datasource.driverClassName' in string value "${datasource.driverClassName}"
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:223)
    at com.zk.common.util.PropertiesUtil.processProperties(PropertiesUtil.java:88)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:86)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:162)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:611)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5157)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5680)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1017)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:993)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1296)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2039)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'datasource.driverClassName' in string value "${datasource.driverClassName}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:259)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82)
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:208)
    ... 23 more

May 04, 2023 12:46:29 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
  • /tomcat/logs/commons-daemon.2023-05-04.log
[2023-05-04 12:42:05] [info]  [ 6748] Stopping service...
[2023-05-04 12:42:06] [info]  [ 6748] Service stop thread completed.
[2023-05-04 12:42:07] [info]  [ 6008] Run service finished.
[2023-05-04 12:42:07] [info]  [ 6008] Commons Daemon procrun finished
[2023-05-04 12:45:57] [info]  [ 6688] Commons Daemon procrun (1.0.15.0 32-bit) started
[2023-05-04 12:45:57] [info]  [ 6688] Running 'BioSecurityTomcat' Service...
[2023-05-04 12:45:57] [info]  [ 2860] Starting service...
[2023-05-04 12:45:58] [info]  [ 2860] Service started in 1356 ms.
  • /tomcat/logs/biosecuritytomcat-stderr.2023-05-04.log
2023-05-04 12:45:57 Commons Daemon procrun stderr initialized
May 04, 2023 12:45:58 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded APR based Apache Tomcat Native library 1.2.16 using APR version 1.6.3.
May 04, 2023 12:45:58 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
May 04, 2023 12:45:59 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.2m  2 Nov 2017)
May 04, 2023 12:45:59 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8088"]
May 04, 2023 12:45:59 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8019"]
May 04, 2023 12:45:59 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1952 ms
May 04, 2023 12:45:59 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 04, 2023 12:45:59 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.88
May 04, 2023 12:45:59 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\BioSecurity\MainResource\tomcat\webapps\ROOT
May 04, 2023 12:46:17 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
May 04, 2023 12:46:17 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 04, 2023 12:46:29 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
May 04, 2023 12:46:29 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_Worker-10] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [DefaultQuartzScheduler_QuartzSchedulerThread] but has failed to stop it. This is very likely to create a memory leak.
May 04, 2023 12:46:29 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\Program Files\BioSecurity\MainResource\tomcat\webapps\ROOT has finished in 30,018 ms
May 04, 2023 12:46:29 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8088"]
May 04, 2023 12:46:29 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8019"]
May 04, 2023 12:46:29 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 30121 ms
May 04, 2023 12:46:30 PM org.apache.tomcat.util.http.parser.HttpParser <clinit>
WARNING: Character [[] is not allowed and will continue to be rejected.
May 04, 2023 12:46:30 PM org.apache.tomcat.util.http.parser.HttpParser <clinit>
WARNING: Character []] is not allowed and will continue to be rejected.
  • /tomcat/logs/biosecuritytomcat-stdout.2023-05-04.log保留此日志文件的内容,因为它是闲聊。如果需要,请让我知道,我会发布它。

我尝试重新启动应用程序并捕获日志。在那之后,我想不出如何解决它。

mum43rcc

mum43rcc1#

很明显您没有以spring的任何典型方式/位置定义该属性。如果你使用的是spring Boot ,你可以把它放在cli上(我建议不要像这样使用tomcat)。
解决这个问题的最简单方法是确保在捆绑到WAR中的项目的resources/目录中,包含具有以下值集的application.properties

datasource.driverClassName=org.mysql.Driver

不管你用的是什么数据库。显然,您还需要确保在项目中包含该驱动程序的依赖项,以便在构建WAR时包含它
如果您正确地完成了这一步,那么当您实际部署时,您会注意到在您的WEBAPPS/${YOUR_APP}中,您将在根目录中看到application.properties文件以及类文件。
这个应该可以了

相关问题