我已为Web服务
定义了我的bean.xml
,如下所示
<jaxws:endpoint id="serviceCustomerOffer" implementor="#myServiceCustomerOffer"
implementorClass="com.abc.mime.ws.manage.customeroffer.ManageCustomerOfferImpl"
address="/getCustomerOffer" />
<bean id="myServiceCustomerOffer" name="myServiceCustomerOfferName" class="com.abcd.mime.ws.manage.customeroffer.ManageCustomerOfferImpl" >
<constructor-arg index="0" ref="CustomerOfferFacade" />
</bean>
<bean id="CustomerOfferFacade" name="CustomerOfferFacade"
class="com.abc.mime.ws.facade.customeroffer.CustomerOfferFacadeImpl">
<constructor-arg index="0" ref="customerOfferDAO" />
<constructor-arg index="1" ref="generalDomainSql" />
</bean>
<bean id="customerOfferDAO" name="customerOfferDAOName"
class="com.abc.mime.ws.dao.bscs.sql.customeroffer.CustomerOfferDAOImpl">
</bean>
<bean id="generalDomainSql" name="generalDomainSqlName"
class="com.abcd.mime.ws.dao.bscs.sql.generaldomain.GeneralDomainDAOImpl">
</bean>
我在tomcat 6服务器上部署时遇到以下错误。所有类都以适当的结构定义。
13/Feb/2014 05:08:10,423 [http-8090-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceCustomerOffer': Cannot resolve reference to bean 'myServiceCustomerOffer' while setting constructor argument with index 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myServiceCustomerOffer' defined in ServletContext resource [/WEB-INF/beans.xml]: 1 constructor arguments specified but no matching constructor found in bean 'myServiceCustomerOffer' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myServiceCustomerOffer' defined in ServletContext resource [/WEB-INF/beans.xml]: 1 constructor arguments specified but no matching constructor found in bean 'myServiceCustomerOffer' (hint: specify index and/or type arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
这是我的代码中使用的ManageCustomerOfferImpl.java
。这也映射在wsdl文件中。
package com.abcd.mime.ws.manage.customeroffer;
import java.rmi.RemoteException;
import java.util.Date;
import javax.jws.WebService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.abcd.mime.ws.manage.customeroffer.ManageCustomerOffer;
@WebService(endpointInterface = "com.abcd.mime.ws.manage.customeroffer.ManageCustomerOffer")
public class ManageCustomerOfferImpl implements ManageCustomerOffer{
private CustomerOfferFacade customerOfferFacade;
private Log logger = LogFactory
.getLog(com.abcd.mime.ws.manage.customeroffer.ManageCustomerOfferImpl.class);
public ManageCustomerOfferImpl( CustomerOfferFacade _customerOffer) { this.customerOfferFacade = _customerOffer; }
@Override
public CustomerOfferResponse getCustomerOffer(CustomerOfferRequest customerOfferRequest) throws CustomerOfferFault {
logger.debug("ManageCustomerOfferImpl - getCustomerOffer: Received from Consumer MSISDN = ["+ customerOfferRequest.getMSISDN()+"]");
// TODO Auto-generated method stub
ustomerOfferResponse customerOfferResponse = customerOfferFacade.getCustomerOffer(customerOfferRequest);
logger.debug("ManageCustomerOfferImpl - getCustomerOffer: Sending Response back to Consumer =>> "+ customerOfferResponse);
return customerOfferResponse;
}
}
它工作得更早,但在进行一些修正时却停止了工作
Error13/Feb/2014 09:22:06,625 [http-8090-2] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceCustomerOffer': Invocation of init method failed; nested exception is java.lang.StackOverflowError
Caused by:
java.lang.StackOverflowError
at java.lang.ref.SoftReference.get(SoftReference.java:93)
at java.lang.Class.privateGetDeclaredFields(Class.java:2285)
at java.lang.Class.getDeclaredFields(Class.java:1743)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:298)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:227)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:179)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:172)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:301)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:227)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:179)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:172)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:301)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:227)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:179)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:172)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:301)
Feb 13, 2014 9:22:06 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceCustomerOffer': Invocation of init method failed; nested exception is java.lang.StackOverflowError
Caused by: java.lang.StackOverflowError
at java.lang.ref.SoftReference.get(SoftReference.java:93)
at java.lang.Class.privateGetDeclaredFields(Class.java:2285)
at java.lang.Class.getDeclaredFields(Class.java:1743)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:298)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:227)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:179)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:172)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:301)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:227)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:179)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:172)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:301)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:227)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:179)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:172)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:301)
答案 0 :(得分:0)
您的bean声明为
<bean id="myServiceCustomerOffer" name="myServiceCustomerOfferName" class="com.abcd.mime.ws.manage.customeroffer.ManageCustomerOfferImpl" >
<constructor-arg index="0" ref="CustomerOfferFacade" />
</bean>
这意味着它将使用一个构造函数,该构造函数需要CustomerOfferFacade
所属类型的参数。但是,您的类没有这样的构造函数。因此它失败了。
我不知道CustomerOfferFacadeImpl
是什么,所以我不知道你期望用它做什么,但是你需要添加一个带有该类型参数的构造函数,如果你想要的话<bean>
声明工作。