I'm developing a web application in java spring 4 framework. At one point I'm using FormDataContentDisposition class which is providing by jersey. This class used at an endpoint of my REST call like this ,
@RequestMapping(value = "/createArticle/", method = RequestMethod.POST) @Consumes(MediaType.MULTIPART_FORM_DATA) public ResponseEntity<Void> createNewArticle(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetails)
when i make a REST call, Apache Tomcat giving an exception saying, "Failed to instantiate [com.sun.jersey.core.header.FormDataContentDisposition]: No default constructor found"
Since FormDataContentDisposition don't have a default constructor, i think this exceptions comes, also according to this artcle http://javarevisited.blogspot.in/2014/01/why-default-or-no-argument-constructor-java-class.html there should be a default constructor present. I can't create a default constructor, since this class(FormDataContentDisposition) is inside a jar file.
Help me to overcome from this problem
I think you are correct in the cause of the problem. There is no way in which you can instantiate an object of this class without arguments to the constructor, so you need to figure out, in Spring 4, how to feed an argument to the construction of that class and do so.
The article you refer to delivers the opinion that ALL classes should have a default constructor. It is no kind of rule in Java; I don't even think it qualifies as best practice. I also don't think the article has any bearing on your problem.