У меня есть один класс обслуживания для выполнения операций с БД через классы DAO, я внедряю объект DAO, используя spring.Он работает нормально.
После этого я показал тот же метод, что и метод веб-сервиса, используя аннотацию JAX-WS.
После этого он не работает, говоря, что мой объект dao не вводится,Я получаю nullpointerexception.правильно я делаю или нет?
Мой класс обслуживания
package com.tecnotree.upc.services.impl;
import com.tecnotree.upc.services.*;
import com.tecnotree.upc.entities.*;
import com.tecnotree.upc.dao.UpcLineOfBusinessDao;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.WebParam;
import javax.jws.soap.SOAPBinding;
import org.springframework.transaction.annotation.Transactional;
@WebService
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
public class UpcLineOfBusinessServiceImpl implements UpcLineOfBusinessService {
private UpcLineOfBusinessDao upcLineOfBusinessDao;
public void setUpcLineOfBusinessDao(
UpcLineOfBusinessDao upcLineOfBusinessDao) {
this.upcLineOfBusinessDao = upcLineOfBusinessDao;
}
@Override
@Transactional
@WebMethod
public UpcLineOfBusinessEntity createUpcLineOfBusinessEntity(
UpcLineOfBusinessEntity upcLineOfBusinessEntity) {
try{
if(upcLineOfBusinessDao!=null)
return upcLineOfBusinessDao.create(upcLineOfBusinessEntity);
else
return null;
}
catch(Exception ex)
{
ex.printStackTrace();
return null;
}
}
}
Мой xml-файл Spring
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="upcDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@192.168.4.33:1521:lt33" />
<property name="username" value="UPC_PROD" />
<property name="password" value="UPC_PROD" />
</bean>
<bean id="upcSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="upcDataSource" />
<property name="mappingResources">
<list>
<value>/com/tecnotree/upc/hbmfiles/UpcLineOfBusinessEntity.hbm.xml
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="upcSessionFactory" />
</property>
</bean>
<tx:annotation-driven />
<bean id="upcLineOfBusinessDao" class="com.tecnotree.upc.dao.impl.UpcLineOfBusinessDaoImpl">
<property name="sessionFactory">
<ref bean="upcSessionFactory" />
</property>
</bean>
<bean id="upcLineOfBusinessService" class="com.tecnotree.upc.services.impl.UpcLineOfBusinessServiceImpl">
<property name="upcLineOfBusinessDao">
<ref bean="upcLineOfBusinessDao" />
</property>
</bean>