ResourceConfig 인스턴스에 루트 리소스 클래스가 없습니다.
여기서 뭐가 잘못 됐나요?
The ResourceConfig instance does not contain any root resource classes.
Dec 10, 2010 10:21:24 AM com.sun.jersey.spi.spring.container.servlet.SpringServlet initiate
SEVERE: Exception occurred when intialization
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:103)
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1182)
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$600(WebApplicationImpl.java:161)
at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:698)
at com.sun.jersey.server.impl.application.WebApplicationImpl$12.f(WebApplicationImpl.java:695)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:197)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:695)
at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117)
필터:
<filter>
<filter-name>JerseyFilter</filter-name>
<filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-class>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
<param-value>/views/</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
<param-value>/(images|css|jsp)/.*</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>JerseyFilter</filter-name>
<url-pattern>/myresource/*</url-pattern>
</filter-mapping>
암호:
@Path ("/admin")
public class AdminUiResource {
@GET
@Produces ("text/html")
@Path ("/singup")
public Viewable getSignUp () {
return new Viewable("/public/signup", "Test");
}
}
추가해 보셨습니까?
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>my.package.name</param-value>
</init-param>
SpringServlet 정의에? my.package.name을 AdminUiResource가있는 패키지로 바꾸고 클래스 경로에 있는지 확인하십시오.
저는 Jersey를 처음 사용했습니다. 동일한 문제가 있었지만 "/"를 제거하고 @path ( "admin") 만 사용하면 작동했습니다.
@Path("admin")
public class AdminUiResource { ... }
즉, 저지 RESTful 웹 서비스로 실행할 수있는 클래스를 찾을 수 없습니다.
검사:
com.sun.jersey.config.property.packages
web.xml에서 ' '이 누락 되었는지 여부 .- '
com.sun.jersey.config.property.packages
'매개 변수의 값 이 누락 되었는지 또는 유효하지 않은지 여부 (언급 된 패키지가 존재하지 않음). 저지 서비스로 실행되는 POJO 클래스를 넣은 패키지 여야합니다. @Path
속성으로 주석 처리 된 메소드가있는 POJO 클래스가 하나 이상 있는지 여부 입니다.
패키지 이름을 추가해야합니다.
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>your.package.name</param-value>
</init-param>
또한 내가 주목
한 한 가지 사실은 MAVEN BUILD 후 프로젝트를 새로 고쳐야 합니다. 그렇지 않으면 동일한 오류가 표시됩니다.
우리가 프로젝트를 새로 고쳐야하는 이유를 알고 있다면 의견을주십시오.
리소스 패키지에는 @Path로 주석이 달린 pojo가 하나 이상 포함되어 있거나 @Path로 주석이 달린 하나 이상의 메소드 또는 @GET, @PUT, @POST 또는 @DELETE와 같은 요청 메소드 지정자가 있어야합니다. 리소스 메서드는 요청 메서드 지정자로 주석이 달린 리소스 클래스의 메서드입니다. 내 문제가 해결되었습니다 ..
JBOSS EAP 6.1에서이 문제를 겪었습니다. 이클립스를 통해 JBOSS 서버에 코드를 배포 할 수 있었지만 파일을 WAR 파일로 JBOSS에 배포하려고하면이 오류가 발생하기 시작했습니다.
해결책은 web.xml이 JBOSS와 제대로 작동하도록 두 가지가 함께 작동하도록 구성하는 것이 었습니다.
다음 두 줄은 JBOSS가 자체 구성을 수행 할 수 있도록 web.xml에서 주석 처리되었습니다.
<!--
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.your.package</param-value>
</init-param> -->
그런 다음 다음 컨텍스트 매개 변수를 추가하십시오.
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.resources</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.providers</param-name>
<param-value>false</param-value>
</context-param>
기본적으로 아래와 같이 수정했고 모든 것이 잘 작동했습니다.
<servlet>
<servlet-name >MyWebApplication</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
<param-value>/views/</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
<param-value>/(images|css|jsp)/.*</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MyWebApplication</servlet-name>
<url-pattern>/myapp/*</url-pattern>
</servlet-mapping>
Web.xml에서 ResourseConfig가 누락 되었기 때문에이 예외가 발생합니다.
더하다:
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>/* Name of Package where your service class exists */</param-value>
</init-param>
서비스 클래스는 다음과 같은 서비스를 포함하는 클래스를 의미합니다. @Path("/orders")
Eclipse 프로젝트에서 webapp을 실행하려고 할 때 동일한 문제가 발생했습니다. .class 파일을 복사하자마자 /WEB-INF/classes
완벽하게 작동했습니다.
동일한 문제가 발생하여 여러 가지 예제를 테스트하고 가능한 모든 솔루션을 시도했습니다. 마침내 나를 위해 일 @Path("")
하게 된 것은 수업 라인에 오버 라인을 추가했을 때 그것을 생략했습니다.
동일한 문제가 있었고 소스 코드를 배포하는 방식에 문제가 있음을 알았습니다. 오류 메시지에 따르면 "...does not contain any root resource classes"
. 따라서 구성된 패키지에서 리소스 클래스를 찾을 수 없습니다. 나는 방금 수업을 잘못 배치했습니다. 그래서 그것을 선택하지 않았습니다.
WAR의 / WEB-INF / classes 디렉토리에 내 클래스 파일을 배포하는 것을 잊었습니다. 처음에는 WAR 파일의 루트에 직접 배치했습니다. 따라서 리소스 클래스를 찾을 때 다른 (잘못된) 위치에 존재했기 때문에 찾지 못했습니다.
같은 문제-web.xml은 다음과 같습니다.
<servlet>
<servlet-name>JerseyServlet</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>com.mystuff.web.JerseyApplication</param-value>
</init-param>
...
Providing a custom application overrides any XML configured auto detection of classes. You need to implement the right methods to write your own code to wire up the classes. See the javadocs.
Another possible cause of this error is that you have forgotten to add the libraries that are already in the /WEBINF/lib
folder to the build path (e.g. when importing a .war
-file and not checking the libraries when asked in the wizard). Just happened to me.
It happened to me when I deployed my main.jar, without checking the add directory entries box in the export jar menu in Eclipse.
Well, it's a little late to reply. I have faced the same problem and my Google searches were in vain. However, I managed to find what the problem was. There might be many reasons for getting this error but I got the error due to the following and I wanted to share this with my fellow developers.
- I previously used Jersey 1.3 and I was getting this error. But when I upgraded the jars to the latest version of Jersey, this issue was resolved.
- Another instance in which I got this error was when I was trying to deploy my service into JBoss by building a war file. I made the mistake of including the Java files in the .war instead of java classes.
I had to add a trailing forward slash to the end of @path
@Path ("/admin/")
Ok... For me work fine just only assigning the "servlet-class" to com.sum.jersey.spi.container.servlet.ServletContainer, I am using IDE (Eclipse Mars)
<servlet>
<servlet-name>Jersey Web Application</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>Jersey Web Application</servlet-name>
<url-pattern>/frontend/*</url-pattern>
</servlet-mapping>
but for some reason I had to reboot my computer in order to work in my localhost. If still not work? You have to add in your web.xml this code in between "servlet" tag.
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>the.package.name</param-value>
</init-param>
"the.package.name" is the package name where you have your classes. If you are using IDE, refresh the project and run again in Tomcat. still not work? reboot your computer and will work.
Another thing to check is a combination of previous entries
You can have in your web.xml file this:
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.acme.rest</param-value>
</init-param>
and you can have
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.providers</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.resources</param-name>
<param-value>false</param-value>
</context-param>
but you cannot have both or you get this sort of error. The fix in this case would be to comment out one or the other (probably the first code snippet would be commented out)
yes adding the init param for com.sun.jersey.config.property.packages fixed this issue for me.
was merging a jersey rest services into maven based spring application and got this error.
I also got this kind of error, please take care of the configurations in xml.
I wrote com.sun.jersey.comfig.property.packages
Instead of com.sun.jersey.config.property.packages
After correction it's working.
that issue is because jersey can't find a dependecy package for your rest service declarated
check your project package distribution and assert that is equals to your web.xml param value
Probably too late but this is how I resolved this error.
If this solution is not working,
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>/* Name of Package where your service class exists */</param-value>
</init-param>
In eclipse:
RightClick on your Project Or Select Project and press Alt + Enter On the left-hand side of the opened window find Java Build Path
Select Libraries from the right tab panel: If there is anything which is corrupted or showing cross mark on top of the jars, remove and add the same jar again
Apply and Close
Rebuild your project
In my case I have added the jars twice in build path after importing from war. It worked fine after removing the extra jars which was showing error deployment descriptor error pages
adding
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>service.package.name</param-value>
</init-param>
Also came accross this problem, twice for different reasons. The first time I forgot to include
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>my.package.name</param-value>
</init-param>
as described in previous comments, and once I did that, it started working.
Yet... another day I started Eclipse, expecting to continue where I left off, and instead of having my program working, it showed the very same error once again. I started checking if I accidentally had made some changes and saved corrupted file, but could find no such error and the file looked exactly like examples I have, all in order. Since it worked the day before, after some initial searching, I thought, well, maybe it's a Eclipse, or Tomcat glitch or something, so let's just try to make some changes and see if it reacts. So, I did a space + backspace in web.xml file, just to fool Eclipse that the file is changed, and saved it then. The next step was restarting Tomcat server (from Eclipse IDE) and voila, it works again!
Maybe someone with broader experience could explain what the problem really was behind all of this?
Main cause of this Exception is:
You have not given the proper package name where you using the @Path
or forgot to configure in web.xml / Configuration file(Rest API Class File package Name, Your Class Package Name)
Check this Configuration inside <init-param>
'program tip' 카테고리의 다른 글
[AcceptVerbs (HttpVerbs.Post)]와 [HttpPost]의 차이점은 무엇입니까? (0) | 2020.10.11 |
---|---|
iOS : 숫자에서 적절한 월 이름을 얻는 방법은 무엇입니까? (0) | 2020.10.11 |
Lollipop에서 CardView 사이에 공간이없는 이유는 무엇입니까? (0) | 2020.10.11 |
숨겨진 파일이없는 cp -r (0) | 2020.10.10 |
adb shell을 사용하여 안드로이드 폰의 모든 파일을 나열하는 방법은 무엇입니까? (0) | 2020.10.10 |