求助:webservice+SSH+CXF 遇到异常

woyaopp123 2013-06-18 03:26:51
需求是:在服务端有一个方法 返回正常和不正常,然后现在需要用webservice定时调用此方法得到返回值。
application.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

<bean name="userDemoBean" class="service.userDemoImpl"></bean>
<jaxws:endpoint id="userDemoService" implementor="#userDemoBean" address="/userDemoBean"/>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url" value="jdbc:sqlserver://192.168.1.8:1433;databaseName=JB_PMVC">
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>entity/UserDemo.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userDao" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<bean id="userDemoAction" class="action.userDemoAction">
<property name="userDao" ref="userDao"></property>
</bean>
</beans>

xml文件已配。
接口:
@WebService()
public interface userDemoService {
public boolean loginDemo(String userName,String passWord);
}

实现类:
@WebService(endpointInterface="service.userDemoService")
public class userDemoImpl implements userDemoService{

private userDemoDao userDao;

public userDemoDao getUserDao() {
return userDao;
}
public void setUserDao(userDemoDao userDao) {
this.userDao = userDao;
}
/**
* 登陆
*/
public boolean loginDemo(String userName, String passWord) {
return userDao.loginDemo(userName, passWord);
}
}
DAO:
public boolean loginDemo(String userName, String passWord) {

String hql="from UserDemo where userName=? and passWord=?";
Object[] param=new Object[]{userName,passWord};

List<UserDemo> list=hibernateTemplate.find(hql, param);
if(list.size()>0){
return true;
}else{
return false;
}
}


运行Tomcat时候报异常:
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:258)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:192)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:380)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1468)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
... 36 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:287)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:332)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:383)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:169)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:98)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:98)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:114)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:160)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:327)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:242)
... 45 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
org.hibernate.Interceptor是接口, 而 JAXB 无法处理接口。
this problem is related to the following location:
at org.hibernate.Interceptor
at public org.hibernate.Interceptor org.springframework.orm.hibernate3.HibernateAccessor.getEntityInterceptor() throws java.lang.IllegalStateException,org.springframework.beans.BeansException
at org.springframework.orm.hibernate3.HibernateAccessor
at org.springframework.orm.hibernate3.HibernateTemplate
at public org.springframework.orm.hibernate3.HibernateTemplate dao.userDemoDao.getHibernateTemplate()
at dao.userDemoDao
org.springframework.jdbc.support.SQLExceptionTranslator是接口, 而 JAXB 无法处理接口。
this problem is related to the following location:
at org.springframework.jdbc.support.SQLExceptionTranslator
at public org.springframework.jdbc.support.SQLExceptionTranslator org.springframework.orm.hibernate3.HibernateAccessor.getJdbcExceptionTranslator()
at org.springframework.orm.hibernate3.HibernateAccessor
at org.springframework.orm.hibernate3.HibernateTemplate
at public org.springframework.orm.hibernate3.HibernateTemplate dao.userDemoDao.getHibernateTemplate()
at dao.userDemoDao
org.hibernate.SessionFactory是接口, 而 JAXB 无法处理接口。
this problem is related to the following location:
at org.hibernate.SessionFactory
at public org.hibernate.SessionFactory org.springframework.orm.hibernate3.HibernateAccessor.getSessionFactory()
at org.springframework.orm.hibernate3.HibernateAccessor
at org.springframework.orm.hibernate3.HibernateTemplate
at public org.springframework.orm.hibernate3.HibernateTemplate dao.userDemoDao.getHibernateTemplate()
at dao.userDemoDao




求各位大侠帮帮忙啊!
...全文
479 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hbuzhuhaoju 2016-03-13
  • 打赏
  • 举报
回复
解决方案:刚刚测试成功,先说思路,不再注入dao,当webService使用的时候在通过ClassPathXmlApplicationContext 获取Dao,调用方法 @WebService public class WarrantyServiceImpl implements WarrantyService{ private WGenericDaoImpl warrantyDao; public String getName(String name){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); this.warrantyDao = (WGenericDaoImpl)context.getBean("warrantyDao"); Warranty warranty = new Warranty(); warranty.setRemark(name); warrantyDao.add(warranty); return warrantyDao.toString(); }
juer_0001 2016-03-05
  • 打赏
  • 举报
回复
问题解决了?求解决方案
u010615703 2014-06-18
  • 打赏
  • 举报
回复
org.springframework.jdbc.support.SQLExceptionTranslator是接口, 而 JAXB 无法处理接口。 org.hibernate.Interceptor是接口, 而 JAXB 无法处理接口。 org.hibernate.SessionFactory是接口, 而 JAXB 无法处理接口。 这些该怎么解决呢? 用hibernate 怎么可能没有SessionFactory这个接口呢
  • 打赏
  • 举报
回复
private userDemoDao userDao;这个改为注入实现类,不要注入接口。
thisisnew 2014-06-18
  • 打赏
  • 举报
回复
webservice中不要有 getUserDao方法。
u010615703 2014-06-17
  • 打赏
  • 举报
回复
在吗? 这个问题我也遇到了,请问怎么解决的? 教教我好不,急!!!!
woyaopp123 2013-06-18
  • 打赏
  • 举报
回复
我需要操作数据库,肯定会有hibnaterTemplet这个接口,但是他说不能处理接口,。,,不知道咋办。。。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧