一个类上的@WebService和@Transactional注释

我有一个Transnational类,我想启用Web服务:

我试过了:

@WebService(serviceName = "searchSth")  
@Transactional 
public class  A{

    public Sth getSth(){
    do sth here...
  }
}

但我努力工作,我也尝试过:

@WebService(serviceName = "searchSth")     
public class B{
private A a;

public seta(A a){
    this.a =a;
}

public Sth getSth(){
     a.getSth();
    }
}

@Transactional 
public class  A{

    public Sth getSth(){
    do sth here...
  }
}

当我运行它时,我得到:

线程“main”org.springframework.beans.factory.BeanCreationException中的异常:在类路径资源[remote-application.xml]中定义名称为'cre-remoting'的bean时出错:init方法的调用失败;嵌套异常是java.lang.IllegalArgumentException:类com.sun.proxy . $ Proxy22在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1589)既没有@WebService也没有@WebServiceProvider批注 . springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554)位于org.springframework.beans.factory.support的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) . 位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java)的org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)中的AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306) :302)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)位于org.springframework.context.support.AbstractApplicationContext的org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)位于org.springframework.context.support.ClassPathXmlApplicationContext . (ClassPathXmlApplicationContext.java:139)的.refresh(AbstractApplicationContext.java:542)位于com.mycompany的org.springframework.context.support.ClassPathXmlApplicationContext . (ClassPathXmlApplicationContext.java:83) . crmproject.server.RmiServer.main(RmiServer.java:18)引起:java.lang.IllegalArgumentException:类com.sun.proxy . $ Proxy22在com.sun.xml.internal.ws上既没有@WebService也没有@WebServiceProvider注释.server.EndpointFactory.verifyImplementorClass(EndpointFactory.java:424)at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java) :367)com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:315)at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish (EndpointImpl.java:231)位于org.springframework的org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter.publishEndpoint(SimpleJaxWsServiceExporter.java:68)org.springframework.remoting.jaxws.AbstractJaxWsServiceExporter.publishEndpoints(AbstractJaxWsServiceExporter.java:171) . 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1648)中的remoting.jaxws.AbstractJaxWsServiceExporter.afterPropertiesSet(AbstractJaxWsServiceExporter.java:142) AbstractAutowireCapableBeanFactory.java:1585)......还有12个

有什么办法可以解决吗?

回答(1)

2 years ago

堆栈跟踪的开头清楚地显示错误:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cre-remoting' defined in class path resource [remote-application.xml]:

在remote-application.xml配置文件中检查名为cre-remoting的bean的定义 . 您在那里定义的类没有@WebService和@WebServiceProvider注释 .