I am having trouble navigating to my restful service using resteasy 2.1 on localhost and was hoping someone here might be able to help me.
I have built an EAR file with a WAR inside and is seems to compile and deploy to JBoss5 ok.
My service simplified:
#Path("RequestReply")
public class Replier {
#GET
#Path("request")
public String getReply(#QueryParam("id") #DefaultValue("") String id){
if (id.length > 0){
return "ACK";
}
return "NACK";
}
}
My web.xml file is standard:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Test service</display-name>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
So I try to access my API using
http://localhost:8080/RequestReply/request?id=1234
But I get 404 errors.
Can anyone tell me what I am doing wrong?
Application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="java.sun.com/xml/ns/javaee"; xmlns:xsi="w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/application_5.xsd"; version="5">
<display-name>Reseasy</display-name>
<module>
<java>simple.jar</java>
</module>
</application>
Ok so I would suggest trying something like:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
version="5">
<display-name>Reseasy</display-name>
<module>
<web>
<web-uri>Replier.war</web-uri>
<context-root>/api</context-root>
</web>
</module>
</application>
Here the Replier.war refers to the name of the WAR file you create and /api refers to the base of your request URL. So it should look like:
http://localhost:8080/api/RequestReply/request?id=1234
Give that a shot!
Related
I'm trying to build custom URL as prettyfaces tells that it do, but after setup it, it gives me this error:
Referenced file contains errors (http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
This is how my web.xml setup:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>BRAINSET</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
</web-app>
And my pretty-config.xml :
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/prettyfaces/3.3.3
http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/index.xhtml" />
</url-mapping>
With this error I can't even deploy my app in Glassfish:
Could not publish to the server.
java.lang.NullPointerException
Any idea how to fix this ? Or should I look for another tool similar to prettyfaces ?
update
I don't think that this error is caused by PrettyFaces. The XML schema works fine in my Eclipse setup and I don't get any of these errors. And I'm pretty sure that the XSD file is valid.
You should have a look at the Eclipse log file (WORKSPACE/.metadata/.log) to have a look if there is any exception thrown.
BTW: You could also try to remove the schemaLocation element from your pretty-config.xml and check if this helps. PrettyFaces doesn't use the XSD schema when parsing the file. Something like this:
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3">
...
</pretty-config>
Finally figured this out.... so the reason this XSD isn't valid is because the document has this:
<?xml version="1.0" encoding="UTF-8" ?>
instead of:
<?xml version="1.0" encoding="UTF-8"?>
If anyone knows how to get ahold of Lincoln to fix this, that'd be great!
This question already has answers here:
Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI [...] in DispatcherServlet"?
(13 answers)
Closed 6 years ago.
The following are my configuration file i configured
WEB-INF/classes/applicationContext.xml but it searching for
WEB-INF/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="starter_anil" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Anil-Spring</display-name>
<!-- Servlets -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- Listeners -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
i am getting following exception
EVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
here is my applicationContext
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<import resource="config/controllers.xml" />
<!-- <import resource="conf/spring/services.xml" />
<import resource="conf/spring/persistence.xml" />
<import resource="conf/spring/daos.xml" />
<import resource="conf/spring//interceptors.xml" /> -->
</beans>
the solution for this is
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="starter_anil" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Anil-Spring</display-name>
<!-- Servlets -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<!-- Listeners -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
WARNING: No mapping found for HTTP request with URI
[/AnilsSpring/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name
'mvc-dispatcher'
please guide line me once
Why is your applicationContext is in the classes? Move it to the WEB-INF directory, as it is told in the comment. That should fix the problem.
The /classes directory is for the compiled classes, but not for the configuration files.
Try adding a / in /WEB-INF/classes/applicationContext.xml
If it still doesn't work, try adding this instead in your web.xml (before the servlet declaration)
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="starter_anil" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Anil-Spring</display-name>
<!-- Servlets -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<!-- Listeners -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
this made exception less start on tomcat but i am little bit confused
If that's where you absolutely must have it, try this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="starter_anil" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Anil-Spring</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<the-rest-of-your-stuff />
</web-app>
You might need a / before applicationContext.xml, but I don't think so.
May be you need to do undeploy. and deploy it. it will work . .
it works for me for the exception
IOException parsing XML document from ServletContext resource [/WEB-INF/classes/spring application config.xml];
WEB-INF/classes/applicationContext.xml for this requirement, you have to put applicationContext.xml in class path i.e.
If you are using maven then put it in src/main/resources folder, otherwise put in the src folder.
Then you will find it inside WEB-INF/classes
I am fairly new to Apache CXF and tomcat. I am trying to build a simple web service and deploy it on tomcat. below is my web.xml
However when I try to access the 'services' folder using my browser it says No services have been found. I tried creating java web service client but it is not able to locate the service either. What could be wrong in this?
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Sample web service provider</display-name>
<listener>
<!-- For Metro, use this listener-class instead:
com.sun.xml.ws.transport.http.servlet.WSServletContextListener -->
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- Remove below context-param element if using Metro -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/cxf/cxf.xml
</param-value>
</context-param>
<servlet>
<servlet-name>WebServicePort</servlet-name>
<!-- For Metro, use this servlet-class instead:
com.sun.xml.ws.transport.http.servlet.WSServlet -->
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WebServicePort</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>
This means that you don't have any services exposed in your application. Your web.xml seems to be correct but I've just missed one thing, your Spring configuration. Add your Spring config location in your web.xml, for e.g.:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>
Also, you have to create a class which will implement your web service interface and expose it as the CXF endpoint in your Spring applicationContext.xml configuration file. For e.g.:
<bean id="candidateImpl" class="some.pckg.CandidateImpl"/>
<jaxws:endpoint id="candidateEndpoint"
implementor="#candidateImpl"
address="/Candidate"
/>
Your CandidateImpl class should have #WebService annotation. For e.g.:
#WebService(targetNamespace = "http://something.com/ws/candidate",
portName = "CandidateService",
serviceName = "Candidate",
endpointInterface = "some.pckg.types.CandidateService",
wsdlLocation = "WEB-INF/wsdl/CandidateService.wsdl")
public class CandidateImpl implements CandidateService {
//Implementation of all methods from CandidateService.
}
If you've done everything correctly you should see that there is one service available under:
http(s)://whateverhost.com:<somePort>/SomeContextPath/services
And you should be able to get the WSDL file like this:
http(s)://whateverhost.com:<somePort>/SomeContextPath/services/Candidate?wsdl
See also:
Writing a Web Service with Spring
You need to set the spring configuration file location to make this work. You can set it as follows.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>
You need to configure a servlet in your web.xml. Below an example.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<init-param>
<param-name>config-location</param-name>
<param-value>/WEB-INF/spring-ws-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
Now you need to define a file named spring-ws-servlet.xml under WEB-INF folder. Below an example of the content of spring-ws-servlet.xml, which contains the actual configuration for your web service. This depends on your logic, of course:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<context:component-scan base-package="com.sample.service"/>
<!-- JAX-WS Service Endpoint -->
<bean id="personImpl" class="com.sample.service.impl.PersonServiceImpl"/>
<jaxws:endpoint id="personEndpoint"
implementor="#personImpl"
address="/person">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
<!-- JAX-WS Service Endpoint End-->
</beans>
With this, you can access your web service under http://localhost:8080/services/person?wsdl
This is taken from this post. It is a tutorial about creating a Cxf service with IntelliJ Idea and Spring
https://aldavblog.wordpress.com/2015/01/22/creating-a-web-service-from-scratch-using-spring-maven-apache-cxf/
I'm building a web App using JSF 2.0 and had a jaf-facelets.1.1.10 jar in my WEB-INF > lib folder, so now I'm trying to remove that so I can use the built int facelets 2.0 I was reading through this Question which balusC answered and I've done that, except teh part where it saysI need to replace FaceletViewHandler by ViewHandlerWrapper. for that I saw this question, but I don't have any faceletViewhandler classes in my project.
as of now, my webxml looks like this ( please check taht I didn't miss anything, or I'm referencing something I shouldn't:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>miloWeb</display-name>
<welcome-file-list>
<welcome-file>faces/pages/index.xhtml</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.bravo.listeners.ServletListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>PdfServlet</servlet-name>
<servlet-class>com.bravo.servlets.PdfServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PdfServlet</servlet-name>
<url-pattern>/PdfServlet</url-pattern>
</servlet-mapping>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<context-param>
<description>
This is to Have separated faces.config files
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/pages/history/faces-config.xml,
/pages/contactInformation/faces-config.xml,
/pages/childHealthRecord/faces-config.xml,
/pages/dashboard/faces-config.xml,
/pages/insurance/faces-config.xml,
/pages/search/faces-config.xml,
/pages/labs/faces-config.xml,
/pages/patient/faces-config.xml,
/pages/physical/faces-config.xml,
/pages/notes/faces-config.xml,
/pages/scheduler/faces-config.xml,
/pages/settings/faces-config.xml,
/pages/orderEntry/faces-config.xml,
/pages/vitals/faces-config.xml
</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
</web-app>
And as you can see, I have quite a few faces-configs I removed the
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
And now it looks like this ( I know some features I don't need like the navigation, but does it really hurt to keep it taht way?):
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>vitalsBB</managed-bean-name>
<managed-bean-class>com.bravo.vitals.VitalsBB</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>vitals</from-outcome>
<to-view-id>/pages/vitals/vitals.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
after doing some changes and leaving it like that, I run the project on tomcatv7 and get this error:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:452)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
Does that look like an error I would get for having my files like this? because all I did was remove the jar-facelets.1.1.10.jar and now I'm getting this Error. But teh App works fine b4 I remove the facelets jar, so what is the relationship between these two jars??
I tried adding the jstl.jar but that doesn't work, it just shows me this:
The error suggest include jstl-1.2.jar available here in the same folder where your jsf jars are.
There is no need for facelets 2.0 jar, because JSF 2.0 adopted facelets as its default View Declaration Language (VDL), and now it is bundled inside jsf jars (for both MyFaces and Mojarra)
To solve this issue, I had to Add the jstl-impl.jar and jstl-api.jar and update to the latest jsf-impl.jar and jsf-api.jar. That fixed it.
Don't really know why it never complained about it when the facelets.1.10.jar was there.
Just started using JAX-WS. I created 2 test web services in the one WAR file as follows....
package com.djs;
import javax.jws.WebService;
#WebService()
public class AddTwoInts {
public int performAdd(int firstNum, int secondNum) {
return firstNum + secondNum;
}
}
And.....
package com.djs;
import javax.jws.WebService;
#WebService()
public class SayHello {
public String sayHello(String inwards) {
return "Hello " + inwards;
}
}
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>jaxws</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jaxws</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
This is the sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
<endpoint name='performAdd' implementation='com.djs.AddTwoInts' url-pattern='/AddTwoInts' />
<endpoint name='sayHello' implementation='com.djs.SayHello' url-pattern='/SayHello' />
</endpoints>
I deploy into Tomcat 7 and use http://localhost:8080/MyApp/AddTwoInts?wsdl to get the WSDL for AddTwoInts OK.... But when I execute http://localhost:8080/MyApp/SayHello?wsdl I get a 404 page not found error....
Any advice appreciated.
Dave,
I guess you are missing the servlet-mapping for the two end points you have.
Add the following to your web.xml and try again. Let me know if this solve the problem.
<servlet>
<servlet-name>AddTwoInts</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AddTwoInts</servlet-name>
<url-pattern>/AddTwoInts</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SayHello</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SayHello</servlet-name>
<url-pattern>/SayHello</url-pattern>
</servlet-mapping>
You want the web.xml to reference only one servlet, at urlMapping /:
<servlet>
<servlet-name>services</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>services</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Then, include multiple endpoints at the full desired path in sun-jaxws.xml:
<endpoint name='performAdd' implementation='com.djs.AddTwoInts' url-pattern='/AddTwoInts' />
<endpoint name='sayHello' implementation='com.djs.SayHello' url-pattern='/couldhavemore/SayHello' />
Note the "couldhavemore" in there... you can add to the relevant path in the sun-jaxws.xml file to get the full desired path. I've gotten a single service to work with a web.xml entry of something other than /, but then you need a web.xml entry for every service. It seems to get multiple to work you need to use / and then put the full path in sun-jaxws.xml.