Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Can't load properties when starting use tomcat7 + eclipse (4.2) #18

Closed
henryyan opened this issue Dec 31, 2012 · 1 comment
Closed

Can't load properties when starting use tomcat7 + eclipse (4.2) #18

henryyan opened this issue Dec 31, 2012 · 1 comment

Comments

@henryyan
Copy link

Untitled

When checked "Serve modules without publishing" can't start project, but uncheck is ok. why?

I need load a properties file, then add config in root-context.xml.

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

    <!-- Root Context: defines shared resources visible to all other web components -->
        <context:property-placeholder ignore-unresolvable="true"
            location="classpath*:/application.properties" />
</beans>

Full error log:

Jan 01, 2013 1:24:43 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/henryyan/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Jan 01, 2013 1:24:43 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:spring-mvc-showcase' did not find a matching property.
Jan 01, 2013 1:24:43 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context/Loader} Setting property 'useSystemClassLoaderAsParent' to 'false' did not find a matching property.
Jan 01, 2013 1:24:44 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 01, 2013 1:24:44 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 01, 2013 1:24:44 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 758 ms
Jan 01, 2013 1:24:44 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 01, 2013 1:24:44 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.29
Jan 01, 2013 1:24:45 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 01, 2013 1:24:45 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
01:24:45 [localhost-startStop-1] ContextLoader - Root WebApplicationContext: initialization started
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Initializing new StandardServletEnvironment
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [servletConfigInitParams] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [servletContextInitParams] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [jndiProperties] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
01:24:46 [localhost-startStop-1] XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 01 01:24:46 CST 2013]; root of context hierarchy
01:24:46 [localhost-startStop-1] StandardServletEnvironment - Replacing [servletContextInitParams] PropertySource with [servletContextInitParams]
01:24:46 [localhost-startStop-1] XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
01:24:46 [localhost-startStop-1] XmlWebApplicationContext - Bean factory for Root WebApplicationContext: org.springframework.beans.factory.support.DefaultListableBeanFactory@29e3889a: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0]; root of factory hierarchy
01:24:46 [localhost-startStop-1] PropertyPlaceholderConfigurer - Loading properties file from URL [file:/Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties]
01:24:46 [localhost-startStop-1] DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@29e3889a: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0]; root of factory hierarchy
01:24:46 [localhost-startStop-1] ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:125)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
... 16 more
Jan 01, 2013 1:24:46 AM 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.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: /Users/henryyan/tmp/spring-mvc-showcase/src/main/webapp/WEB-INF/classes/application.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:125)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
... 16 more

Jan 01, 2013 1:24:46 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 01, 2013 1:24:46 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [134] milliseconds.
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/spring-mvc-showcase] startup failed due to previous errors
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/docs
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/examples
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jan 01, 2013 1:24:46 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@3b15947b')
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/host-manager
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/manager
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/henryyan/work/tools/apache/tomcat/apache-tomcat-7.0.29-eclipse/webapps/ROOT
Jan 01, 2013 1:24:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 01, 2013 1:24:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 01, 2013 1:24:46 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2598 ms

@rstoyanchev
Copy link
Contributor

I'm not sure why it's not working. It looks like the properties file is not getting deployed, which could be an issue with the Eclipse WTP plugin or the Maven plugin if you're using it. I recommend checking the deployment directory to see if the properties file is there first and then work from there.

I am closing this issue as there isn't anything I can see that we can fix in the sample.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants