2013-03-05 104 views
1

我有一個使用Struts 1.3 + Spring 3.1 + Hibernate 4.0的動態Web應用程序,當它試圖從Web項目中使用它時,它一切正常。當我創建一個添加到EAR中的WebLogic Web服務並且還要使用一個Web服務客戶端並嘗試從數據庫中檢索Java對象時,我得到:無法初始化類com.multivision.ehrms.crud.impl.SpringHibernateFactory無法從Web服務初始化SpringHibernateFactory

AxisFault 
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server 
faultSubcode: 
faultString: Could not initialize class com.multivision.ehrms.crud.impl.SpringHibernateFactory 
faultActor: 
faultNode: 
faultDetail: 
    {http://jax-ws.dev.java.net/}exception:<message>Could not initialize class com.multivision.ehrms.crud.impl.SpringHibernateFactory</message><ns2:stackTrace><ns2:frame class="com.multivision.ehrms.service.data.BaseDataService" line="unknown" method="getDataRetriever"/><ns2:frame class="com.multivision.crm.service.data.QueryDataService" line="unknown" method="retrieveAllQueries"/><ns2:frame class="com.multivision.crm.ws.CRMdata" file="CRMdata.java" line="22" method="retrieveAll"/><ns2:frame class="sun.reflect.NativeMethodAccessorImpl" file="NativeMethodAccessorImpl.java" line="native" method="invoke0"/><ns2:frame class="sun.reflect.NativeMethodAccessorImpl" file="NativeMethodAccessorImpl.java" line="39" method="invoke"/><ns2:frame class="sun.reflect.DelegatingMethodAccessorImpl" file="DelegatingMethodAccessorImpl.java" line="25" method="invoke"/><ns2:frame class="java.lang.reflect.Method" file="Method.java" line="597" method="invoke"/><ns2:frame class="weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker" file="WLSInstanceResolver.java" line="92" method="invoke"/><ns2:frame class="weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker" file="WLSInstanceResolver.java" line="74" method="invoke"/><ns2:frame class="com.sun.xml.ws.server.InvokerTube$2" file="InvokerTube.java" line="151" method="invoke"/><ns2:frame class="com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl" file="EndpointMethodHandlerImpl.java" line="268" method="invoke"/><ns2:frame class="com.sun.xml.ws.server.sei.SEIInvokerTube" file="SEIInvokerTube.java" line="100" method="processRequest"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="866" method="__doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="815" method="_doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="778" method="doRun"/><ns2:frame class="com.sun.xml.ws.api.pipe.Fiber" file="Fiber.java" line="680" method="runSync"/><ns2:frame class="com.sun.xml.ws.server.WSEndpointImpl$2" file="WSEndpointImpl.java" line="403" method="process"/><ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit" file="HttpAdapter.java" line="532" method="handle"/><ns2:frame class="com.sun.xml.ws.transport.http.HttpAdapter" file="HttpAdapter.java" line="253" method="handle"/><ns2:frame class="com.sun.xml.ws.transport.http.servlet.ServletAdapter" file="ServletAdapter.java" line="140" method="handle"/><ns2:frame class="weblogic.wsee.jaxws.WLSServletAdapter" file="WLSServletAdapter.java" line="171" method="handle"/><ns2:frame class="weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke" file="HttpServletAdapter.java" line="708" method="run"/><ns2:frame class="weblogic.security.acl.internal.AuthenticatedSubject" file="AuthenticatedSubject.java" line="363" method="doAs"/><ns2:frame class="weblogic.security.service.SecurityManager" file="SecurityManager.java" line="146" method="runAs"/><ns2:frame class="weblogic.wsee.util.ServerSecurityHelper" file="ServerSecurityHelper.java" line="103" method="authenticatedInvoke"/><ns2:frame class="weblogic.wsee.jaxws.HttpServletAdapter$3" file="HttpServletAdapter.java" line="311" method="run"/><ns2:frame class="weblogic.wsee.jaxws.HttpServletAdapter" file="HttpServletAdapter.java" line="336" method="post"/><ns2:frame class="weblogic.wsee.jaxws.JAXWSServlet" file="JAXWSServlet.java" line="95" method="doRequest"/><ns2:frame class="weblogic.servlet.http.AbstractAsyncServlet" file="AbstractAsyncServlet.java" line="99" method="service"/><ns2:frame class="javax.servlet.http.HttpServlet" file="HttpServlet.java" line="820" method="service"/><ns2:frame class="weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction" file="StubSecurityHelper.java" line="227" method="run"/><ns2:frame class="weblogic.servlet.internal.StubSecurityHelper" file="StubSecurityHelper.java" line="125" method="invokeServlet"/><ns2:frame class="weblogic.servlet.internal.ServletStubImpl" file="ServletStubImpl.java" line="300" method="execute"/><ns2:frame class="weblogic.servlet.internal.ServletStubImpl" file="ServletStubImpl.java" line="183" method="execute"/><ns2:frame class="weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction" file="WebAppServletContext.java" line="3717" method="wrapRun"/><ns2:frame class="weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction" file="WebAppServletContext.java" line="3681" method="run"/><ns2:frame class="weblogic.security.acl.internal.AuthenticatedSubject" file="AuthenticatedSubject.java" line="321" method="doAs"/><ns2:frame class="weblogic.security.service.SecurityManager" file="SecurityManager.java" line="120" method="runAs"/><ns2:frame class="weblogic.servlet.internal.WebAppServletContext" file="WebAppServletContext.java" line="2277" method="securedExecute"/><ns2:frame class="weblogic.servlet.internal.WebAppServletContext" file="WebAppServletContext.java" line="2183" method="execute"/><ns2:frame class="weblogic.servlet.internal.ServletRequestImpl" file="ServletRequestImpl.java" line="1454" method="run"/><ns2:frame class="weblogic.work.ExecuteThread" file="ExecuteThread.java" line="209" method="execute"/><ns2:frame class="weblogic.work.ExecuteThread" file="ExecuteThread.java" line="178" method="run"/></ns2:stackTrace> 

Could not initialize class com.multivision.ehrms.crud.impl.SpringHibernateFactory 
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) 
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129) 
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) 
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:395) 
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) 
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) 
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) 
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) 
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) 
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784) 
    at org.apache.axis.client.Call.invoke(Call.java:2767) 
    at org.apache.axis.client.Call.invoke(Call.java:2443) 
    at org.apache.axis.client.Call.invoke(Call.java:2366) 
    at org.apache.axis.client.Call.invoke(Call.java:1812) 
    at com.multivision.crm.ws.CRMdataPortBindingStub.retrieveAll(CRMdataPortBindingStub.java:176) 
    at com.multivision.crm.ws.DataConsumer.main(DataConsumer.java:12) 

就像我說的,SpringHibernateFactory沒有問題使用Web項目時初始化,但是當我揭露使用Web服務和客戶端的項目,然後SpringHibernateFactory無法初始化。誰能理解這個問題?

+0

它是如何從web項目運行的? – 2013-03-07 10:30:00

回答

0

服務器啓動時是否啓動了您的spring上下文?你能在你的控制檯找到這種輸出嗎?

[ContextLoader ] Root WebApplicationContext: initialization started 
[XmlWebApplicationContext ] Refreshing Root WebApplicationContext: startup date [Tue Mar 05 09:34:47 CET 2013]; root of context hierarchy 
[XmlBeanDefinitionReader ] Loading XML bean definitions from class path resource [applicationContext.xml] 

嘗試在你的web.xml中添加此否則

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

您的問題,但爲什麼如果你使用Spring使用Java EE服務器沒有聯繫呢? Tomcat應該足夠了,如果你真的需要一個Java EE服務器,那麼使用CDI和EJB容器而不是彈簧

+0

我在啓動時沒有得到那個輸出,但是我在web.xml中有這個監聽器和ContextLoaderListener。我深入挖掘,似乎JNDI查找數據源不起作用的Web服務,雖然它在Web應用程序中工作。爲什麼會這樣? – 2013-03-06 00:08:40

+0

我需要額外的信息,如webService類和你得到休眠SessionManager的方式 – Gab 2013-03-06 08:20:42

相關問題