Here is my method:
public String retrieveMimeType(InputStream stream, String filename) throws Exception {
TikaConfig config = TikaConfig.getDefaultConfig();
Detector detector = config.getDetector();
TikaInputStream streams = TikaInputStream.get(stream);
Metadata metadata = new Metadata();
metadata.add(TikaCoreProperties.RESOURCE_NAME_KEY, filename);
MediaType mediaType = null;
mediaType = detector.detect(stream, metadata);
return mediaType.toString();
}
It give me this on the log :
java.lang.NoSuchMethodError: org.apache.commons.io.IOUtils.read(Ljava/io/InputStream;[B)I
at org.apache.tika.detect.apple.BPListDetector.detect(BPListDetector.java:106)
at org.apache.tika.detect.CompositeDetector.detect(CompositeDetector.java:85)
at com.hraccess.helper.UserFileValidator.retrieveMimeType(UserFileValidator.java:313)
at com.hraccess.webclient.servlets.ServletBlob.doPost(ServletBlob.java:429)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
For this line :
at com.hraccess.helper.UserFileValidator.retrieveMimeType(UserFileValidator.java:313)
here is the line 313:
mediaType = detector.detect(stream, metadata);
So what can I do? It gives this error when I added the parsers to my pom.xml . How to find why?