tomcat 7中CATALINA_OPTS的问题

时间:2015-01-19 07:10:46

标签: tomcat7

我正在尝试在catalina.bat文件中设置几个属性。

set "CATALINA_OPTS=-Denvironment.properties.location=D:\Office\IR\irEnvironmentProperties\environment.properties"

CATALINA_OPTS="%CATALINA_OPTS% -Dappconfig.dir=D:\Office\IR\IR\appconfig -Dappconfig.farm=dev -Dir.log.dir=D:\Office\IR\irlogs -Denvironment.properties.location=D:\Office\IR\irEnvironmentProperties\environment.properties"

rem set appconfig.dir=D:\Office\IR\IR\appconfig 
rem set appconfig.farm=dev
rem set ir.log.dir=D:\Office\IR\irlogs

以上是我尝试的所有组合,但我无法摆脱找不到 environment.properties 文件的问题。

在第一行,我也尝试删除周围的双引号。

目录路径是正确的我只需在浏览器或Windows运行提示符上粘贴路径即可访问正确的目录。

在tomcat中设置CATALINA_OPTS的正确方法是什么?如果可能的话,请指点我的初学者教程。

### EDIT ###

我在独立模式下有tomcat(下载了一个zip文件,没有Windows安装程序)。

堆栈跟踪:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'envPropertiesLoader' defined in class path resource [application-context.xml]: Cannot create inner bean 'util:properties#4589632c' of type [org.springframework.beans.factory.config.PropertiesFactoryBean] while setting bean property 'arguments'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'util:properties#4589632c': Invocation of init method failed; nested exception is java.io.FileNotFoundException: "D:\Office\IR\irEnvironmentProperties\environment.properties" (The filename, directory name, or volume label syntax is incorrect)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:649)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    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:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
    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:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
    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:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'util:properties#4589632c': Invocation of init method failed; nested exception is java.io.FileNotFoundException: "D:\Office\IR\irEnvironmentProperties\environment.properties" (The filename, directory name, or volume label syntax is incorrect)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
    ... 29 more
Caused by: java.io.FileNotFoundException: "D:\Office\IR\irEnvironmentProperties\environment.properties" (The filename, directory name, or volume label syntax is incorrect)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at java.io.FileInputStream.<init>(FileInputStream.java:101)
    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.PropertiesFactoryBean.createInstance(PropertiesFactoryBean.java:113)
    at org.springframework.beans.factory.config.PropertiesFactoryBean.createProperties(PropertiesFactoryBean.java:98)
    at org.springframework.beans.factory.config.PropertiesFactoryBean.afterPropertiesSet(PropertiesFactoryBean.java:69)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    ... 32 more

2 个答案:

答案 0 :(得分:1)

你从哪里设置这些变量...... 我认为第一个选项集(带双引号)应该有效...... 尝试将此变量添加到\ bin \ setenv.bat文件中的setenv.bat文件中... 或者,您也可以在startup.bat中指定它(如果您使用此脚本来管理tomcat

答案 1 :(得分:0)

  1. 设置环境变量(如CATALINA_OPTS)的建议位置是bin / setenv.bat文件,如RUNNING.txt中所述。

  2. 对于许多系统属性,可以在conf / catalina.properties文件中进行设置。其中列出的所有属性都在Tomcat引导时读取并传递给System.setProperty()。

    免责声明:虽然使用catalina.properties很方便,但推荐的方法是在CATALINA_OPTS和JAVA_OPTS中使用-D。

  3. 您可以尝试使用调试器运行, https://wiki.apache.org/tomcat/FAQ/Developing#Debugging

  4. 奇怪的是,错误消息是关于无效语法,而不是关于不存在的路径。是否可以使用简单的示例Java程序重现此消息?不存在的路径是否会产生不同的错误消息?

    如果你使用直线斜线&#39; /&#39;也许你会成功。而不是反斜杠。查看堆栈跟踪,一些API使用URL(FileURLConnection)。可能是直斜杠会更好。

    消息实际上可能是由底层操作系统提供的,而不是由Java代码提供的。如果是这样,它可能是OS提供的固定消息,作为对数字错误代码的解释。如果是这种情况,当使用某些特定的数字错误代码时,其文本可能会努力覆盖所有情况。 (只是猜测)