Java Apache POI ImageHeaderPNG missing - apache-tika

I am using latest dependency of Apache POI 4.1.2 in my java application together with Tika.
I realized that the class ImageHeaderPNG is missing with the following calls tack:
java.lang.NoClassDefFoundError: org/apache/poi/sl/image/ImageHeaderPNG
at org.apache.poi.hwpf.usermodel.Picture.fillImageContent(Picture.java:172)
at org.apache.poi.hwpf.usermodel.Picture.getContent(Picture.java:279)
Inside Tika:
org.apache.tika.parser.microsoft.WordExtractor.handlePictureCharacterRun(WordExtractor.java:560
at org.apache.tika.parser.microsoft.WordExtractor.handleParagraph(WordExtractor.java:365)
at org.apache.tika.parser.microsoft.WordExtractor.handleHeaderFooter(WordExtractor.java:257)
at org.apache.tika.parser.microsoft.WordExtractor.parse(WordExtractor.java:180)
at org.apache.tika.parser.microsoft.OfficeParser.parse(OfficeParser.java:175)
at org.apache.tika.parser.microsoft.OfficeParser.parse(OfficeParser.java:131)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:280)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:280)
at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:143)
at org.apache.tika.Tika.parseToString(Tika.java:527)
at org.apache.tika.Tika.parseToString(Tika.java:602)
Any idea, hints where this class was moved to?
According to the online documentation it should be available:
https://poi.apache.org/apidocs/dev/org/apache/poi/sl/image/package-frame.html
https://poi.apache.org/apidocs/dev/org/apache/poi/sl/image/ImageHeaderPNG.html

Related

weird import issues - Jung2

I've been trying to get Jung 2.1.1 to work successfully but whatever breaking changes were made are just not making sense.
After importing the 2.1.1 jars, I get the error:
The constructor VisualizationViewer(Network, LayoutAlgorithm, Dimension) is undefined
for the line:
VisualizationViewer vv = new
VisualizationViewer(g, layoutAlgorithm, new Dimension(900, 900));
where
Network g = NetworkBuilder.undirected().build(); // and other load steps
There are other imports that aren't working, like
import edu.uci.ics.jung.visualization.decorators.PickableNodePaintFunction;
import edu.uci.ics.jung.visualization.layout.LayoutAlgorithmTransition;
Edit: It appears the classes in the Jung 2.1.1 JAR still use the old definitions, for example
VisualizationViewer(Layout<V,E>,Dimension)
and not
VisualizationViewer(Network<N,E>,Dimension,Dimension)
This question was answered in https://github.com/jrtom/jung/issues/201
The short version is that you should not be cloning the HEAD version on the JUNG website; that's the 3.0 version in development, which is not yet ready for release, and is incompatible with 2.1.1. Use the 2.1.1 version explicitly for both the jars and the samples.

Using JavaCV with Kotlin

I'm currently attempting to start a project using JavaCV in Kotlin. I'm using IntelliJ Idea as my IDE. I'm using JavaCV 1.3.2 and OpenCV 3.20.
This is my setup for the module's dependancies for OpenCV:
and for JavaCV:
I have opencv before javacv in the dependancies.
To test that OpenCV is present and valid, I wrote the below to test. As I can loadLibrary and the version number shows correctly I can assume that OpenCV is actually working.
import org.opencv.core.Core
import org.opencv.core.Mat
import org.opencv.core.CvType
import org.opencv.core.Scalar
import org.bytedeco.javacv.OpenCVFrameGrabber
fun main(args : Array<String>) {
println("Test Built Successfully")
System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
println("Running OpenCV Version ${Core.VERSION}")
val grabber = OpenCVFrameGrabber(1)
}
The line where we initialize the grabber rasies the following exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no opencv_imgproc320 in java.library.path
Perhaps I am missing something here, but I have followed the instructions provided by the README.md in the Git repository for JavaCV. I haven't seen anybody else trying to use this library with Kotlin on StackOverflow, though have checked out some posts about the same exception being raised using java.
Handling this error is no different in Kotlin from Java; you need to specify the path to the native libraries for opencv. By default on Windows it will look for the native libraries in whatever is set in your PATH environment variable.
You can also explicitly specify which directory to look for the native libraries by specifying the system property java.library.path (as indicated by the error message).
For example, you can add a run configuration like this:
Where ${PATH_TO_DYNAMIC_LIB} would be where ever the native lib opencv_imgproc320.dll is - I think in your case it would be C:/Users/ms/IdeaProjects/CVTest/opencv/build/java/x64.
I was able to resolve this by leaving my VM options blank and adding all necessary OpenCV libraries as native library paths in my JavaCV library configuration.
on MacOS, you don't need to install a native library. On OpenCV3.41, as fetched from
<!-- https://mvnrepository.com/artifact/org.openpnp/opencv -->
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.4.2-1</version>
</dependency>
I looked in the library (jar tf ~/.m2/repository/org/openpnp/opencv/3.4.2-1/opencv-3.4.2.-1.jar) and found dlls and whatnot in it:
jar tf *1.jar | grep nu
...
nu/pattern/opencv/osx/
nu/pattern/opencv/osx/x86_64/
nu/pattern/opencv/osx/x86_64/README.md
nu/pattern/opencv/osx/x86_64/cmake.log
nu/pattern/opencv/osx/x86_64/libopencv_java342.dylib
...
This led me to this StackOverflow question on nu.pattern which show how to use the nu.pattern in code.
static {
nu.pattern.OpenCV.loadShared();
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
}
This prologue code enabled sample apps which used to fail as above to run.

From axis2 function call, which is in another jar is not called and no error also shown

I have recently migrated my environment from Java 6 to Java 7. Installed Netbeans 8.0.2. A Grails(Version 2.1.1) project is running in it.
From Grails project using withREST a web service is called in another Tomcat (Version 8). This tomcat(version 8) is using axis2 to expose the methods. A java class "OneWebservice.java". Built as aar file and deployed.
Code is like this.
import com.project.Two.TwoFunction;
import com.project.Three.ThreeFunction;
public class OneWebservice{
function getOneandTwo()
{
com.project.Two.TwoFunction();
.....
com.project.Three.ThreeFunction();
}
}
When function getOneandTwo() is called, in the above code Two.TwoFunction is called, while Three.ThreeFunction is not called. No error is also printed.
Ok, Got this fixed.
We have Solr implemented for text based search.
Import related to Solr was there in com.project.Three.ThreeFunction this class file
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
was giving problem, if this is commented its working fine...
I think Solr is not working in Java 8 and Tomcat 8

Error with #CompileStatic on grails service that uses google Cache

Using grails 2.3.2, Java 1.6.0_65, trying to compile the following placed in the services directory. Even if it is not a service, and just put in the src/groovy directory, it still causes the same compile error.
I installed groovy 2.1.9 (and tried 2.2.0) which appears to be the version used by grails 2.3.2 and ran groovyc -cp quava-13.0.1.jar TestCache.groovy and it worked fine. So it appears to be something related to grails.
package somewhere
import com.google.common.cache.Cache
import groovy.transform.CompileStatic
#CompileStatic
class TestCacheService {
private final Cache<URL, String> cache
TestCacheService() {
cache = null
}
}
I receive the following error:
General error during instruction selection: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy
java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseEnumArray(AnnotationParser.java:673)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:462)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3127)
at java.lang.Class.getAnnotation(Class.java:3086)
at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:113)
at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:66)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:202)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
at java.lang.reflect.Method.declaredAnnotations(Method.java:693)
at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:686)
at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:175)
at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:362)
at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:258)
at org.codehaus.groovy.ast.ClassNode.getInterfaces(ClassNode.java:353)
at org.codehaus.groovy.ast.ClassNode.declaresInterface(ClassNode.java:945)
at org.codehaus.groovy.ast.ClassNode.implementsInterface(ClassNode.java:925)
at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.getResultType(StaticTypeCheckingVisitor.java:2629)
at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBinaryExpression(StaticTypeCheckingVisitor.java:421)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1435)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:119)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1051)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:162)
at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:110)
at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:60)
at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:132)
at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:176)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1036)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:506)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:59)
at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:215)
at org.codehaus.groovy.ant.Groovyc.runCompiler(Groovyc.java:1104)
at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:1155)
at org.codehaus.groovy.grails.compiler.Grailsc.compile(Grailsc.java:78)
at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:770)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
Is this a known bug?
Any workaround?
Google's Cache class uses the Nullable annotation. I had multiple nullable annotation implementations on my classpath. I think removing 'edu.washington.cs.types.checker:checker-framework:1.6.4' from the classpath solved this problem.

Grails 2.3.0 Restful Service Runtime Exception

I´m currently running Grails 2.3.0 and Java jdk1.7.0_40 on a Windows 7 machine, no IDE. I wanted to see how the new Rest functionality looks like. So I created the domain class as follows:
package fergara
import grails.rest.*
#Resource(uri='/Cars', formats=['json', 'xml'])
class Car {
String model
static constraints = {
}
}
The error I got when open the url:
URI
/FergaraTest/Cars/1 Class
org.codehaus.groovy.runtime.typehandling.GroovyCastException
Message
Cannot cast object 'fergara.CarController#12c43f7' with class 'fergara.CarController' to class 'org.codehaus.groovy.grails.plugins.web.api.CommonWebApi'
I feel that the Oracle´s Java SDK is the problem. To make the app run I have to pass "no-reloading" to the grails run-app command, otherwise I get an error saying that it could not start the VM and cannot open the springloaded-core-1.1.3.jar.
A have the Grails 2.3.0 installed on an Ubuntu 13.04 with OpenJDK6 and it is working good.
Hope someone can shed a light on this. Thank you.

Resources