Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get session

YEJan 16 2013 — edited Jan 16 2013
A wsdl is created by a java class ( Dao ). After adding reflection, session cannot be get. Code snippets are as follows.
Error message is : unwinding now: java.lang.reflect.InvocationTargetException: null

If the method does not contain this.getSession, it works fine. However, it seems that in the new instance, session is null if a method has this.getSession.

How to get current instance to get session?

Thanks
@WebService(name="webService",serviceName="webServiceSrc",targetNamespace="http://com.ws.org")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
		use=SOAPBinding.Use.LITERAL,
		parameterStyle=SOAPBinding.ParameterStyle.WRAPPED
)
public class WebService extends HibernateDaoSupport{

...........

	private String GetCityData(String userid, Long city, Integer version){

		String hql="from CityInfo t where t.filename='"+Long.toString(city)+"'";
		Session session = this.getSession();
                ...................................
        }

                 
	public String CommonWS(String paramString) throws Exception{
		
		..........................
		String functionName="";

		ArrayList<Object []>s = parseXml2(paramString);
		functionName = s.get(0)[0].toString();
		
		Class<?>[] mapValue = WStype.map.get(functionName);
		Class cl=Class.forName("com.ws.WebService");
		Method m=cl.getDeclaredMethod(functionName, mapValue);
		m.setAccessible(true);
		
		Object[] newobject=getObject(s.get(1), mapValue);
		
		m.invoke(cl.newInstance(), newobject);
		
		return null;
		
	}	
	
}
		
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

	<!-- SpringContextUtils定义 -->
	<bean id="springContextUtils" class="com.framework.core.utils.SpringContextUtils" lazy-init="false"/>
	
	<!-- WebService -->
	<bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
	
	<import resource="classpath:META-INF/cxf/cxf.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
	
	<bean id="webServiceBean" class="com.ws.WebService" >
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<!-- WSDL -->
	<jaxws:endpoint id="webService" implementor="#webServiceBean" address="/webService" />
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2013
Added on Jan 16 2013
0 comments
378 views