I created a servlet for my GWT app made with eclipse. When I deploy it in TOMCAT works perfectly, but in Glassfish I have an 404 Error.
I have no deploy errors, the main html page loads well. But anything that use the RPC servlet gives me this error:
com.google.gwt.user.client.rpc.StatusCodeException: 404 Not Found
HTTP Status 404 - Not Found
type Status report
messageNot Found
descriptionThe requested resource is not available.
GlassFish Server Open Source Edition 4.1
My web.xml is like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>com.test.server.testServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/webclient/test</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Webclient.html</welcome-file>
</welcome-file-list>
</web-app>
In the stub for the RPC I have this com.test.client.testService :
#RemoteServiceRelativePath("test")
public interface testService extends RemoteService {
And the servlet:
public class testServiceImpl extends RemoteServiceServlet implements testService
Notes:
When the app runs in tomcat, if I write the servlet name in the URL it shows me this error:
localhost:8080/webclient/webclient/test
Status HTTP 405 - Method HTTP GET is not supported in this URL
It seems that in fact is loaded well. But when is in Glassfish:
HTTP Status 404 - Not Found
What i'm missing? Thanks!
The behaviour with the GET in TOMCAT is correct (405)..but the 404 is strange. Have u got more information in your Glassfish log?? . Check this items...
0). Check the pattern of the URL . The URL should be http://hostname/nameOfWAR/{urlPatter_into_web.xml}
1).Make a test just to deploy a HelloWord jsp on the root of the web apps..and check the app is well-deployed showing some result..
2). Assuming that "webclient" is your WAR application have u exported or included the gwt-user jar in your app on deploying to Glassfish: gwt-user-xxx.jar ? If you use Eclipse you can use the Deployment Assembly or just locate the jar into the lib location of the war.
3.) Check there is no problem with the serialization policy file on the compiled gwt classes . Its a .gwt.rpc file... This must be on classpath . If this is the problems it should be more info throug exceptions, , etc... [ Also is possible to overwrite the location of this file overwriting SerializationPolicy ]
Try to change #RemoteServiceRelativePath("test") to #RemoteServiceRelativePath("/webclient/test")
In generall, <servlet-mapping> element should be in the form of an absolute directory path your app. You can read this useful article http://www.gwtproject.org/doc/latest/tutorial/RPC.html
And please, classes should name with upper case. I understand that maybe it is a test project, but to quickly get used to bad.
Solved! I didn't check the server.log of glassfish. There was an error of casting of the RPC servlet:
rpc servlet cannot be cast to javax.servlet.Servlet
The problem was I messed up the libs and added javax* in the classpath, and Glassfish don't need this. I deleted all additional libs I left in domain/lib/ext, and worked perfectly.
Thanks for your support!
Related
I am trying to deploy a WAR file compiled in JDK 1.8 to an AWS Tomcat Elastic Beanstalk instance. the elastic beanstalk instance uses JDK 8 and Tomcat 8, so I don't understand why I'm getting 404 errors when deploying my WAR file. I'm using gradle to build and WAR the application if that is of any help.
the logs are too big to paste in, and I don't know what is significant, so I uploaded the bundled zip to my dropbox that you can find here:
https://www.dropbox.com/s/d1ssmz76pbqkn20/BundleLogs-1487348401257.zip?dl=0
my web.xml is also too long to paste in the question, so I will link to it here: https://www.dropbox.com/s/4m7v3fhcczs0ina/web.xml?dl=0
I know it's bad practice to give links on Stack Overflow because of their mutability, so once the solution is found I will edit the question to directly include the pertinent segments of code.
I am not too sure if this solved your issue. I had a similar issue and it was fixed after extending SpringBootServletInitializer. This is deone because my application runs using Tomcat 8, Java 8 platform, which is like a container. Generally you need to extends SpringBootServletInitializer when deploying a war in a container.
Here is a sample Application.java
#SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Your error is pretty straight forward:
org.xml.sax.SAXParseException; systemId: file:/var/lib/tomcat8/webapps/ROOT/WEB-INF/web.xml; lineNumber: 477; columnNumber: 23; Error at (477, 23) : The servlets named [TextHistoryServlet] and [TextHistoryServlet] are both mapped to the url-pattern [/TextHistoryServlet] which is not permitted
Around that line you'll see:
<servlet-mapping>
<servlet-name>CsvParseServlet</servlet-name>
<url-pattern>/CsvParseServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TextHistoryServlet</servlet-name>
<url-pattern>/TextHistoryServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TextHistoryServlet</servlet-name>
<url-pattern>/TextHistoryServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SurveyServlet</servlet-name>
<url-pattern>/SurveyServlet</url-pattern>
</servlet-mapping>
Remove the second mapping for TextHistoryServlet
I've developed a RESTful service with JAX-RS, using Jersey libraries. I've builded and compiled it (with no errors) and I've deployed it with Tomcat 8.0.
But when I access to the service through the browser, always the same error:
Status HTTP 404 - Not Found
type Informe de estado
message Not Found
description The requested resource is not available
Apache Tomcat/8.0.21
I've already past several days struggling with this, and I can't find a solution. I've followed multiples tutorials, some of them very easy ones, but none of them got my service working.
I've tried using IntellJ Idea and Eclipse. You can download the project and try the service from my Github:
https://github.com/daniegarcia254/SmartCULM.git
There are two branches apart from the master, one for the Eclipse project and the another one for the IntellJ Idea project.
Both projects use Maven repositories for the needed libraries that are in the respectives pom.xml.
I think my final mistake is that I don't nail the service URL, but I've tried in a thousand different ways. Maybe I have the wrong structure of project or the wrong web.xml config, don't sure anymore about anythin!
For extra info, here the URL I'think should be the one valid to access the RESTful service once it's deployed:
http://localhost:8080/smartculm/api/service/noticias
I'm not positive, but I think that you might be missing some data in your web.xml file. In the projects that I've worked on, I had to specify the class of my servlet and the location of my resource and application files.
<display-name> display-name </display-name>
<servlet>
<servlet-name>Some_Service_Name</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.resource.package.name</param-value>
</init-param>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.application.package.ApplicationClassName</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Some_Service_Name</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I believe that instead of "com.resource.package.name", you would probably use "main.java.rest.smartculm". I don't see an application in your project, so I'm not sure what you would use. I usually define my own application class by extending javax.ws.rs.core.Application. I also put all of the files that you have in your webapp directory in the WebContent directory at the root of my project, instead of being in the src directory.
A reference that I used to get started was:
http://www.vogella.com/tutorials/REST/article.html
Important:
The complete path to a resource is based on the base URL and:
display-name -> configured in the <display-name> tag in the web.xml
url-pattern --> configured in the <url-pattern> tag in the web.xml
path_from_rest_class --> defined by the #Path annotations in your classes
http://your_domain:port/display-name/url-pattern/path_from_rest_class
I am struggling for the past 6-7 hrs trying to figure out what went wrong with my Apache Tomcat Server. In all of my projects, the jdk version got switched to 1.6 from 1.8.
To solve the version conflict, I verified whether compiled version and JVM of Tomcat version are same by taking help from here.
For multiple contexts with the same path error, I know i need to remove duplicate Context tags in server.xml. So, first I check in Servers project (which gets created itself when you add Apache Tomcat Server in Eclipse) and find none there. So, I delve deep into the directory(Eclipse WorkSpace) metadata\.plugins\org.eclipse.wst.server.core\tmp3\conf and removed the duplicate Context tags over there, with help taken from here.
Now when i create a new Dynamic Web Project, everything works fine and I am able to see the web page. But if I try to access any of the HTML, XHTML files of those old project in which the jdk got changed, this org.apache.catalina.LifecycleException continues to pop up and the server fails to start, and consequently these duplicate Context tags continues to build up again and again every time i start the server.
None of my old Web application projects seems to work now.
java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext
[/EdBurns_ChrisSchalk]].....
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost]]
....
Caused by: java.lang.RuntimeException: Unexpected element value kind in
annotation: 0
How to prevent these context tags being build up again and again in server.xml.
Secondly, how to get back those old web projects to working state again?
I had a similar error and fixed it by following steps:
1. Under Servers project (which gets created itself when you add Apache Tomcat Server in Eclipse), open server.xml
2. Comment out the line
<Context docBase=... />
This will prevent multiple context tags to be created upon each request
1) Stop the server
2) Clean Tomcat's work directory
If you are not using annotation based Servlet then please remove annotation #WebServlet("/YourServletName") from the starting of the servlet. This annotation confuses the mapping with web.xml, after removing this annotation Tomcat server will work properly.
This seems to be an issue with local Maven repository. (i.e. .m2 folder) may be due to some corrupt .jar file
For me, the following actions helped to overcome this issue.
On my local file system, I've deleted the directory .m2 (Maven local repository)
In Eclipse, updated the project (select Maven > Update Project)
Ran the app again on Tomcat server.
Went through the various resources on the net but none of them helped then i deleted the existing server and added the same server again and now it is working fine and the steps are
Window>>ShowView>>Servers>>RightClick>>Delete
and then add the server again as you have added previously.
If you are using the following stack:
Server Version: Apache Tomcat/9.0.21
Servlet Version: 4.0 JSP Version: 2.3
Then try adding <absolute-ordering /> to your web.xml file. So your file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>spring-mvc-crud-demo</display-name>
<absolute-ordering />
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
......
In my case, the servlet-api.jar file in jre/lib/ext in the jdk directory conflicts with the servlet-api.jar file in tomcat, removing the servlet-api.jar in jre/lib/ext in the jdk directory can solve the problem.
Just make sure build with correct web.xml configuration.I have update web.xml with tomcat configuration and it worked for me.
Sample :-
<?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>simulator</display-name>
<description>simulator app</description>
<!-- File upload -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- excel simulation -->
<display-name>simulator</display-name>
<description>simulator app</description>
<!-- File upload -->
<welcome-file-list>
<welcome-file>InsertPage.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>FileUploadServlet</servlet-name>
<servlet-class>clari5.excel.FileUploadServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FileUploadServlet</servlet-name>
<url-pattern>/excelSimulator/FileUploadServlet</url-pattern>
</servlet-mapping>
</web-app>
One of the problems that can cause this is when you forget to put the / character in the WebServlet annotation #WebServlet("/example") #WebServlet("example")
I hope it works, it worked for me.
Below solution worked for me:
Navigate to Project->Clean..
Clean all the projects referenced by Tomcat server
Refresh the project you're trying to run on Tomcat
Try to run the server afterwards
I think it is jar file version problem. I had the same issue and I fixed it by changing the commons-codec-1.6.jar file from the build path. Earlier I was using latest version 1.10. Gradually I decreased the versions and 1.6 version fixed my issue.
Go to the task manager, kill the java processes and turn the server back on.
should work fine.
This question already has answers here:
The ResourceConfig instance does not contain any root resource classes
(25 answers)
Closed 4 years ago.
I'm new to jersey and web services and I'm try to run a simple RESTful web service. I followed http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/ but my project doesn't use maven and I download the jersey.1.17.1.jar and include it to my project path.
When I want to call the service on http://localhost:8080/sycotext/rest/service/SOMETEXT I get this error :
HTTP Status 500 - Servlet.init() for servlet sycoText-servlet threw exception
this is the stack trace :
javax.servlet.ServletException: Servlet.init() for servlet sycoText-servlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:515)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1010)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1618)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1576)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
root cause
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99)
com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1331)
com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168)
com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774)
com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770)
com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770)
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765)
com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:489)
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319)
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:515)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1010)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1618)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1576)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
here is my code :
package ir.sycotech.text.server.service;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
#Path("/service")
public class SycoTextService {
#GET
#Path("/{param}")
public Response getMsg(#PathParam("param") String msg) {
String output = "Jersey say : " + msg;
return Response.status(200).entity(output).build();
}
and here is my web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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>Restful Web Application</display-name>
<servlet>
<servlet-name>sycoText-servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>ir.sycotech.text.server.service</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sycoText-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I have specified my packagename correctly in the web.xml file and I don't know why I got this error, I will be really appreciate if anyone knows what is the problem
The error:
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
means that Jersey can't find service classes. That can be caused by a wrongly named package for the com.sun.jersey.config.property.packages parameter or if the package name is correct but it does not contain resource classes (people sometimes forget to add the #Path annotation on the class).
But I can't find anything wrong with your setup. So this should work!
Check that your application deployed correctly and that your WEB-INF/classes folder actually contains your class with the proper folder path for the package.
Do a full clean and rebuild then try again.
I do not no the actual problem you are facing.
You can dwonload an example https://github.com/kdmalviyan/RestWithJerseyExample.git
you have to take following actions after downloading:
1. mvn clean install
2. deploy war to your server
3. access "JerseyExample-0.0.1-SNAPSHOT/rest/hello/hello Kuldeep Singh" on your server
You will get Output like: Jersey say : hello Kuldeep Singh
I suggest you to follow exact steps without any change anything first. If you get correct result then you can modify according to your need. Please make sure if you are renaming package, rename package in web.xml too.
I just ran into this problem using Grizzly with jersey.
When you fire up a a Grizzly container you have to pass in a map telling Grizzly where to find your resources. If you created your project from an archetype like I did or just moved some things around you also have to update this value which is easy to overlook.
final static String YOUR_PACKAGE_NAME_GOES_HERE = "where.ever.your.resource.package.happens.to.be"
final Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages",
YOUR_PACKAGE_NAME_GOES_HERE);
System.out.println("Starting grizzly...");
SelectorThread threadSelector = GrizzlyWebContainerFactory.create(BASE_URI, initParams);
I ran into this issue, as well. There were two things that I did to get it to work, with the first being unrelated to this problem.
First, I'm using jersey 1.19. However, I didn't realize there was a file named
javax.ws.rs-api-2.0.jar in the WEB-INF/lib on the server. This file was added two years ago and, IIRC, works in conjunction with jersey 2.x but not 1.x. I effectively removed the file (renamed it with .bak as its extension).
Second, I created a JAR file in Eclipse for the web service. I did not use Maven or Ant or anything like that. Just a simple export. Now, the error can mean there is nothing in your code that references jersey. But I wrote a simple test class and everything should be working, I thought. Turns out the export wasn't creating the JAR file properly. I opened the JAR and the class was empty. No wonder it was generating this error! I exported once more and instead of checkmarking Export generated class files and resources, I checkmarked Export all output folders for checked projects. I also have multiple packages in this one project so that could be related to why the export wasn't functioning properly. Once I did that, it worked!
I tried the export again but, this time, I checkmarked Export generated class files and resources and selected every resource in the project. What was different from last time was I selected .settings. Last time, .settings wasn't selected. Again, this worked, too!
I hope this helps someone out there with a similar problem. Sometimes, it's just something as stupid as confirming your JAR file is correct. I use java decompiler to inspect the JAR file.
I encounter similar problem. Please check your initialization process whether you have registered the api class properly.
In your case, the initialization class is ir.sycotech.text.server.service
You need to register all api class in service.
Here is my example:
I will hit the error if the following classes are not registered, ( register(CtoFService.class);
register(FtoCService.class);
register(TriggerCmd.class);)
*<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>my.mimos.hcserver.init.MyApplication</param-value>
</init-param>*
#ApplicationPath("/HCRestServer/")
public class MyApplication extends ResourceConfig{
public MyApplication() {
System.out.println("******Started!*****");
register(CtoFService.class);
register(FtoCService.class);
register(TriggerCmd.class);
register(CORSResponseFilter.class);
System.out.println("******Done registration!*****");
}
}
Please ensure that your package "com.sun.jersey.config.property.packages" is registered correctly in Web.xml ... Good Luck !!
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servletclass>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.rest.service</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
If you trying to use HttpServerFactory, you must pass a PackagesResourceConfig.
Example:
ResourceConfig rc = new PackagesResourceConfig("com.package");
HttpServerFactory.create(getBaseURI(), rc);
I had the same problem, which I solved by specifying BOTH the classes package AND removing load-on-startup altogether, i.e.:
<servlet>
<servlet-name>my-servlet-name</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>my.package.name</param-value>
</init-param>
<!-- <load-on-startup>1</load-on-startup> -->
</servlet>
I guess because I had more than one servlet under the same package and Jersey coudn't pick the "root" one to be loaded on startup.
Well, none of the above answers worked for me. They made me double check every step and package name, though. As Bogdan said, there were no compiled classes inside the target/classes/ folder.
Check that your application deployed correctly and that your WEB-INF/classes folder actually contains your class with the proper folder path for the package.
My solution was just cleaning the project and compiling different. Instead of just going for mvn war:war I did:
$ mvn clean:clean
$ mvn compile
$ mvn war:war
Then it compiled fine and the OP error disappeared.
I'm learning how to develop SOAP web services with Java.
So far now I've been following this excellent tutorial
http://web.archive.org/web/20120626005333/http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/
It all goes well, I have my web service working from the command line with it's embedded server and then, with the help of NetBeans I deployed it on Tomcat.
I'd like to know the steps to manually deploy it on Tomcat, in order to learn how it's done and because I don't like depending on an IDE.
I mean, I'd like to know how everything could be done from the command line and a text editor.
I've also found this link that explains how to manually deploy a servlet to Tomcat,
http://linux-sxs.org/internet_serving/c292.html
but I couldn't find any article telling how to deploy a web service.
Thanks a lot.
How to MANUALLY build and deploy a jax-ws web service to tomcat
I was trying to figure out how to MANUALLY build and deploy a web service for learning pourposes.
I began with this excellent article
http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/
(new URL: http://www.oracle.com/technetwork/articles/javase/jax-ws-2-141894.html)
The idea was to do the whole thing using only a notepad and the command line.
The only way I could achieve was by deploying a web service with netbeans, and then having a look at the war generated file at \dist\.war (it's just a zip file, you can open it with 7zip)
I leave this in case anybody is interested and for documentation purposes...
If anybody knows an easier way please let me know!!!
tested on:
C:\tomcat6\bin>version
Server version: Apache Tomcat/6.0.26
Server built: March 9 2010 1805
Server number: 6.0.26.0
OS Name: Windows XP
OS Version: 5.1
Architecture: x86
JVM Version: 1.6.0_18-b07
JVM Vendor: Sun Microsystems Inc.
saludos
sas
1. create the following dir c:\java\src\ws
2. create thew following file c:\java\src\ws\Adder.java
// c:\java\src\ws\Adder.java
package ws;
import javax.jws.WebService;
#WebService
public class Adder {
public double add( double value1, double value2 ) {
return value1 + value2;
}
}
3. standing at c:\java\src\ execute
c:\java\src> javac ws\Adder.java
file c:\java\src\ws\Adder.class will be generated
4. create the following directory structure with the following files
c:\tomcat6\webapps\adder_ws
META-INF
context.xml
WEB-INF
classes
ws
Adder.class
lib
activation.jar
webservices-api.jar
webservices-extra.jar
webservices-extra-api.jar
webservices-rt.jar
webservices-tools.jar
sun-jaxws.xml
web.xml
5. copy compiled file
copy c:\java\src\ws\Adder.class c:\tomcat6\webapps\adder_ws\WEB-INF\classes\ws\Adder.class
6. c:\tomcat6\webapps\adder_ws\META-INF\context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/adder_ws"/>
7. c:\tomcat6\webapps\adder_ws\WEB-INF\web.xml
<?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">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Adder</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>Adder</servlet-name>
<url-pattern>/add</url-pattern>
</servlet-mapping>
<!-- not needed
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
-->
</web-app>
8. Config WEB-INF\sun-jaxws.xml
file : c:\tomcat6\webapps\adder_ws\WEB-INF\sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="ws.Adder" name="Adder" url-pattern="/add"/>
</endpoints>
9. Copy libraries
files at c:\tomcat6\webapps\adder_ws\WEB-INF\lib
copy netbeans files from
[netbeans dir]\enterprise\modules\ext\metro\*.*
and
[netbeans dir]\ide\modules\ext\jaxb\activation.jar
10. restart apache
Shutdown : c:\tomcat6\bin\shutdown.bat
Startup : c:\tomcat6\bin\startup.bat
11. Test
Open a web browser and go to http://localhost:8080/adder_ws/add?wsdl
you can also use a tool like soapui (http://www.soapui.org/) to test the web service
that's it, I guess now I'll have a look at the way eclipses does it...
here's another useful article
it kind of answer my very own question
http://java.dzone.com/articles/jax-ws-deployment-five-minute
Following articles has step by step guide to manually build and deploy JAX-WS web services. It uses Ant as build tool.
Building JAX-WS Web service
I would expect the deployable to be the same for a web service and a servlet. Namely, a .war file. So you should be able to deploy it in the same fashion.
I see that nobody has mentioned JAX-WS Tutorials from Mkyong.com.
In the "JAX-WS Security in Tomcat" section on the "JAX-WS Tutorial" page, there is a short, to the point and with pictures tutorial, just what the OP wanted:
Deploy JAX-WS web services on Tomcat