Note that there are some explanatory texts on larger screens.

plurals
  1. POrestful webservices with apache cxf and spring
    primarykey
    data
    text
    <p>i have two classes which i want to expose as a restful web services using apache cxf and spring but i am unable expose two web services of two different classes.i got a runtime exception while invoking second service.here are my web.xml,applicationcontext.xml and two classes which i am using in my project.plz any one fix this issue </p> <pre><code> `enter code here` web.xml -------- &lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" &gt; &lt;web-app&gt; &lt;display-name&gt;ApacheCXF Sample Application&lt;/display-name&gt; &lt;!-- Add for Spring support --&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener- class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.apache.cxf.transport.servlet.CXFServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;com.sun.jersey.config.property&lt;/param-name&gt; &lt;param-value&gt;com.iton.restExamples.ServiceOneImpl&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet&gt; &lt;servlet-name&gt;AnotherCXFServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.apache.cxf.transport.servlet.CXFServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt; &lt;param-value&gt;com.iton.restExamples.ServiceTwoImpl&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;CXFServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/base/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;AnotherCXFServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/another/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; applicatin context.xml ------------------------ &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"&gt; &lt;context:component-scan base-package="com.example" /&gt; &lt;!-- &lt;import resource="classpath:META-INF/cxf/cxf.xml" /&gt; &lt;import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /&gt; &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml" /&gt; --&gt; &lt;jaxrs:server id="restContainer" address="/"&gt; &lt;jaxrs:serviceBeans&gt; &lt;ref bean="serviceOne"/&gt; &lt;ref bean="serviceTwo"/&gt; &lt;/jaxrs:serviceBeans&gt; &lt;/jaxrs:server&gt; &lt;bean id="serviceOne" class="com.iton.restExamples.ServiceOneImpl"&gt;&lt;/bean&gt; &lt;bean id="serviceTwo" class="com.iton.restExamples.ServiceTwoImpl"&gt;&lt;/bean&gt; &lt;/beans&gt; ServiceOneImpl.java --------------- package com.iton.restExamples; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; public class ServiceOneImpl implements ServiceOne { public ServiceOneImpl() { // TODO Auto-generated constructor stub } @Override @GET @Produces("text/plain") @Path("/one") public String mesgTwo(@QueryParam("msg") String mesgTwo) { System.out.println(mesgTwo); System.out.println("welcome message"); return mesgTwo; } } SeriveTwoImpl.java ------------------- package com.iton.restExamples; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; public class ServiceTwoImpl implements ServiceTwo { public ServiceTwoImpl() { // TODO Auto-generated constructor stub } @Override @GET @Produces("text/plain") @Path("/two") public String mesgTwo(String mesg) { mesg="Welcome"; System.out.println(mesg); System.out.println("welcome message in Serive two"); return mesg; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload