升级Jersey分发版后,我得到MessageBodyProviderNotFoundException
。我在MultiPart
中注册了web.xml
,但似乎我更缺少配置。
POM
<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version.no}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version.no}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version.no}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version.no}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version.no}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>${jersey.version.no}</version>
</dependency>
的web.xml
<servlet>
<servlet-name>Jersey Spring</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.mercuryinsurance.esignature.client.rest.service</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
<init-param>
<param-name>jersey.config.servlet.filter.contextPath</param-name>
<param-value>/WEB-INF/jsps/rest</param-value>
</init-param>
<init-param>
<param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
<param-value>/(resources|(WEB-INF/jsp))/.*</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
代码:
WebTarget webTarget = client.createResource( ESignatureSpringUtil.getMessage( KeyConstants.ALSB_DOCUSIGN_ADDRESS )
+ ESignatureSpringUtil.getMessage( KeyConstants.REST_SEND_DOCUMENTS_ADDRESS ) );
Invocation.Builder builder = webTarget
.path( ESignatureSpringUtil.getMessage( KeyConstants.REST_SEND_DOCUMENTS_ADDRESS ) )
.request( MediaType.APPLICATION_XML )
.header( KeyConstants.REST_URI_APPENDERS, docSb )
.header( DocusignRESTContants.CONTENT_TYPE, DocusignRESTContants.MULTIPART_FORM_DATA )
.header( DocusignRESTContants.X_DOCUSIGN_AUTHENTICATION, getDocusignAuthHeader( cu ) );
Response response = builder.post( Entity.entity( multiPart, MediaType.APPLICATION_OCTET_STREAM ), Response.class );
栈跟踪
Caused by: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/octet-stream, type=class org.glassfish.jersey.media.multipart.MultiPart, genericType=class org.glassfish.jersey.media.multipart.MultiPart.
答案 0 :(得分:0)
我终于开始工作了。我发送表单作为MultiPart对象t能够发送多个表单。我不得不将其作为字节流发送,而不仅仅是普通的java对象。实体方法中的{% url 'enrollment' courses.slug % }
。我从供应商处获得了200个状态代码。