Announcement Announcement Module
Collapse
No announcement yet.
JAX WS web service from existing java application and Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JAX WS web service from existing java application and Spring

    Hi,

    This is my first JAX WS implementation and after going down the rocky path to configure my JAX WS on apache tomcat now I am facing other issues with Spring.

    Here is my web service setup:

    I have an existing framework/project build as a java application which utilizes Spring. I need to expose most of the calls from my framework in the webservice.

    I got everything to work besides my DAO object they always fail and my guess is my spring configuration is not setup properly for jax ws.

    Here is my web service structure:

    META-INF
    context.xml
    MANIFEST.MF
    WEB-INF
    lib
    all required jars plus my Project.jar
    classes
    reflection of my webservice package
    jdbc.properties
    ApplicationContext.xml (same configuration as Project.jar)
    web.xml
    sun-jaxws.xml
    -----
    And of course all the above is bundled in a war file and deployed on my server container.


    Here is my app Context:

    Code:
    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC   "-//SPRING//DTD BEAN//EN"
    "springframework.org/dtd/spring-beans.dtd">
    <beans>
        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location">
                <value>WEB-INF/jdbc.properties</value>
            </property>
        </bean>
    
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
            <property name="driverClass" value="${db.driver}"/>
            <property name="jdbcUrl" value="${db.jdbcurl}"/>
            <property name="user" value="${db.username}"/>
            <property name="password" value="${db.password}"/>
            <property name="minPoolSize" value="0"/>
            <property name="maxPoolSize" value="15"/>
            <property name="initialPoolSize" value="3"/>
        </bean>
    
        <!--
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClass" value="${db.driver}"/>
            <property name="jdbcUrl" value="${db.jdbcurl}"/>
            <property name="user" value="${db.username}"/>
            <property name="password" value="${db.password}"/>
            <property name="minPoolSize" value="0"/>
            <property name="maxPoolSize" value="15"/>
            <property name="initialPoolSize" value="3"/>
        </bean>
        -->
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"/>
        </bean>
        <bean id="authorizationDAO" class=" com.myCompany.re.dao.jdbc.AuthorizationImpl">
            <property name="transactionManager">
                <ref local="transactionManager"/>
            </property>
        </bean>
        <bean id="companyDAO" class=" com.myCompany.re.dao.jdbc.CompanyImpl">
            <property name="transactionManager">
                <ref local="transactionManager"/>
            </property>
        </bean>
    
    and followed by bunch of other DAOs
    
    Here is also how I declare my app context and MyService implementation in the web service class:
    
    @WebService()
    public class TestApi {
    
        private ApplicationContext appContext = new ClassPathXmlApplicationContext("/WEB-INF/ApplicationContext.xml");
        private AdminService adminService;
        private ExecutionService execService;
    
    my method:
     @WebMethod(operationName = "getCompanyById")
        public String getCompanyById(@WebParam(name = "objId") long objId) {
    
            adminService = (AdminService) appContext.getBean("adminService");//get bean casts from xml to an object
            Company c = null;
    Any ideas why I can't get my DB calls to work?

  • #2
    I missed an important part of my AppContext file. Here is how I declare my Service.
    Code:
        <bean id="adminService" class="com.myCompany.re.service.DefaultAdminServiceImpl">
             <property name="validationService">
                <ref local="validationService"/>
            </property>
            <property name="companyAccessDAO">
                <ref local="companyAccessDAO"/>
            </property>
            <property name="companyDAO">
                <ref local="companyDAO"/>
            </property>
            <property name="deviceGroupDAO">
                <ref local="deviceGroupDAO"/>
            </property>
            <property name="logMessageDAO">
                <ref local="logMessageDAO"/>
            </property>
            <property name="mailingEntryDAO">
                <ref local="mailingEntryDAO"/>
            </property>
            <property name="userDAO">
                <ref local="userDAO"/>
            </property>
        </bean>

    Comment

    Working...
    X