报错java.lang.IndexOutOfBoundsException

Java项目,部署项目后,启动tomcat6.0没报错,在浏览器键入访问地址http://localhost:8080/gyqp,显示:无法显示该页面,Myeclipse后台报异常,异常信息如下:

信息: Server startup in 12175 ms
2012-1-6 15:49:07 org.apache.jk.common.MsgAjp processHeader
严重: BAD packet signature 18245
2012-1-6 15:49:07 org.apache.jk.common.ChannelSocket processConnection
严重: Error, processing connection
java.lang.IndexOutOfBoundsException
    at java.io.BufferedInputStream.read(BufferedInputStream.java:306)
    at org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:628)
    at org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:585)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:693)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Thread.java:595)

搞了好几天都不知道是什么原因,请大家帮帮我。谢谢了。


我就是把你的xml service名为Catalina3的http connector那段注释去掉 并且改了一下端口
service是多个connector和host(context)的组合,你的catalina3中只有ajp3,没有http并且你用http+ajp的那个端口去访问,会被ajp connector接受但是协议不用所以处理出错 自己找原因吧

把tomcat配置文件service.xml中的相关内容注解掉就可以了。

[code="xml"]
<!– –>
[/code]

[quote]严重: BAD packet signature 18245[/quote]

enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

查看一下是否有访问8009端口的程序。关闭这个程序或者换一个其他端口

port="8080" 是否被占用。

你贴出配置就能明显地找出错误你的协议用错了你应该用protocol的值应该是http\1.1(BIO),或者NIO具体类名我记不太清楚了回头到公司了再详细查查,一个CONTEXT可以使用多个CONNECTOR但端口不同,你配置的ajp协议占用了8080,再用http协议去访问肯定报错不是一个协议啊


connectionTimeout="20000"
redirectPort="8443" />

添加在service Catalina3中

哦! 得将port换成其他的不能和在service名为Catalina的connector端口重复

[code="java"]
<?xml version='1.0' encoding='utf-8'?>

<!--APR library loader. Documentation at /docs/apr.html -->

<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->

<!-- Prevent memory leaks due to use of particular java/javax APIs-->

<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->

<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
    maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8088" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
           port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />
-->           
<!-- Define a SSL HTTP/1.1 Connector on port 8443
     This connector uses the JSSE configuration, when using APR, the 
     connector should be using the OpenSSL style configuration
     described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" />
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


<!-- An Engine represents the entry point (within Catalina) that processes
     every request.  The Engine implementation for Tomcat stand alone
     analyzes the HTTP headers included with the request, and passes them
     on to the appropriate Host (virtual host).
     Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
--> 
<Engine name="Catalina" defaultHost="localhost">

  <!--For clustering, please take a look at documentation at:
      /docs/cluster-howto.html  (simple how to)
      /docs/config/cluster.html (reference documentation) -->
  <!--
  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
  -->        

  <!-- The request dumper valve dumps useful debugging information about
       the request and response data received and sent by Tomcat.
       Documentation at: /docs/config/valve.html -->
  <!--
  <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
  -->

  <!-- This Realm uses the UserDatabase configured in the global JNDI
       resources under the key "UserDatabase".  Any edits
       that are performed against this UserDatabase are immediately
       available for use by the Realm.  -->
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

  <!-- Define the default virtual host
       Note: XML Schema validation will not work with Xerces 2.2.
   -->
  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
           prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
    -->

  </Host>
</Engine>


port="8080"
redirectPort="7443"
minSpareThreads="25"
connectionTimeout="20000"
maxSpareThreads="75"
maxThreads="150"
URIEncoding="UTF-8">

port="8010"
redirectPort="7443"
protocol="AJP/1.3">

<Engine defaultHost="localhost" name="Catalina3">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
  <Host appBase="webapps" name="localhost">
        <Context path="/gyqp" docBase="E:\workspaces\gyqp_new\web" privileged="true" debug="0" reloadable="true"></Context>
  </Host>
</Engine>



[/code]

不应该啊 邪门!

我也遇到同样的问题:java.lang.IndexOutOfBoundsException

原因是:
这没有配置或其docBase的路径指出错误。

同时访问时输入的端口不能是protocol="AJP/1.3"指定的端口,而是8080端口。