ejb+Resteasy를 호출하는rest 서비스 오류: Could not find MessageBodyWriter

3371 단어 jbossejbresteasy
Could not find MessageBodyWriter for response object of type: java.util.ArrayList
해결 방법:war 패키지는rest 서비스를 제공하는 jb LOCAL 인터페이스 클래스를 포함해야 합니다
내 포장 참고:
1、build.ejblocal.xml 세션
.설명: IHEllo WorldLocal은ejb LOCAL 인터페이스로rest 성명을 포함하고 클래스 중 한 가지 방법이 있으며 반환값은 List입니다.책은vo클래스입니다.패키지 생성ejb-local.jar
2、build.ejbimpl.xml 세션
<target name="ejb-local.jar">
		<jar jarfile="${temp.dir}/ejb-local.jar">
			<fileset dir="./${classes.dir}">
				<include name="**/IHelloWorldLocal.class" />
				<include name="**/Book.class" />
				<!--include name="**/jboss-deployment-structure.xml" /-->
				
			</fileset>
		</jar>
	</target>
설명: Hello World Bean은 IHEllo World Local의 실현 클래스입니다.패키지 생성 jb-impl.jar.
jboss-deployment-structure.xml은 다음과 같습니다. jb-local에 대한 설명입니다.jar의 의존
<target name="ejb-impl.jar">
		<jar jarfile="${temp.dir}/ejb-impl.jar">
			<fileset dir="./${classes.dir}">
				<include name="**/HelloWorldBean.class" />
				<include name="**/jboss-deployment-structure.xml" />
				
			</fileset>
		</jar>
	</target>

3、build.war.xml 세션
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
  <deployment>

    <dependencies>
		<module name="deployment.ejb-local.jar" />
    </dependencies>
    
  </deployment>
</jboss-deployment-structure>
설명: 를 포함하지 않으면rest 서비스를 호출하면 위의 오류를 보고합니다
web.xml의 Resteasy 구성:
        <target name="deploy-war">
		<jar jarfile="${temp.dir}/rest.war">
			<fileset dir="./web/">
				<include name="**/IHelloWorldLocal.class" />
				<include name="**/web.xml" />
				<include name="WEB-INF/jboss-deployment-structure.xml" />
				
			</fileset>
		</jar>
	</target>
WEB-INF/jboss-deployment-structure.xml 구성:
 	 <context-param>
		<param-name>resteasy.jndi.resources</param-name>
		<param-value>
			java:global/ejb-impl/HelloWorldBean!com.ejb.hello.IHelloWorldLocal
		</param-value>
	</context-param>
	 <context-param>
		<param-name>resteasy.servlet.mapping.prefix</param-name>
		<param-value>/rest</param-value>
	</context-param>

 	<context-param>
		<param-name>resteasy.scan</param-name>
		<param-value>true</param-value>
	</context-param>

	<listener>
		<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
	</listener>

	<servlet>
		<servlet-name>Resteasy</servlet-name>
		<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>Resteasy</servlet-name>
		<url-pattern>/rest/*</url-pattern>
	</servlet-mapping>

좋은 웹페이지 즐겨찾기