【转】BAD packet signature 18245 错误解决 .

本文详细解析了Apache Tomcat中AJP协议访问端口错误的原因,包括错误信息分析、原因解释以及解决方法。通过调整URL端口号,将其修改为实际的WEB服务端口号,可以有效避免此类问题发生。

1、错误信息

2014-7-15 2:46:38 org.apache.jk.common.MsgAjp processHeader
严重: BAD packet signature 18245
2014-7-15 2:46:38 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:620)
    at org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:577)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:685)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Thread.java:595)


2、原因,WEB请求访问端口不正确。也就是说在浏览器中输入的URL端口号是AJP协议的端口号,而不是WEB服务的端口号。

下面的例子中ARJ协议端口号为8009,真正的WEB服务端口号应为9000,所以,若使用8009访问,会出现上面的错误信息。

 

 

 <Service name="Catalina">
    <!--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 URIEncoding="UTF-8" connectionTimeout="20000" port="9000" protocol="HTTP/1.1" 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 defaultHost="localhost" name="Catalina">
以下XML内容略

 

3、解决:将URL端口号修改为WEB服务的端口号。

即协议protocal 为HTTP/1.1的那一个Connnector的端口号,而不是AJP。

 

转自:http://blog.youkuaiyun.com/hongweigg/article/details/37811005

第三批上传文件:数据解析类 // ===== com/smallplanet/util/SPSXYPoint.java ===== package com.smallplanet.util; import com.smallplanet.jyd.JYDPoint; import com.smallplanet.jyd.JYDStorable; import com.smallplanet.util.SPSVector; import java.text.DecimalFormat; public class SPSXYPoint implements Comparable, JYDStorable { private static DecimalFormat fmt4 = new DecimalFormat("###0.0000"); double x = Double.NaN; double y = Double.NaN; private static final double Tolerance = 0.01D; public SPSXYPoint() {} public SPSXYPoint(double newX, double newY) { this.x = newX; this.y = newY; } public SPSXYPoint(float newX, float newY) { this.x = (double)newX; this.y = (double)newY; } public double getX() { return this.x; } public String getXData(){ return fmt4.format(this.x); } public double getY() { return this.y; } public String getYData(){ return fmt4.format(this.y); } public boolean approximatelyEquals(SPSXYPoint testPoint, float numericalError) { boolean returnFlag = false; if(testPoint != null && Math.abs(this.getX() - testPoint.getX()) < (double)numericalError && Math.abs(this.getY() - testPoint.getY()) < (double)numericalError) { returnFlag = true; } System.out.println("SPSXYPoint.approximatelyEquals() this = " + this + " testPoint = " + testPoint + " returnFlag = " + returnFlag); return returnFlag; } public SPSXYPoint addVector(SPSVector theVector) { SPSXYPoint tempPoint = new SPSXYPoint(this.x + theVector.getX(), this.y + theVector.getY()); return tempPoint; } public boolean isBefore(SPSXYPoint comparePoint) { return this.x < comparePoint.x; } public boolean isAfter(SPSXYPoint comparePoint) { return this.x > comparePoint.x; } public boolean isValid() { boolean returnFlag = true; if(!Double.isNaN(this.x) && !Double.isNaN(this.y)) { if(Double.isInfinite(this.x) || Double.isInfinite(this.y)) { returnFlag = false; } } else { returnFlag = false; } return returnFlag; } public int compareTo(Object testObject) { SPSXYPoint testPoint = (SPSXYPoint)testObject; double x0 = testPoint.getX(); int returnValue = this.x < x0?-1:(this.x == x0?0:1); return returnValue; } public String toString() { return "x = " + fmt4.format(this.x) + " y = " + fmt4.format(this.y); } public String toTabbedString() { return fmt4.format(this.x) + "\t" + fmt4.format(this.y) + "\n"; } public Object toJydStorableObject() { JYDPoint newPoint = new JYDPoint(this.getX(), this.getY()); return newPoint; } public boolean equals(Object ob) { boolean returnFlag = false; if(ob instanceof JYDPoint) { JYDPoint tempPoint = (JYDPoint)ob; if(Math.abs(this.x - (double)tempPoint.getX()) < 0.01D && Math.abs(this.y - (double)tempPoint.getY()) < 0.01D) { returnFlag = true; } } else if(ob instanceof SPSXYPoint) { SPSXYPoint tempPoint1 = (SPSXYPoint)ob; if(Math.abs(this.x - tempPoint1.getX()) < 0.01D && Math.abs(this.y - tempPoint1.getY()) < 0.01D) { returnFlag = true; } } return returnFlag; } } // ===== com/sienco/sonoclot/signature/SimpleSignature.java ===== package com.sienco.sonoclot.signature; import com.sienco.sonoclot.signature.FilterPointList; import com.sienco.sonoclot.signature.LineSegment; import com.sienco.sonoclot.signature.SignatureException; import com.smallplanet.jyd.JYDPoint; import com.smallplanet.util.SPSCurveData; import com.smallplanet.util.SPSGraphicsException; import com.smallplanet.util.SPSUtilities; import com.smallplanet.util.SPSXYPoint; import java.text.DecimalFormat; import java.util.*; public class SimpleSignature extends FilterPointList { protected static final float DEFAULT_MINIMUM_SIGNATURE_DATA_SPACING = 0.008333334F; protected static final float HISTORIC_MINIMUM_SIGNATURE_DATA_SPACING = 0.0016666667F; static final float MaxAnalysisDelay = 0.1F; private static DecimalFormat fmt = new DecimalFormat("###0.0000"); private SPSCurveData mySPSCurve = new SPSCurveData(); private boolean lastDataPointUncompressed = false; public SimpleSignature(float tolerance, float minimumSpacing) { super(minimumSpacing); } public SimpleSignature(float tolerance) { super(0.008333334F); } public SimpleSignature(float minimumspacing, List newData) throws SignatureException { super(minimumspacing); this.initializeSignature(newData); } public SimpleSignature(List newData) throws SignatureException { super(0.0016666667F); this.initializeSignature(newData); } void removeEndPoint() { super.removeEndPoint(); } private void initializeSignature(List newData) throws SignatureException { ListIterator tempIterator = newData.listIterator(); while(tempIterator.hasNext()) { Object tempObject = tempIterator.next(); if(tempObject != null) { SPSXYPoint tempPoint; if(tempObject instanceof SPSXYPoint) { tempPoint = (SPSXYPoint)tempObject; } else { JYDPoint jydPoint = (JYDPoint)tempObject; tempPoint = new SPSXYPoint(jydPoint.getX(), jydPoint.getY()); } super.addEndPoint(tempPoint); } } } public SPSCurveData getSignatureCurve() { this.updateSPSCurve(); return this.mySPSCurve; } private void updateSPSCurve() { this.mySPSCurve.clear(); Iterator tempIterator = this.iterator(); while(tempIterator.hasNext()) { Object tempObject = tempIterator.next(); if(tempObject != null && tempObject instanceof SPSXYPoint) { SPSXYPoint tempPoint = (SPSXYPoint)tempObject; try { this.mySPSCurve.addPoint(tempPoint); } catch (SPSGraphicsException var5) { SPSUtilities.throwNullPointerException("SimpleSignature.updateSPSCurve() bad data"); } } } } protected SPSXYPoint getMinClotSignalPointBetweenTimes(double t0, double t1) { double yMinimum = 100000.0D; SPSXYPoint minPoint = null; int index = this.getIndexBeforeT(t0); for(int maxIndex = this.getIndexBeforeT(t1); index <= maxIndex; ++index) { SPSXYPoint tempPoint = this.getPoint(index); double yTest = tempPoint.getY(); if(yTest < yMinimum) { yMinimum = yTest; minPoint = tempPoint; } } return minPoint; } float getTimeForYNearTime(float time, float yTarget, float timeRange) { float returnTime = Float.NaN; int ilow = this.getIndexBeforeT(time); int ihigh; LineSegment tempSegment; for(ihigh = ilow + 1; ilow >= 0; --ilow) { tempSegment = this.getLineSegment(ilow); if(tempSegment.isYOnSegment(yTarget)) { returnTime = tempSegment.getTforY(yTarget); break; } if(tempSegment.getStartTime() <= time - timeRange) { break; } } if(Float.isNaN(returnTime)) { while(ihigh < this.size() - 1) { tempSegment = this.getLineSegment(ihigh); if(tempSegment.isYOnSegment(yTarget)) { returnTime = tempSegment.getTforY(yTarget); break; } if(tempSegment.getEndTime() >= time + timeRange) { break; } ++ihigh; } } return returnTime; } float getLastClotSignal() { float tempLastClotSignal = this.getClotSignalAtTime(this.getEndTime()); return tempLastClotSignal; } public float getClotSignalAtTime(float t) { float y = this.getYAtT((double)t); return y; } double getTimeForClotSignalAfterTime(double testClotSignal, double initialTime) { double tempReturnTime = Double.NaN; double t0 = initialTime; double y0 = (double)this.getYAtT(initialTime); int i = this.getIndexAfterT((float)initialTime); double t1 = (double)this.getTimeAtIndex(i); double y1 = this.getClotSignalAtIndex(i); for(int indexLimit = this.size(); (y0 - testClotSignal) * (y1 - testClotSignal) > 0.0D && i < indexLimit; t1 = (double)this.getTimeAtIndex(i)) { y0 = y1; t0 = t1; ++i; y1 = this.getClotSignalAtIndex(i); } System.out.println("SimpleSignature.getTimeForClotSignalAfterTime():\n y0 = " + y0 + "\n y1 = " + y1 + "\n t0 = " + t0 + "\n t1 = " + t1 + "\n testClotSignal = " + testClotSignal); if((y0 - testClotSignal) * (y1 - testClotSignal) <= 0.0D) { double tempSlope = (y1 - y0) / (t1 - t0); double tempOffset = y0 - tempSlope * t0; tempReturnTime = Math.abs(tempSlope) > 1.0E-7D?(testClotSignal - tempOffset) / tempSlope:t0; } System.out.println("SimpleSignature.getTimeForClotSignalAfterTime():\n testClotSignal = " + testClotSignal + "\n initialTime = " + initialTime + "\n tempReturnTime = " + tempReturnTime); return tempReturnTime; } public SPSXYPoint getPointAtTime(float t) { float y = this.getYAtT((double)t); SPSXYPoint tempPoint = new SPSXYPoint(t, y); return tempPoint; } private double getTimeLength() { double tempTimeLength = (double)this.getEndTime(); return tempTimeLength; } private float getYAtT(double t) { float returnValue = Float.NaN; if(this.size() == 0) { returnValue = 0.0F; } else if(this.size() == 1) { SPSXYPoint index = this.getFirstPoint(); returnValue = (float)index.getY(); } else { int index1 = this.getIndexBeforeT(t); SPSXYPoint point0; SPSXYPoint point1; if(index1 < this.size() - 1) { point0 = this.getPoint(index1); point1 = this.getPoint(index1 + 1); } else { point0 = this.getPoint(index1 - 1); point1 = this.getPoint(index1); } float y = (float)(point0.getY() + (point1.getY() - point0.getY()) * (t - point0.getX()) / (point1.getX() - point0.getX())); returnValue = y; } return returnValue; } protected int getIndexBeforeT(double t) { int returnInt; if(this.size() < 2) { returnInt = 0; } else { int iLow = 0; int iHigh = this.size() - 1; boolean index = false; double testTime = this.getPoint(iLow).getX(); if(t < testTime) { returnInt = iLow; } else { testTime = this.getPoint(iHigh).getX(); if(t > testTime) { returnInt = iHigh; } else { while(iHigh - iLow > 1) { int index1 = (iHigh + iLow) / 2; testTime = this.getPoint(index1).getX(); if(t < testTime) { iHigh = index1; } else { iLow = index1; } } returnInt = iLow; } } } return returnInt; } public float getAnalysisEndTime(float tempAnalysisPeriod) { float returnTime = Float.NaN; int tempSize = this.size(); if(tempSize > 1 && this.getEndTime() - this.getStartTime() > tempAnalysisPeriod * 2.0F) { float tempTime0 = (float)this.getPoint(tempSize - 2).getX(); float tempTime1 = this.getEndTime(); if(tempTime1 - tempTime0 < tempAnalysisPeriod) { returnTime = tempTime0; } else { returnTime = tempTime1 - tempAnalysisPeriod; } } return returnTime; } protected float getTimeAtIndex(int index) { float tempFloat; try { SPSXYPoint e = this.getPoint(index); tempFloat = (float)e.getX(); } catch (ArrayIndexOutOfBoundsException var4) { tempFloat = 0.0F; } return tempFloat; } LineSegment getLineSegment(int index) { LineSegment returnSegment = null; if(this.size() > 1) { SPSXYPoint point0 = this.getPoint(index); SPSXYPoint point1 = this.getPoint(index + 1); returnSegment = new LineSegment(point0, point1); } return returnSegment; } public void addUncompressedPoint(SPSXYPoint newPoint) { if(this.size() > 0) { SPSXYPoint currentEndPoint = this.getLastPoint(); if(!this.isTooClose(currentEndPoint, newPoint)) { if(this.lastDataPointUncompressed) { this.removeEndPoint(); } super.addEndPoint(newPoint); this.updateSPSCurve(); this.lastDataPointUncompressed = true; } } } public void addEndPoint(SPSXYPoint newPoint) { SPSUtilities.throwNullPointerException("SimpleSignature.addEndPoint() this should never be called"); } public void addCompressedPoint(SPSXYPoint newPoint) { if(this.lastDataPointUncompressed) { this.removeEndPoint(); } super.addEndPoint(newPoint); this.updateSPSCurve(); this.lastDataPointUncompressed = false; } protected double getMaximumSlopeBetweenTimes(float tLow, float tHigh) { double maxSlope = Double.NaN; int iMin = this.getIndexBeforeT(tLow); int iMax = this.getIndexAfterT(tHigh); double y0 = Double.NaN; double y1 = Double.NaN; double t0 = Double.NaN; double t1 = Double.NaN; double tempSlope = Double.NaN; while(Double.isNaN(y0) || iMin < iMax) { t0 = (double)this.getTimeAtIndex(iMin); y0 = this.getClotSignalAtIndex(iMin++); t1 = (double)this.getTimeAtIndex(iMin); y1 = this.getClotSignalAtIndex(iMin); tempSlope = (y1 - y0) / (t1 - t0); if(Double.isNaN(maxSlope) || tempSlope > maxSlope) { maxSlope = tempSlope; } } if(Double.isNaN(maxSlope)) { System.out.println("SimpleSignature.getMaximumSlopeBetweenTimes(): unexpected NaN:"); System.out.println(" tLow = " + tLow); System.out.println(" tHigh = " + tHigh); System.out.println(" iMin = " + iMin); System.out.println(" iMax = " + iMax); System.out.println(" y0 = " + y0); System.out.println(" y1 = " + y1); System.out.println(" t0 = " + t0); System.out.println(" t1 = " + t1); System.out.println(" tempSlope = " + tempSlope); SPSUtilities.throwNullPointerException("SimpleSignature.getMaximumSlopeBetweenTimes():"); } return maxSlope; } double getClotSignalAtIndex(int index) { double tempDouble; try { SPSXYPoint e = this.getPoint(index); tempDouble = e.getY(); } catch (ArrayIndexOutOfBoundsException var5) { tempDouble = 0.0D; } return tempDouble; } protected double getAlignedTimeBefore(double t) { int index = this.getIndexBeforeT(t); double t0 = (double)this.getTimeAtIndex(index); return t0; } protected double getAlignedTimeAfter(double t) { int index = this.getIndexBeforeT(t); if(index + 1 < this.size()) { ++index; } double t0 = (double)this.getTimeAtIndex(index); return t0; } public String toString() { StringBuffer buf = new StringBuffer(); buf.append("SimpleSignature"); buf.append("\n Number of points = " + this.size()); Iterator iter = this.getPointsIterator(); while(iter.hasNext()) { SPSXYPoint tempPoint = (SPSXYPoint)iter.next(); buf.append("\n " + tempPoint); } return buf.toString(); } public List<Map<String,String>> getPointListData(){ List<Map<String,String>> result = new ArrayList<Map<String, String>>(); Iterator iter = this.getPointsIterator(); Map<String,String> data = null; int index = 0; while(iter.hasNext()) { SPSXYPoint tempPoint = (SPSXYPoint)iter.next(); data = new HashMap<String, String>(); result.add(data); data.put("i", index + ""); data.put("x", tempPoint.getXData()); data.put("y", tempPoint.getYData()); index++; } return result; } } ====== 你还要上传其他文件吗?如需要请告知文件名,如不需要就开始delphi 编程,请把与设备通讯的模块写入单独的单元中,方便调试与引用。另外请注意:引用控件HidControllerClassVersion = '1.0.35'的方法是引用 JvHidControllerClass.pas,不是HidController。如果需要,我可以提供JvHidControllerClass.pas文件内容中所有头部的定义函数。
09-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值