Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Failures during mvn install? #76

Closed
Booley opened this issue Feb 18, 2016 · 15 comments
Closed

Test Failures during mvn install? #76

Booley opened this issue Feb 18, 2016 · 15 comments
Labels

Comments

@Booley
Copy link

Booley commented Feb 18, 2016

I'm trying to install javacpp on OSX with mvn install:

git clone https://github.com/bytedeco/javacpp
cd javacpp
mvn clean
mvn install

But the install fails with these errors:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.bytedeco.javacpp.AdapterTest
Generating /javacpp/target/test-classes/org/bytedeco/javacpp/jniAdapterTest.cpp
Compiling /javacpp/target/test-classes/org/bytedeco/javacpp/macosx-x86_64/libjniAdapterTest.dylib
clang++ -I/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/include/darwin /javacpp/target/test-classes/org/bytedeco/javacpp/jniAdapterTest.cpp -std=c++11 -Wl,-rpath,@loader_path/. -march=x86-64 -m64 -Wall -O3 -fPIC -dynamiclib -undefined dynamic_lookup -o /javacpp/target/test-classes/org/bytedeco/javacpp/macosx-x86_64/libjniAdapterTest.dylib -framework JavaVM 
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.765 sec <<< FAILURE!
org.bytedeco.javacpp.AdapterTest  Time elapsed: 0.764 sec  <<< ERROR!
java.lang.IllegalAccessError: tried to access field org.bytedeco.javacpp.Loader.loadLibraries from class org.bytedeco.javacpp.AdapterTest
    at org.bytedeco.javacpp.AdapterTest.setUpClass(AdapterTest.java:76)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running org.bytedeco.javacpp.IndexerTest
Generating /javacpp/target/test-classes/org/bytedeco/javacpp/jniIndexerTest.cpp
Compiling /javacpp/target/test-classes/org/bytedeco/javacpp/macosx-x86_64/libjniIndexerTest.dylib
clang++ -I/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/include/darwin /javacpp/target/test-classes/org/bytedeco/javacpp/jniIndexerTest.cpp -Wl,-rpath,@loader_path/. -march=x86-64 -m64 -Wall -O3 -fPIC -dynamiclib -undefined dynamic_lookup -o /javacpp/target/test-classes/org/bytedeco/javacpp/macosx-x86_64/libjniIndexerTest.dylib -framework JavaVM 
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.313 sec <<< FAILURE!
org.bytedeco.javacpp.IndexerTest  Time elapsed: 0.313 sec  <<< ERROR!
java.lang.IllegalAccessError: tried to access field org.bytedeco.javacpp.Loader.loadLibraries from class org.bytedeco.javacpp.IndexerTest
    at org.bytedeco.javacpp.IndexerTest.setUpClass(IndexerTest.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)


Results :

Tests in error: 
  org.bytedeco.javacpp.AdapterTest: tried to access field org.bytedeco.javacpp.Loader.loadLibraries from class org.bytedeco.javacpp.AdapterTest
  org.bytedeco.javacpp.IndexerTest: tried to access field org.bytedeco.javacpp.Loader.loadLibraries from class org.bytedeco.javacpp.IndexerTest

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.660 s
[INFO] Finished at: 2016-02-18T10:28:04+00:00
[INFO] Final Memory: 28M/316M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project javacpp: There are test failures.
[ERROR] 
[ERROR] Please refer to //javacpp/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

How can I fix these test failures?

@saudet
Copy link
Member

saudet commented Feb 18, 2016

That's a new one. I wonder what causes that. You can skip the tests for now by calling mvn clean install -Dmaven.skip.test

@saudet
Copy link
Member

saudet commented Feb 18, 2016

BTW, what version of Maven is this?

@Booley
Copy link
Author

Booley commented Feb 18, 2016

This is maven 3.3. Skipping the tests worked, thanks!

@Booley
Copy link
Author

Booley commented Feb 23, 2016

Ahhhh actually, that command didn't work, I actually ran mvn clean install -DskipTests earlier and that worked, but I just ran with the -Dmaven.skip.test option instead and that still results in the failed tests; I thought they were equivalent commands but apparently not.

I opened another issue at bytedeco/javacpp-presets#154 about building the caffe presets, and I'm wondering if it's possible these are related?

After running mvn clean install -DskipTests in the javacpp directory successfully, I used that jar file in an Eclipse project and tried running:

import org.bytedeco.javacpp.*;

public class Test {
    public static void main(String[] args) {
        BoolPointer p = new BoolPointer();
        p.put(true);
    }
}

just to see if the javacpp.jar built correctly (and not concerning the presets at all), but it outputs this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.BoolPointer.put(IZ)Lorg/bytedeco/javacpp/BoolPointer;
    at org.bytedeco.javacpp.BoolPointer.put(Native Method)
    at org.bytedeco.javacpp.BoolPointer.put(BoolPointer.java:74)
    at Test.main(Test.java:8)

I assume the javacpp.jar file was not meant to ever be used by itself, but I thought a simple test like this ought to work. Does this mean something is wrong with the jar, or was I not meant to access it like this in the first place? Is it possible these failed tests are what prevent me from using the presets correctly?

@saudet
Copy link
Member

saudet commented Feb 24, 2016

Sorry, I meant mvn clean install -Dmaven.test.skip. Yes, JavaCPP wasn't meant to run standalone, but it could be modified to... Anyway, check the test subdirectory for a way around that.

@saudet
Copy link
Member

saudet commented Feb 24, 2016

Yes, it looks like your installation of Maven is picking up an old version of JavaCPP somewhere, and that's probably why the tests fail.

@Booley
Copy link
Author

Booley commented Feb 24, 2016

Thanks for the quick reply! That command works, but unfortunately I keep getting UnsatisfiedLinkErrors when using the jars (specifically, opencv). I tried deleting my .m2 directory and reinstalling maven, but no difference. I'm just wondering, are there any prerequisites for using javacpp on OSX that maybe I'm forgetting about (e.g. specific OSX version or maybe Xcode dependencies)?

Right now I'm trying to narrow down the problem by seeing if there's something wrong with javacpp.jar before I start combining it with any of the presets, since they all build correctly but are apparently not usable. Is there a super short test program you recommend I try to verify if my built version of javacpp.jar works, such as by calling a specific function? I can reference all class constants normally, but not the functions. Otherwise, I'll keep investigating my maven installation.

@saudet
Copy link
Member

saudet commented Feb 24, 2016 via email

@Booley
Copy link
Author

Booley commented Feb 24, 2016

As it turns out I didn't have quite a few things there installed, so that was extremely helpful! Unfortunately, that didn't affect the build: I can build javacpp.jar only by skipping the tests, and I can build a preset successfully, but when I use them I get UnsatisfiedLinkedError.

I noticed that when I run sh cppbuild.sh install opencv the output here:

--     Linker flags (Release):
--     Linker flags (Debug):
--     Precompiled headers:         NO
--     Extra dependencies:          -framework Cocoa -framework QTKit -framework QuartzCore -framework AppKit /usr/local/Cellar/hdf5/1.8.16/lib/libhdf5.dylib /usr/local/opt/szip/lib/libsz.dylib /usr/lib/libz.dylib /usr/lib/libdl.dylib /usr/lib/libm.dylib correspondence multiview numeric glog gflags
--     3rdparty dependencies:       libjpeg libwebp libpng libtiff libjasper IlmImf zlib
-- 
--   OpenCV modules:
--     To be built:                 core flann hdf imgproc ml photo video dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres face features2d calib3d stereo videostab xfeatures2d ximgproc aruco optflow sfm stitching python3
--     Disabled:                    java python2 world bgsegm bioinspired ccalib contrib_world datasets dpm line_descriptor reg rgbd saliency surface_matching text tracking xobjdetect xphoto
--     Disabled by dependency:      cnn_3dobj structured_light
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev ts viz cvv matlab
-- 
--   GUI: 
--     QT:                          NO
--     Cocoa:                       YES
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.8)
--     JPEG:                        build (ver 90)
--     WEBP:                        build (ver 0.3.1)
--     PNG:                         build (ver 1.6.19)
--     TIFF:                        build (ver 42 - 4.0.2)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     GDAL:                        NO
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  NO
--     FFMPEG:                      NO
--       codec:                     NO
--       format:                    NO
--       util:                      NO
--       swscale:                   NO
--       resample:                  NO
--       gentoo-style:              NO
--     GStreamer:                   NO
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     OpenNI2:                     NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     QuickTime:                   NO
--     QTKit:                       YES
--     V4L/V4L2:                    NO/NO
--     XIMEA:                       NO
--     gPhoto2:                     NO
-- 
--   Parallel framework:            GCD
-- 
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use IPP Async:               NO
--     Use VA:                      NO
--     Use Intel VA-API/OpenCL:     NO
--     Use Eigen:                   YES (ver 3.2.6)
--     Use Cuda:                    NO
--     Use OpenCL:                  NO
--     Use custom HAL:              NO
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.10)
-- 
--   Python 3:
--     Interpreter:                 /usr/local/bin/python3 (ver 3.5.1)
--     Libraries:                   /Library/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib (ver 3.5.1)
--     numpy:                       /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include (ver 1.10.4)
--     packages path:               lib/python3.5/site-packages
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:
--     ant:                         /usr/local/bin/ant (ver 1.9.6)
--     JNI:                         /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Matlab:                        Matlab not found or implicitly disabled
-- 
--   Documentation:
--     Doxygen:                     NO
--     PlantUML:                    NO
-- 
--   Tests and samples:
--     Tests:                       NO
--     Performance tests:           NO
--     C/C++ Examples:              NO
-- 
--   Install path:                  (dir)/Documents/JavaCPP/javacpp-presets/opencv/cppbuild/macosx-x86_64
-- 
--   cvconfig.h is in:              (dir)/Documents/JavaCPP/javacpp-presets/opencv/cppbuild/macosx-x86_64/opencv-3.1.0

Under OpenCV Modules->Disabled, it says java. Also, under Java it says Java wrappers: NO. Is this problematic, or is it that the presets are built during some separate stage, so the wrappers should not be built during cppbuild.sh?

@saudet
Copy link
Member

saudet commented Feb 24, 2016

It's not the same wrappers no. JavaCPP is closer to the C++ API.

@saudet
Copy link
Member

saudet commented Feb 24, 2016

Might want to try this:
Debugging Classpath Problems
http://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html

@Booley
Copy link
Author

Booley commented Feb 24, 2016

Ahhh hot diggity dawg it works!!!!!!!! You were right, it was a combination of not having the right packages installed and having an old javacpp.jar (built before installing those packages) on my classpath. I cleaned out everything and rebuilt, and it works perfectly now--no failed tests and no UnsatisfiedLinkError anymore. Sorry for causing you trouble, but thank you so much for your help! :)

@saudet
Copy link
Member

saudet commented Feb 24, 2016

Great :) No problem

@saudet saudet closed this as completed Feb 24, 2016
@naderigolshan
Copy link

naderigolshan commented Aug 8, 2018

Thanks to Booley for mvn clean install -DskipTests.

@sachindranathpandey
Copy link

sachindranathpandey commented Dec 15, 2018

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
            <testFailureIgnore>true</testFailureIgnore>
            </configuration>
      </plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants