无法实例化MessageBodyReader错误

时间:2015-06-24 17:18:06

标签: java xml eclipse maven

首先,我应该说我是Maven的新手,甚至认为我不认为Maven与此错误有关。我正在使用带有m2e的Eclipse 4.2.1 我有来自ckan4j开发人员

的代码
direct:next

这是我的pom.xml文件

Client c = ClientBuilder.newBuilder().register(MultiPartFeature.class).build();
WebTarget wt = c.target("192.168.1.2/action").path("resource_update");
Builder b = wt.request();
b.header("authorization", "fa0499d1-ffda-4590-82b3-4afdb9c91576");
FileDataBodyPart filePart = new FileDataBodyPart("upload", new File("/home/ilias/Downloads/OdtUtils.java"));
FormDataMultiPart multipart = (FormDataMultiPart) new FormDataMultiPart().field("id","test2").bodyPart(filePart);
String response_string = b.post(Entity.entity(multipart, multipart.getMediaType())).readEntity(String.class);       
System.out.println(response_string);

我不是100%确定依赖项,但我只是在搜索编译时遇到的错误并在此处添加结果,直到我没有错误。 现在,当我构建maven(使用<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>ckanTest2</groupId> <artifactId>ckanConn2</artifactId> <version>0.0.1-SNAPSHOT</version> <name>CkanConnectTest</name> <dependencies> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-client</artifactId> <version>3.0.2.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-multipart-provider</artifactId> <version>3.0.11.Final</version> </dependency> <dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-multipart</artifactId> <version>1.19</version> </dependency> <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-server</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.18</version> </dependency> </dependencies> </project> )时,我得到了这个

generate-sources

甚至认为它抱怨记录器,我现在不急于解决。除此之外,它似乎正在建设中。

尝试执行java文件时,我得到了这个

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".  
SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J:  
See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.  
[INFO] Scanning for projects...   
[INFO]            
[INFO]-----------------------------------------------------------------------  
[INFO] Building CkanConnectTest 0.0.1-SNAPSHOT  
[INFO]------------------------------------------------------------------------  
[INFO]------------------------------------------------------------------------  
[INFO] BUILD SUCCESS  
[INFO]------------------------------------------------------------------------    [INFO] Total time: 0.298s  
[INFO] Finished at: Wed Jun 24 19:50:57 EEST 2015  
[INFO] Final Memory: 6M/58M  
[INFO]------------------------------------------------------------------------

我使用xml标签只是为了让xml代码更具可读性

1 个答案:

答案 0 :(得分:0)

我遇到了由RestEasy和Jersey(org.glassfish.jersey.media)组合造成的同样问题:

ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
ResteasyProviderFactory.pushContext(javax.ws.rs.ext.Providers.class, factory);

另一个提示是使用依赖性jersey-media-multipart而不是jersey-multipart