Jersey returns 500 when trying to return an XML response

前端 未结 4 1201
闹比i
闹比i 2021-01-20 03:56

I\'m trying to create my own RESTful WS application using Jersey 2.12 based from this article. I want to return an XML representation of a class depending on the id been pas

4条回答
  •  离开以前
    2021-01-20 04:44

    We need to understand this problem first Jersey returns 500 when trying to return an XML response. This issue is coming because of missing dependency in pom.xml and that is:

    
        org.glassfish.jaxb
        jaxb-runtime
        2.2.11
      
    

    But this is not enough. This will resolve the 500 Error but one more error will come, while using endpoint.

    javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
    

    To resolve this you need to add following dependencies too into pom.xml

    
    
        com.sun.xml.bind
        jaxb-core
        2.3.0.1
    
    
            
    
        com.sun.xml.bind
        jaxb-impl
        2.3.1
    
    

    So this is the complete solution, to make your Jersey webApp work

提交回复
热议问题