This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Unique issue with Spring-WebServices-JDBC

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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've got no option but to sell you all for scientific experiments. Or a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!