2017-10-19 2 views
0

POSNET을 POST로 RestService에 게시 할 때이 오류가 발생합니다. 라이브러리 문제가 나타납니다하지만 난 다 괜찮아요.org.glassfish.jersey.server.ContainerException : java.lang.NoSuchMethodError : org.jvnet.mimepull.MIMEMessage.close() V

의 Web.xml

<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> 
    <servlet> 
     <servlet-name>Jersey Servlet</servlet-name> 
     <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> 
     <init-param> 
      <param-name>jersey.config.server.provider.packages</param-name> 
      <param-value>org.netbeans.rest.application.config.ApplicationConfig</param-value> 
     </init-param> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>Jersey Servlet</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 
</web-app> 

ApplicationConfig.java

@javax.ws.rs.ApplicationPath("webresources") 
public class ApplicationConfig extends Application { 

    @Override 
    public Set<Class<?>> getClasses() { 
     Set<Class<?>> resources = new java.util.HashSet<>(); 
     addRestResourceClasses(resources); 
     resources.add(MultiPartFeature.class); 
     return resources; 
    } 

    /** 
    * Do not modify addRestResourceClasses() method. 
    * It is automatically populated with 
    * all resources defined in the project. 
    * If required, comment out calling this method in getClasses(). 
    */ 
    private void addRestResourceClasses(Set<Class<?>> resources) { 
     resources.add(com.src.servicio.service.ServicioREST.class); 
    } 

} 

클래스

@Path("/service") 
public class ServicioREST { 

    private final java.sql.Date fecha_Actual = new java.sql.Date(new java.util.Date().getTime()); 
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); 
    SimpleDateFormat dateFormat2 = new SimpleDateFormat("dd-MM-yyyy-HH-mm"); 
    SimpleDateFormat yearformat = new SimpleDateFormat("yyyy"); 
    DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss"); 

    @POST 
    @Consumes({MediaType.MULTIPART_FORM_DATA}) 
    @Path("test") 
    public Response prueba(@HeaderParam("token") String token, @FormDataParam("unix_time") String fecha, 
      @FormDataParam("plate") String placa, @FormDataParam("lng") float longitud, @FormDataParam("lat") float latitud, 
      @FormDataParam("speed_allowed") float velPermitida, @FormDataParam("over_speed") float velVehiculo, 
      @FormDataParam("video") InputStream video, @FormDataParam("evidence") InputStream fotoLejana, 
      @FormDataParam("fragment") InputStream fotoCercana) throws Exception { 


     OutputStream out; 
     int read; 
     byte[] bytes = new byte[1024]; 

      //Guarda la foto panoramica del vehiculo 
      out = new FileOutputStream(new File(dir + "\\" + placa + "_panoramica.jpg")); 
      while ((read = fotoLejana.read(bytes)) != -1) { 
       out.write(bytes, 0, read); 
      } 
      fotoLejana.close(); 
      out.close(); 
      plano_detalle.setFoto_lejos(dir + "\\" + placa + "_panoramica.jpg"); 

      //Guarda la foto cercana de la placa del vehiculo 
      out = new FileOutputStream(new File(dir + "\\" + placa + "_cerca.jpg")); 
      while ((read = fotoCercana.read(bytes)) != -1) { 
       out.write(bytes, 0, read); 
      } 
      fotoCercana.close(); 
      out.close(); 
      plano_detalle.setFoto_cerca(dir + "\\" + placa + "_cerca.jpg"); 


      return Response.ok().build(); 

    } 
} 

라이브러리

저지 미디어 - 다중 - 2.26.jar mimepull-1.9.7.jar는

스택 추적

java.lang.NoSuchMethodError: org.jvnet.mimepull.MIMEMessage.close()V 
    at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.getMimeParts(MultiPartReaderClientSide.java:276) 
    at org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide.readMultiPart(MultiPartReaderClientSide.java:231) 
at org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide.readMultiPart(MultiPartReaderServerSide.java:91)... 

임 글래스 피쉬 4.1.1, 자바 EE 7 저지

답변

0

작업 난 당신이 jeresy lib 디렉토리를 다운 그레이드 할 수있다 생각합니다. 저지 2.26 이후 자바 ee 8입니다.

관련 문제