Web Service not accessible on Tomcat 7 - 404 error - web-services

Hi Friends
I have created a sample web service using netbeans 7.3. It works fine on localhost when running through tomcat linked with netbeans.
When I deploy it in webapps folder of the tomcat 7 on any standalone machine, it works fine too. BUT when we transfer the code from webapps to public_html folder of online linux server, I get 404 error. please see the file. Online server has tomcat 7 which is linked through with Apache
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd">
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>EduCloudWS</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>EduCloudWS</servlet-name>
<url-pattern>/EduCloudWS</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
sun-jaxws.xml
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
<endpoint implementation="com.educloud.ws.EduCloudWS" name="EduCloudWS" url-pattern="/EduCloudWS"/>
</endpoints>
I am trying to access by following links, both don't work and give a 404 error
http://domainname.com/EduCloudWS
http://domainname.xom/EduCloudWS/EduCloudWS
Thanks for the help

Related

Jersey RESTful deployment on Tomcat 6

I am using the following setup to deploy a REST webservice on Tomcat 6 and it works:
<web-app>
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
With the above setup, Tomcat scans WEB-INF/classes and WEB-INF/lib folders for the resources.
I then changed it to the following setup to use Application sub-class:
<web-app>
<servlet>
<servlet-name>RestServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>test.MyApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
where test.MyApplication is the sub-class of Application returning the resource class:
public class MyApplication extends Application {
public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<Class<?>>();
s.add(MyResource.class);
return s;
}
}
But still the server scans WEB-INF/classes and WEB-INF/lib for the resources.
What am I missing? Does the server still scan WEB-INF when Application subclass is set in the web.xml?
Does the server still scan WEB-INF when Application subclass is set in the web.xml?
No it doesn't. The documentation explains that scanning the path is done if no resource configuration related initialization parameters (like javax.ws.rs.Application) are present.
You should see what's in your server logs. When Jersey initializes it logs what it's doing and for a classpath scan it prints something like:
INFO: Scanning for root resource and provider classes in the Web app resource paths:
/WEB-INF/lib
/WEB-INF/classes
When you provide an Application class it prints this instead:
INFO: Instantiated the Application class test.MyApplication
You should make sure that the proper web.xml file is deployed when the server starts. Maybe you still have the old version deployed.

Tomcat 6.0 Deployment Error

I am having problems deploying my web application, and it has been puzzling me for 3 weeks after continually blaming our hosting company and their server.
First of all, the web application was deploying fine using manager on tomcat 5.
Then I asked to change to tomcat 6, which they did, and now the application does not deploy and gives the now all so familiar SEVERE: Error deploying configuration descriptor XXXX.xml.
BUT in Eclipse I build and run my application on Tomcat 6 which works fine!, but when again when I try and deploy the packaged war on my local server via manager, I get the SEVERE error.
There is something wrong with my deployment descriptor which is sensitive to tomcat but not in eclipse. I read somewhere about case sensitive and I have double checked this.
I have then tried and commented out the context - still does not work, and everything in web.xml apart from the welcome-file-list. Still I get the same error.
I am out of ideas and very confused.
Below I have posted web.xml and context.xml (for confidentiality reasons I have to XXXX out the names).
<?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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>XXXX</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>restSdkService</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.XXXX.core.TestWebApp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>restSdkService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<resource-ref>
<description>MySQL Datasource example</description>
<res-ref-name>jdbc/XXXX</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/emotifi" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="XXXX" password="XXXX"
driverClassName="com.mysql.jdbc.Driver"
url="XXXX"/>
<Resource name="jdbc/emotifi_web" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="XXXX" password="XXXX"
driverClassName="com.mysql.jdbc.Driver"
url="XXXX"/>
</Context>

ClassNotFoundException,Missing ServletContainerAdaptor

I am creating one REstfulwebservices project. When ever I am going to run this
project then I am getting this error. ClassNot FoundException...ServletAdaptor
problem.
SEVERE: Servlet /XybuyProject threw load() exception
java.lang.ClassNotFoundException:
com.sun.jersey.server.spi.container.servlet.ServletAdaptor
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:996)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4834)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5155)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5150)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
This is Web.xml :
<?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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>FirstProject</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index2.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>
com.sun.jersey.server.spi.container.servlet.ServletAdaptor
</servlet-class>
<init-param>
<param-name>com.sun.jersy.config.property.packages</param-name>
<param-value>com.xybuy.webservice</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/REST/*</url-pattern>
</servlet-mapping>
</web-app>
can you tel me what is the problem behind it.....
Based on the stacktrace, you seem to be using Tomcat, which is a barebones JSP/Servlet container and not a full fledged Java EE container. Jersey is a JAX-RS implementation which is usually already bundled in fullfledged Java EE application servers such as Glassfish. Perhaps you were reading a Jersey book/tutorial or downloading a sample targeted on Glassfish or another Java EE container and thus it will be assumed that you don't need to install it separately.
However, on Tomcat, Jersey is thus not bundled and you will get ClassNotFoundExceptions on Jersey classes when declaring them in web.xml. You need to download the Jersey JAR file(s) separately and drop them in /WEB-INF/lib folder of the webapp.

Access IIS Express on a VMWare Win7

I'm running a ASP.NET MCV 4 project in VS2012 on a windows 7 virtual machine using VMWare. I want to be able to access the site from my mac.
I've done all the steps stated in this question. Restarted IIS, turned off windows firewall, changed the application config file and granted remote access to the ACL and I still get a 503 error in my mac.
Any steps I could have missed?
application config file is the following:
<site name="prototype" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\Igor Popov\Desktop\myapp\prototype" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":50438:192.168.0.9" />
</bindings>
</site>
1.Editing applicationhost.config file, your site bindings should look like below;
<binding protocol="http" bindingInformation="*:50438:localhost" />
2.Run your VS as administrator.
3.Visite the site with "localhost:50438" in your mac.

setting the ContextPath in Jetty running under ServiceMix (OSGI)

Here is my brief background of environment.
I am trying to convert a myapp WAR to an OSGi compliant by making the MANIFEST.MF as shown below, and wanted to deploy this war in ServiceMix an OSGi based container.
MANIFEST.MF
Manifest-Version: 2.0
Bundle-SymbolicName: myapp
Bundle-Version: 2.1.dev
Bundle-Name: Jetty.myapp
Bundle-Vendor: ABC
Created-By: 1.6.0_25-b06 (Sun Microsystems Inc.)
Bundle-ClassPath: .,WEB-INF/lib, WEB-INF/classes, xforms/xsltforms
Web-ContextPath: myapp
Webapp-Context: myapp
Import-Package: javax.servlet
Built-By: root
Project-Name: ABC_PRJ
Project-Version: 2.1.dev
Project-Build: ${DSTAMP}
SVN-Revision: ${svn.revision}
The ContextPath is getting set to null, where should I set the contextPath and how? You may observe the 'null' string in the FileNotFound Exception.
log:
java.io.FileNotFoundException: null/WEB-INF/myForms-config.xml (No such file or
directory)
My web.xml in myapp is :
<contextPath>/</contextPath>
<context-param>
<param-name>myForms.configfile</param-name>
<param-value>WEB-INF/myForms-config.xml</param-value>
</context-param>
Is it the problem with myapp or jetty or serviceMix? Any Clue?
You need to set the web-contextpath via the Manifest and not via the web.xml
for more information take a look at Pax-Web