- i have used the jersey implementation of a jaxrs but iam unable to the programme following is case where i am getting problem any idea help me - in following programme i used the jersy 2.x implementaion of jaxrs i implemented the programme using jersey implemetation of jax-rs(restfull) 2 classes i have written instead of web.xml i used the class - MyResource.java - package com.rest.application; import java.util.HashSet; import java.util.Set; import javax.ws.rs.ApplicationPath; import com.rest.webservice.SampleService; @ApplicationPath("rest") public class MyResource { private Set s; public MyResource() { s=new HashSet(); s.add(new SampleService()); } public Set getSingletons() { return s; } }- SampleService.java - import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @Path("sample") public class SampleService { @GET @Produces("text/html") @Path("{username}") public String sayHello(@PathParam("username")String s) { return "<font color='blue' size=8>Hello:" +s+ "</font>"; } @GET @Produces("text/plain") public String sayBye() { return "Bye"; } }- i added the all jars needed to this programm still i am getting following error - java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]. StandardHost[localhost].StandardContext[/RestApp2]] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]. StandardHost[localhost].StandardContext[/RestApp2]]- like this same error is displaying everywhere - when i changed the server tomcat 7 to 6 it is working but not displaying the output will anybody have any idea thanking you in advance 
in jersey 2.x am getting the error like java.util.concurrent.ExecutionException
270 Views Asked by Anil Amane At
        	2
        	
        There are 2 best solutions below
0
                 On
                        
                            
                        
                        
                            On
                            
                                                    
                    
                This says, @ApplicationPath("rest") may be applied only to the subclass of Application.
Can you share more on what are you trying to do and what is the complete stack trace. Are you using web.xml ?
As @MSD mentioned, your use of
@ApplicationPathis incorrect. See the Jersey documentation on Application Deployment to see all the different deployment options, and how they work in different environments.Basically, the easiest way put the
@ApplicationPathon an emptyApplicationclassThis will scan the entire classpath for
@Providerand@Pathannotated classes, to register with the application. Though this may seem easier, the more common approach, when working with Jersey is to use it'sResourceConfigclass, which is a subclass ofApplication. You can register packages, which will scan the packages and subpackagesOne benefit is that sometimes there will be third party dependencies that are annotated, but you don't want registered. To register individual classes just use
register(...class)in theResourceConfig.Now the reason for the error in Tomcat 7 and not 6, is most likely because Tomcat 6 (servlet 2.5) does not have the sevlet pluggability mechanism, which uses the
ServletContainerInitializer. The Jersey implementation of this initializer loads the application, looking for the@ApplicationPathon theApplicationsubclass. If you're not in a 3.0 environment, this functionality will not work.Note the Jersey initializer is included in the
jersey-container-servletjar. You can read more about it here