aspose file tools*
The moose likes Other Application Frameworks and the fly likes Unique issue with Spring-WebServices-JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Unique issue with Spring-WebServices-JDBC" Watch "Unique issue with Spring-WebServices-JDBC" New topic
Author

Unique issue with Spring-WebServices-JDBC

Shailesh Welankar
Ranch Hand

Joined: Dec 30, 2002
Posts: 35
hi Friends,

I have been working with Spring for couple of years now, but this is the first time I am trying to incorporate WS with Spring (on Win-XP, BEA Weblogic 10.0-Workshop, MySQL environment). I am encountering an unique issue with Spring. Here are the details of the issue -

I have have a WebService class defined as :
@WebService
public class GAREE {
private GareeDAO gareeDAO;

public void setGareeDAO(GareeDAO gareeDAO) {
this.gareeDAO = gareeDAO;
}

public GareeDAO getGareeDAO() {
return this.gareeDAO;
}
...
@WebMethod
public void waiveStrike(String incidentTicketNum) {
getGareeDAO().waiveStrikeForIncidentTicketNumber(incidentTicketNum);

} // End waiveStrike()


The web.xml contains the entries :

<context-param>
<param-name>contextConfigLocation</param-name>
<!--
<param-value>WEB-INF/dataAccessContext.xml, WEB-INF/applicationContext.xml</param-value>
-->
<param-value>WEB-INF/dataAccessContext.xml, WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>contextLoaderServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>


The applicationContext.xml contains :
<bean id="garee" class="com.company.project.webservice.GAREE">
<property name="gareeDAO">
<ref bean="gareeDAO"/>
</property>
</bean>


and the dataAccessContext.xml contains :
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.garee.jdbc.class}"/>
<property name="url" value="${database.garee.url}"/>
<property name="username" value="${database.garee.username}"/>
<property name="password" value="${database.garee.password}"/>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
...
<bean id="gareeDAO" class="com.company.project.dao.GareeDAOImpl">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate"/>
</property>
</bean>


The problem statement of the issue is that -

When i am running the WebService client and hitting the GAREE webservice, the waiveStrike method always gets the gareeDAO instance as NULL. If I try to call the same method, from the setter, it of course gets the gareeDAO instance and a successful database hit is made at time of app initialization by Spring. So, JDBCTemplate and the DAO are working properly. Only the WebServices class' methods for some reason do NOT seem to get the DAO instance object !!!
I understand that I can use Spring-WS for this, but we have go ahead with BEA Workshop based WebServices only. The Spring is another requirement with a stand-alone application that we are having along with the WS module (the above one which has issues).

Any ideas why this might be happening? Do let me know if you need more information. Thanks in advance.
[ November 04, 2008: Message edited by: Shailesh Welankar ]

--Shailesh Welankar
SCDJWS 1.4 | SCBCD 5.0 | SCWCD 1.4 | SCJP 1.4 | Preparing for SCEA 5
Shailesh Welankar
Ranch Hand

Joined: Dec 30, 2002
Posts: 35
Friends,

This issue is resolved!! I made the DAO instance variable to be static in the WebServices class declaration and accordingly removed the "this." call and set and retrieved it as a static variable rather than an instance variable. Should not have been an issue, may be the way Weblogic instantiates the WebService class, made the object to lose value once it was running on the server (mine is of course a web application). Making it static made it to retain the value throughout (build time as well as run time) on the Server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unique issue with Spring-WebServices-JDBC