2014-03-26 4 views
1

내 서버 웹 서비스 요청을XFire에서 XML을 구문 분석하면 CPU가 높아 집니까?

그러나 자사의 CPU를 처리 할 수있는 XFire를 사용하고 100 % 또는 때로는 1천퍼센트까지 찍은

내가 서버를 restartd 일부 요청 후,이 이상한 문제가 다시 나타났다

내가 스레드 덤프를 스캔 CPU를 차지 스레드는 다음과 같이이다 :

httpWorkerThread-18028-39" daemon prio=10 tid=0xa0832800 nid=0x1d89 runnable [0x99e69000] 
java.lang.Thread.State: RUNNABLE 
at com.sun.xml.stream.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:892) 
at com.sun.xml.stream.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:362) 
at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:568) 
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:44) 
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131) 
at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64) 
at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38) 
at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:304) 
at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:129) 
at org.codehaus.xfire.transport.http.XFireServlet.doPost(XFireServlet.java:116) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:753) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:846) 

그것은 XML 파일을 구문 분석되어있는 XFire처럼 보이지만 시간이 지날으로, 스레드 덤프에서 다르지 없었다 모든 스레드는 무한 루프와 같습니다.

는 그러나, 나는, 내가 많은 구글 문제

의 원인이 무엇인지 파악하고 그 현상

그러나 단지 내처럼이 topic을 찾을 수있는 XFire와 충분한 경험이없는 이 주제는 JVM 버그 일 수 있으며 JDK6 대신 JDK5를 사용하는 것이 좋습니다. JDK5를 사용하여 도움이되는지 확인하려고합니다.

그런 문제가 발생 했습니까? 이 문제의 원인과 해결 방법은 무엇입니까?

thx 많이 있습니다.

답변

0

마지막으로이 문제가 해결되었습니다.

이유는이 topic에서 말한 것처럼 JDK6 XMLStreamReader 구현의 버그입니다.

문제를 해결하는 방법은 무엇입니까?

내가있는 XFire의 소스 코드를 읽고 답이 코드에 있습니다

XMLStreamReader reader = 
      STAXUtils.createXMLStreamReader(request.getInputStream(), 
              charEncoding, 
              context); 

STAXUtils.createXMLStreamReader가에 XMLStreamReader를 생성으로 XMLInputFactory를 작성합니다. 이 코드에서

public static XMLInputFactory getXMLInputFactory(MessageContext ctx) 
{ 
    if (ctx == null) return xmlInputFactory; 

    Object inFactoryObj = ctx.getContextualProperty(XFire.STAX_INPUT_FACTORY); 

    if (inFactoryObj instanceof XMLInputFactory) 
    { 
     return (XMLInputFactory) inFactoryObj; 
    } 
    else if (inFactoryObj instanceof String) 
    { 
     String inFactory = (String) inFactoryObj; 
     XMLInputFactory xif = (XMLInputFactory) factories.get(inFactory); 
     if (xif == null) 
     { 
      xif = (XMLInputFactory) createFactory(inFactory, ctx); 
      configureFactory(xif,ctx); 
      factories.put(inFactory, xif); 
     } 
     return xif; 
    } 

    if(!inFactoryConfigured){ 
     configureFactory(xmlInputFactory,ctx); 
     inFactoryConfigured=true; 
    } 



    return xmlInputFactory; 
} 

, 당신은에 XMLStreamReader에는 버그가 없습니다으로 XMLInputFactory를 생성하는 "xfire.stax.input.factory"있는 XFire 속성을 구성 할 수 있습니다 그러나,이 속성을 설정하는 방법을 알아낼 수 없습니다.

내 프로젝트에서 xmlInputFactory는 JDK의 기본 xmlInputFactory입니다.

/** 
* Create a new instance of the factory. 
* This static method creates a new factory instance. 
* This method uses the following ordered lookup procedure to determine 
* the XMLInputFactory implementation class to load: 
* Use the javax.xml.stream.XMLInputFactory system property. 
* Use the properties file "lib/stax.properties" in the JRE directory. 
* This configuration file is in standard java.util.Properties format and contains 
* the fully qualified name of the implementation class with the key being the system property defined above. 
* Use the Services API (as detailed in the JAR specification), if available, to determine the classname. 
* The Services API will look for a classname in the file META-INF/services/javax.xml.stream.XMLInputFactory 
* in jars available to the runtime. 
* Platform default XMLInputFactory instance. 
* Once an application has obtained a reference to a XMLInputFactory 
* it can use the factory to configure and obtain stream instances. 
* 
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded 
*/ 
public static XMLInputFactory newInstance() 
    throws FactoryConfigurationError 
{ 
    return (XMLInputFactory) FactoryFinder.find(
    "javax.xml.stream.XMLInputFactory", 
    "com.sun.xml.internal.stream.XMLInputFactoryImpl"); 
} 

그래서, 당신은 wstx lib 디렉토리와 같은 다른 XMLInputFactroy를 사용하도록 javax.xml.stream.XMLInputFactory 시스템 속성을 사용할 수 있습니다.