Summary of the use of MyEclipse rest WebService (Jersey) __web

Source: Internet
Author: User

Java.lang.ClassNotFoundException:com.sun.jersey.spi.container.servlet.ServletContainerDownload the corresponding version from Http://mvnrepository.com/artifact/com.sun.jersey/jersey-bundle, put it under Webroot/web-inf/lib, right-click, and add to build Path Java.lang.noclassdeffounderror:org/objectweb/asm/classvisitorDownload: Asm-commons-3.3.jar http://www.java2s.com/Code/Jar/a/Downloadasmcommons33jar.htm Download: Asm-3.3.jar http:// www.java2s.com/Code/Jar/a/Downloadasm33jar.htm Download: Asm-tree-3.3.jar http://www.java2s.com/Code/Jar/a/ Downloadasmtree33jar.htm Join Build Path
Com.sun.jersey.api.container.ContainerException:The ResourceConfig instance does not contain any root resource Classes.RESTful project does not define webservice, define a webservice. No provider classes found.This is a hint message, not an error message. Change the Jersey servlet in Web.xml from "Com.sun.jersey.spi.container.servlet.ServletContainer" to " Com.sun.jersey.spi.spring.container.servlet.SpringServlet ".
Also add @provider annotations to the class, such as:
Package com.cn;

Import Javax.ws.rs.GET;
Import Javax.ws.rs.Path;
Import javax.ws.rs.Produces;
Import Javax.ws.rs.QueryParam;
Import Javax.ws.rs.ext.Provider;
@Provider
@Path ("/hellows") public
class HelloService {

	@GET
	@Path ("/hello{name}")
	@Produces ("Application/json")
	Public String SayHello (@QueryParam ("name") string name) {
		throw new unsupportedoperationexception (' not yet Implemented. ");
	}
}


Java.lang.ClassNotFoundException:com.sun.jersey.spi.spring.container.servlet.SpringServletDownload: http://www.java2s.com/Code/Jar/j/Downloadjerseyspring15jar.htm Com.sun.jersey.api.container.ContainerException:The ResourceConfig instance does not contain any root resource Classes.In <servlet> (including Com.sun.jersey.spi ...) ) Riga
  	<init-param>
   		<param-name>com.sun.jersey.config.property.packages</param-name>
   		< Param-value>com.cn</param-value>
	</init-param>
Javax.servlet.ServletException:Error allocating a servlet instanceRestart Tomcat
This page contains the following errors:
error on line 1 at column 1:document are empty
Below is a rendering of th E page up to the.
Change the method @produces (Mediatype.text_xml) to @produces ("Application/json") and MIME Media type Application/json is not found
Download: http://owlike.github.io/genson/
Servlet Jersey REST Service is not available (page tip this error)Failed to Classload type while reading annotation metadata. This is a non-fatal error and but certain annotation metadata may be unavailable.
Java.lang.ClassNotFoundException:javax.ws.rs.Path (console prompts this error) Download: http://www.java2s.com/Code/Jar/j/ Downloadjsr311api111jar.htm Unable to process Application/x-www-form-urlencoded;charset=utf-8jquery ajax request instead post,content-type set to: Application/json could not deserialize to type class Com.sun.jersey.api.representation.FormChange Content-type and consumes to Mediatype.application_form_urlencode and Application/x-www-form-urlencode
    <script>
$ ("#btn"). Click (function () {
	$.ajax {
	    URL: "rest/apasinfopush/push/",
	    type: "POST" ,
	    dataType: "JSON",
	    data: {
	    	apas_info_unid:$ ("Select[name=apas_info_unid]"). Val (),
	    	handlestate:$ ("#input [Name=handlestate]"). Val (),
	    	message:$ ("Input[name=message]"). Val (),
	    	to_userid:$ ("Input[name= To_userid] "). Val (),
	    	to_username:$ (" Input[name=to_username] "). Val ()
	    },
	    headers: {' Content-type ': ' Application/x-www-form-urlencoded ', ' Accept ': '},
	    success:function (res) {
	        if (res.status = = 1) {
	            Window.location.reload ();
	        } else {
	            alert (res.message);
    }}}); </script>

	@POST
	@Path ("/push/")
	@Produces ({Mediatype.application_json})
	@Consumes ({mediatype.application_ Form_urlencoded  })


The request sent by the client is syntactically incorrect (bad request).This doesn't look wrong, configure the Web.xml, add
	<init-param>
	  <param-name>com.sun.jersey.config.feature.TracePerRequest</param-name>
	  <param-value>true</param-value>      
	</init-param>
Ajax Request Plus:
   Headers: {
                "x-jersey-trace-accept": True
            },
Then we see the service-side error reprocessing. java.lang.NoSuchMethodError:antlr.collections.AST.getLine () IUnder Struts2 core libraries There is a Antlr-2.7.2.jar Hibernate 4.1 core Libraries has a Antlr-2.7.7.jar deletion version of the lower one. Where to delete:
Myeclise install directory to remove the lower version of the jar. Workspace Search Antlr-2.7.2.jar and delete.
Lock wait timeout exceeded; Try restarting transactionReference: http://stackoverflow.com/questions/5836623/ Getting-lock-wait-timeout-exceeded-try-restarting-transaction-even-though-im

1) Enter MySQL
Mysql-u your_user-p
2 View the Locked table
Mysql> Show open tables where in_use>0;
3 View the current process, some of which are in the locked table
Mysql> show Processlist;
4) Kill Related process
Mysql> kill Put_process_id_here;

In addition execute:
SET GLOBAL innodb_lock_wait_timeout = 5000;
SET innodb_lock_wait_timeout = 5000;

Serious: Servlet.service () for Servlet [Jersey REST Service] in context with path [/WHRWECHAT2] threw exception [servlet execut Ion threw a exception] with root cause
Java.lang.AbstractMethodError:javax.ws.rs.core.UriBuilder.uri (ljava/lang/string;) Ljavax/ws/rs/core/uribuilder;
At Javax.ws.rs.core.UriBuilder.fromUri (uribuilder.java:119)

Delete Javax.ws.rs-api-2.0.jar can

Some use reference: https://theholyjava.wordpress.com/2012/01/31/troubleshooting-jersey-rest-server-and-client/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.