Announcement Announcement Module
Collapse
No announcement yet.
problems with spring's httpinvoker with tomcat client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problems with spring's httpinvoker with tomcat client

    my server use HttpInvolker in tomcat like as flow:
    remoting-servlet.xml
    [QUOTE<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    <bean name="/AccountService"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
    <!--bean class="org.springframework.remoting.rmi.RmiService Exporter"-->
    <!-- does not necessarily have to be the same name as the bean to be exported -->
    <!--property name="serviceName" value="AccountService" /-->
    <property name="service" ref="userAndregionService" />
    <property name="serviceInterface"
    value="com.gemalto.usermanager.service.IUserServic e" />
    <!-- defaults to 1099 -->
    <!--property name="registryPort" value="1199" /-->
    </bean>
    </beans>
    ][/QUOTE]
    web.xml

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-beans.xml</param-value>
    </context-param>
    <servlet>
    <servlet-name>remoting</servlet-name>
    <servlet-class>
    org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    </servlet>
    <servlet>
    <servlet-name>SpringContextServlet</servlet-name>
    <servlet-class>
    org.springframework.web.context.ContextLoaderServl et
    </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>remoting</servlet-name>
    <url-pattern>/AccountService</url-pattern>
    </servlet-mapping>
    spring-client.xml
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
    "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    <beans>

    <bean id="iu" class="com.gemalto.otapush.rmi.Account" lazy-init="true">
    <property name="accountService" ref="accountService" />
    </bean>

    <!--bean id="accountService"
    class="org.springframework.remoting.rmi.RmiProxyFa ctoryBean" lazy-init="true">
    <property name="serviceUrl"
    value="rmi://localhost:1199/AccountService" />
    <property name="serviceInterface"
    value="com.gemalto.usermanager.service.IUserServic e" />
    </bean-->

    <bean id="accountService"
    class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean" lazy-init="true">
    <property name="serviceUrl"
    value="http://localhost:8080/newcpad/AccountService" />
    <property name="serviceInterface"
    value="com.gemalto.usermanager.service.IUserServic e" />
    </bean>

    </beans>
    client testing coding :
    ...
    ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlPath);
    Account iu = (Account) ctx.getBean("iu");
    ...
    I test it use java client and it's no problem,but it's incorrected on IE brower when i connected it with tomcat container.
    i used servlet as flow:
    [QUOTEprotected ModelAndView handleRequestInternal(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
    String classpath = this.getClass().getResource("/").getPath();
    String xmlPath = "spring-client.xml";
    String Config_File = classpath + xmlPath;

    // this ctx
    ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlPath);
    Account iu = (Account) ctx.getBean("iu");
    System.out.println(iu.isAuthSystemUser("1111", "1111"));
    return null;
    }
    ][/QUOTE]
    exception:

    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'iu' defined in class path resource [spring-client.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/gemalto/usermanager/service/IUserService
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:408)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:360)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

  • #2
    I don't know where IE comes into play here. But it seems, that the IUSerService class is not known to the client.

    Regards,
    Andreas

    PS: Please use [ code] [ /code] tags instead of [ quote] [ /quote] tags for posting code and check the correct opening/closing. You may correct your posts even after submission.

    Comment


    • #3
      Originally posted by Andreas Senft View Post
      I don't know where IE comes into play here. But it seems, that the IUSerService class is not known to the client.

      Regards,
      Andreas

      PS: Please use [ code] [ /code] tags instead of [ quote] [ /quote] tags for posting code and check the correct opening/closing. You may correct your posts even after submission.
      Ye,my client don't narrow the Object in tomcat servlet,but in test case only in java main method it's ok,
      package test;

      import org.springframework.context.ApplicationContext;
      import org.springframework.context.support.ClassPathXmlAp plicationContext;

      import com.gemalto.otapush.rmi.Account;

      public class TestForRMIClient {

      /**
      * @param args
      */
      public static void main(String[] args) {
      String classpath = TestForRMIClient.class.getResource("/").getPath();
      String xmlPath = "spring-client.xml";
      String Config_File = classpath + xmlPath;

      // this ctx
      ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlPath);
      Account iu = (Account) ctx.getBean("iu");
      System.out.println(iu.isAuthSystemUser("1111", "1111"));

      }

      }
      result correctly:

      04-18 16:56:53-[INFO] JDK 1.4+ collections available
      04-18 16:56:53-[INFO] Loading XML bean definitions from class path resource [spring-client.xml]
      04-18 16:56:54-[INFO] Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=17829242]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [iu,accountService]; root of BeanFactory hierarchy
      04-18 16:56:54-[INFO] 2 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=17829242]
      04-18 16:56:54-[INFO] Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@64dc11]
      04-18 16:56:54-[INFO] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@ecd7e]
      04-18 16:56:54-[INFO] Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [iu,accountService]; root of BeanFactory hierarchy]
      04-18 16:56:54-[INFO] CGLIB2 available: proxyTargetClass feature enabled
      true

      Comment


      • #4
        That's ok,cause of interface file don't import in tomcat's classpath.

        Comment

        Working...
        X