java.lang.IllegalArgumentException介绍

解决Tomcat启动时因找不到指定目录而引发的异常问题,涉及server.xml中Context元素的docBase属性配置错误。

我现在遇到一个需要配置tomcat  server.xml来修正的找不到的问题:

如下:

[html]  view plain  copy
 print ?
  1. java.lang.IllegalArgumentException: Document base C:\Source\AirChina\AirChina_Portal\WebContent does not exist or is not a readable directory  
  2.     at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)  
  3.     at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4048)  
  4.     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4217)  
  5.     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)  
  6.     at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)  
  7.     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)  
  8.     at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)  
  9.     at org.apache.catalina.core.StandardService.start(StandardService.java:516)  
  10.     at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)  
  11.     at org.apache.catalina.startup.Catalina.start(Catalina.java:583)  
  12.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  13.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)  
  14.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  
  15.     at java.lang.reflect.Method.invoke(Method.java:597)  
  16.     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)  
  17.     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)  
  18. 2012-8-28 16:37:35 org.apache.catalina.core.StandardContext start  

以上异常很明显是 位置文件找不到。而且这是项目启动时候报出的。所以需要查看下 tomcat 配置文件。

以下为tomcat server 配置文件。注意配置:<Context path="/www" docBase="D:\AMR2\AirChina_Portal\WebContent"  privileged="true"/>

[html]  view plain  copy
 print ?
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!--  
  3.         Licensed to the Apache Software Foundation (ASF) under one or more  
  4.         contributor license agreements. See the NOTICE file distributed with  
  5.         this work for additional information regarding copyright ownership.  
  6.         The ASF licenses this file to You under the Apache License, Version  
  7.         2.0 (the "License"); you may not use this file except in compliance  
  8.         with the License. You may obtain a copy of the License at  
  9.         http://www.apache.org/licenses/LICENSE-2.0 Unless required by  
  10.         applicable law or agreed to in writing, software distributed under the  
  11.         License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  
  12.         CONDITIONS OF ANY KIND, either express or implied. See the License for  
  13.         the specific language governing permissions and limitations under the  
  14.         License.  
  15.     --><!--  
  16.         Note: A "Server" is not itself a "Container", so you may not define  
  17.         subcomponents such as "Valves" at this level. Documentation at  
  18.         /docs/config/server.html  
  19.     --><Server port="8005" shutdown="SHUTDOWN">  
  20.   
  21.     <!--APR library loader. Documentation at /docs/apr.html -->  
  22.     <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>  
  23.     <!--  
  24.         Initialize Jasper prior to webapps are loaded. Documentation at  
  25.         /docs/jasper-howto.html  
  26.     -->  
  27.     <Listener className="org.apache.catalina.core.JasperListener"/>  
  28.     <!--  
  29.         JMX Support for the Tomcat server. Documentation at  
  30.         /docs/non-existent.html  
  31.     -->  
  32.     <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>  
  33.     <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>  
  34.   
  35.     <!-- 
  36.         Global JNDI resources Documentation at /docs/jndi-resources-howto.html 
  37.     -->  
  38.     <GlobalNamingResources>  
  39.         <!--  
  40.             Editable user database that can also be used by UserDatabaseRealm to  
  41.             authenticate users  
  42.         -->  
  43.         <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>  
  44.      <!-- <Resource acquireIncrement="2" auth="Container" description="DB Connection" driverClass="oracle.jdbc.driver.OracleDriver" factory="org.apache.naming.factory.BeanFactory" jdbcUrl="jdbc:oracle:thin:@10.10.181.22:1521:TDP13ONLINE" maxPoolSize="10" minPoolSize="2" name="jdbc/edsmpdb" password="aceportal" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="airchina"-->      
  45.      <!-- <Resource acquireIncrement="2" auth="Container" description="DB Connection" driverClass="oracle.jdbc.driver.OracleDriver" factory="org.apache.naming.factory.BeanFactory" jdbcUrl="jdbc:oracle:thin:@10.10.124.14:1521:TDP13ONLINE" maxPoolSize="10" minPoolSize="2" name="jdbc/edsmpdb" password="aceusers" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="aceusers"/> -->   
  46.      <!--<Resource acquireIncrement="2" auth="Container" description="DB Connection" driverClass="oracle.jdbc.driver.OracleDriver" factory="org.apache.naming.factory.BeanFactory" jdbcUrl="jdbc:oracle:thin:@172.30.9.18:1521:TDP13ONLINE" maxPoolSize="10" minPoolSize="2" name="jdbc/edsmpdb" password="airchina" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="aceportal"/>-->  
  47.        
  48.      <Resource acquireIncrement="2" auth="Container" description="DB Connection" driverClass="oracle.jdbc.driver.OracleDriver" factory="org.apache.naming.factory.BeanFactory" jdbcUrl="jdbc:oracle:thin:@10.9.205.152:1521:TDP13ONLINE" maxPoolSize="10" minPoolSize="2" name="jdbc/edsmpdb" password="airchina" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="aceportal"/>  
  49.      <!--<Resource acquireIncrement="2" auth="Container" description="DB Connection" driverClass="oracle.jdbc.driver.OracleDriver" factory="org.apache.naming.factory.BeanFactory" jdbcUrl="jdbc:oracle:thin:@127.0.0.1:1521:orcl" maxPoolSize="10" minPoolSize="2" name="jdbc/edsmpdb" password="airport" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="airport"/>-->  
  50.     </GlobalNamingResources>  
  51.       
  52.   
  53.     <!--  
  54.         A "Service" is a collection of one or more "Connectors" that share a  
  55.         single "Container" Note: A "Service" is not itself a "Container", so  
  56.         you may not define subcomponents such as "Valves" at this level.  
  57.         Documentation at /docs/config/service.html  
  58.     -->  
  59.     <Service name="Catalina">  
  60.   
  61.         <!--  
  62.             The connectors can use a shared executor, you can define one or more  
  63.             named thread pools  
  64.         -->  
  65.         <!--  
  66.             <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"  
  67.             maxThreads="150" minSpareThreads="4"/>  
  68.         -->  
  69.   
  70.   
  71.         <!--  
  72.             A "Connector" represents an endpoint by which requests are received  
  73.             and responses are returned. Documentation at : Java HTTP Connector:  
  74.             /docs/config/http.html (blocking & non-blocking) Java AJP Connector:  
  75.             /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define  
  76.             a non-SSL HTTP/1.1 Connector on port 8080  
  77.         -->  
  78.         <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>  
  79.         <!-- A "Connector" using the shared thread pool-->  
  80.         <!--  
  81.             <Connector executor="tomcatThreadPool" port="8080"  
  82.             protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />  
  83.         -->  
  84.         <!--  
  85.             Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the  
  86.             JSSE configuration, when using APR, the connector should be using the  
  87.             OpenSSL style configuration described in the APR documentation  
  88.         -->  
  89.         <!--  
  90.             <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"  
  91.             maxThreads="150" scheme="https" secure="true" clientAuth="false"  
  92.             sslProtocol="TLS" />  
  93.         -->  
  94.   
  95.         <!-- Define an AJP 1.3 Connector on port 8009 -->  
  96.         <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>  
  97.   
  98.   
  99.         <!--  
  100.             An Engine represents the entry point (within Catalina) that processes  
  101.             every request. The Engine implementation for Tomcat stand alone  
  102.             analyzes the HTTP headers included with the request, and passes them  
  103.             on to the appropriate Host (virtual host). Documentation at  
  104.             /docs/config/engine.html  
  105.         -->  
  106.   
  107.         <!--  
  108.             You should set jvmRoute to support load-balancing via AJP ie :  
  109.             <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">  
  110.         -->  
  111.         <Engine defaultHost="localhost" name="Catalina">  
  112.   
  113.             <!--  
  114.                 For clustering, please take a look at documentation at:  
  115.                 /docs/cluster-howto.html (simple how to) /docs/config/cluster.html  
  116.                 (reference documentation)  
  117.             -->  
  118.             <!-- 
  119.                 <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> 
  120.             -->  
  121.   
  122.             <!--  
  123.                 The request dumper valve dumps useful debugging information about  
  124.                 the request and response data received and sent by Tomcat.  
  125.                 Documentation at: /docs/config/valve.html  
  126.             -->  
  127.             <!-- 
  128.                 <Valve className="org.apache.catalina.valves.RequestDumperValve"/> 
  129.             -->  
  130.   
  131.             <!--  
  132.                 This Realm uses the UserDatabase configured in the global JNDI  
  133.                 resources under the key "UserDatabase". Any edits that are performed  
  134.                 against this UserDatabase are immediately available for use by the  
  135.                 Realm.  
  136.             -->  
  137.             <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>  
  138.   
  139.             <!--  
  140.                 Define the default virtual host Note: XML Schema validation will not  
  141.                 work with Xerces 2.2.  
  142.             -->  
  143.             <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">  
  144.   
  145.                 <!--  
  146.                     SingleSignOn valve, share authentication between web applications  
  147.                     Documentation at: /docs/config/valve.html  
  148.                 -->  
  149.                 <!--  
  150.                     <Valve className="org.apache.catalina.authenticator.SingleSignOn"  
  151.                     />  
  152.                 -->  
  153.   
  154.                 <!--  
  155.                     Access log processes all example. Documentation at:  
  156.                     /docs/config/valve.html  
  157.                 -->  
  158.                 <!--  
  159.                     <Valve className="org.apache.catalina.valves.AccessLogValve"  
  160.                     directory="logs" prefix="localhost_access_log." suffix=".txt"  
  161.                     pattern="common" resolveHosts="false"/>  
  162.                 -->  
  163.                   
  164.             <!--  
  165.             <Context path="/examples" docBase="C:\Source\AirChina\examples"  privileged="true"/>   
  166.             <Context path="/www" docBase="C:\Source\AirChina\AirChina_Portal\WebContent"  privileged="true"/>   
  167.             <Context path="/" docBase="C:\Source\AirChina\AirChina_Admin\WebContent"  privileged="true"/>   
  168.             <Context path="/www" docBase="C:\Source\AirChina\AirChina_Portal\WebContent"  privileged="true"/>   
  169.             <Context path="/b2cbnd" docBase="C:\Source\AirChina\ACE\WebRoot"  privileged="true"/>   
  170. <Context path="/b2cbnd" docBase="C:\Source\AirChina\ACE\WebRoot"  privileged="true"/>  
  171. <Context path="/www" docBase="C:\Source\AirChina\AirChina_Portal\WebContent"  privileged="true"/>   
  172.             -->  
  173. <span style="color:#ff0000;"><strong><Context path="/www" docBase="D:\AMR2\AirChina_Portal\WebContent"  privileged="true"/> </strong></span>  
  174. </Host>  
  175.         </Engine>  
  176.     </Service>  
  177. </Server>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值