java.lang.NoClassDefFoundError: sbt/PlayInternalKeys - java

When I (try to) start Play, I see this:
[info] Loading global plugins from /home/paul/.sbt/plugins
[info] Loading project definition from /home/my-project/project
[error] java.lang.NoClassDefFoundError: sbt/PlayInternalKeys
[error] Use 'last' for the full log
I am loading a custom sbt plugin.
What does that error mean?
(FYI, I'm assuming that last line says I can run play last. I can't. It gives the same error.)

For some reason, I found that my Play project wasn't pulling in the SNAPSHOT versions I was publishing to my local repo for the sbt plugin.
I had to increment the version numbers myself. When I did that, I did not see this error anymore. (I did continue to have to update the version when I changed the plugin.)

Related

Building spark-cassandra-connector: SBT cannot resolve dependencies

I have cloned the spark-cassandra-connector in order to fix one of its unresolved issues.
Prior to any code changes, I'm trying to build locally, as explained in the developer guide.
But whichever SBT command that I run, fails with an unresolved dependency errors:
[error] sbt.librarymanagement.ResolveException: unresolved dependency: org.apache.logging.log4j#log4j-api;2.11.1: org.apache#apache;18!apache.pom(pom.original) origin location must be absolute: file:/Users/gcatz/.m2/repository/org/apache/apache/18/apache-18.pom
[error] unresolved dependency: org.apache.logging.log4j#log4j-core;2.11.1: org.apache#apache;18!apache.pom(pom.original) origin location must be absolute: file:/Users/gcatz/.m2/repository/org/apache/apache/18/apache-18.pom
[error] unresolved dependency: com.squareup.okhttp3#okhttp;3.7.0: org.sonatype.oss#oss-parent;7!oss-parent.pom(pom.original) origin location must be absolute: file:/Users/gcatz/.m2/repository/org/sonatype/oss/oss-parent/7/oss-parent-7.pom
...
I'm using a mac (Monterey), Java 1.8.
I wrote some comments regarding the issue in the original thread on DataStax community, but have been asked to open a new thread here instead.
Have you guys ever encountered such an issue with SBT?
It seems the issue was in broken cache (~/.m2, ~/.ivy2). Removing the cache helped with origin location must be absolute
How to fix "origin location must be absolute" error in sbt project (with Spark 2.4.5 and DeltaLake 0.6.1)?
sbt new RuntimeException
Origin location must be absolute error in building a SBT project, IntelliJ
Also wrong version of Java was selected (Java 9 instead of 8). Correcting $PATH helped with error while loading String, class file '/modules/java.base/java/lang/String.class' is broken (class java.lang.NullPointerException/Cannot invoke "scala.tools.nsc.Global$Run.typerPhase()" because the return value of "scala.tools.nsc.Global.currentRun()" is null) [error] java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI [error] at java.base/jdk.internal.jrtfs.JrtPath.toUri(JrtPath.java:175)

Maven Javadoc generator String Index out of range

When I want to generate Javadocs with the maven-javadoc-plugin, the process fails with the error message:
[ERROR] javadoc: error - String index out of range: -6
[ERROR]
[ERROR] Command line was: /usr/lib/jvm/java-8-openjdk-amd64/jre/../bin/javadoc #options #packages
I tried enabling Debug Mode of Maven, Debug mode of the Javadoc Plugin, Debug mode of the javadoc generator itself. I have not gotten any more information than the message above. Not even a hint what class it fails to generate JavaDoc for.
Searching for this problem doesn't lead to much results either as all queries end in results for documentation about StringIndexOutOfBoundsException or other exception related problems.
I use version 3.2.0 of the maven-javadoc-plugin. But it doesn't seem to matter what version I use as the problem is also existent in version 2.7.
What I've found out so far is, that this error only occurs if I utilize stuff from a special dependency (currently the problem gets resolved if I remove all references to that dependency in code).
Said dependency is not public and was installed using the mvn install:install-file command. The classes in the dependency have been compiled with Java 6.
This is my last hope to get some information and maybe a solution to the problem.
Edit 1: It is definitely that dependency. If I manually remove it from the 'classpath' of the javadoc command (options file) then the error disappears.
Could it have something to do with me having a package name that matches exactly the package name used in the dependency?

java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor when manually building the plugin

I am trying to use JaCoCo code coverage plugin (3.0.4) in Jenkins (2.138.2). It works as expected, but what I don't like about it is that it does not generate the report when the build is either failed or aborted. This code is here: https://github.com/jenkinsci/jacoco-plugin/blob/master/src/main/java/hudson/plugins/jacoco/JacocoPublisher.java#L585-L587
There is a pull request for this, but looks like it didn't get worked on after its original creation.
So I tried to rebuild the plugin myself with next steps:
Clone https://github.com/jenkinsci/jacoco-plugin
Checkout the latest version 3.0.4
Remove the if statement from above in JacocoPublisher class
Build the plugin (mvn package as they say)
I am able to build it with no problems. The next steps are:
Navigate to Jenkins -> Manage Jenkins -> Manage Plugins -> Advanced
Upload the generated jacoco.hpi file and restart Jenkins
After this is done, the Post Build step to run JaCoCo reports disappears, and I see this in jenkins logs:
06-Nov-2018 17:19:24.353 WARNING [Handling GET /jenkins/job/testing-jacoco-code-coverage-reports/configure from 0:0:0:0:0:0:0:1 : http-nio-8080-exec-3 Job/configure.jelly Project/configure-entries.jelly] hudson.ExpressionFactory2$JexlExpression.evaluate Caught exception evaluating: i.descriptor in /jenkins/job/testing-jacoco-code-coverage-reports/configure. Reason: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor
at jenkins.model.Jenkins.getDescriptorOrDie(Jenkins.java:1517)
at hudson.tasks.Publisher.getDescriptor(Publisher.java:122)
at hudson.tasks.Recorder.getDescriptor(Recorder.java:51)
at hudson.plugins.jacoco.JacocoPublisher.getDescriptor(JacocoPublisher.java:775)
... 168 more
The solution for this issue proposed by Jenkins is not applicable here since the plugin already extends the required classes.
Reverting to previous version (3.0.4 but not of my custom build) makes the build step appear again, but again, is lacking the behavior I need.
Am I missing anything?
Thank you!
After removing the original version, I had to also delete the remaining jacoco plugin files from the /plugins folder. After that, installation went fine.

Eclipse plugin project "checkstyle internal error" says "cannot initialize module TreeWalker - Unable to instantiate '...ForbidCertainImportsCheck'"

I haven't looked at my Eclipse plugin project for a few weeks, but after I updated to Neon.1, I noticed the following error in the Problems view:
Checkstyle execution failed due to an internal error. Please check the error log for details.
In the error log, I saw things like this:
!MESSAGE Checkstyle-Plugin: cannot initialize module TreeWalker - Unable to instantiate
'com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck' class,
it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotation.com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck,
com.puppycrawl.tools.checkstyle.checks.blocks.com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck,
[deleted numerous similar class names],
com.puppycrawl.tools.checkstyle.com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheckCheck.
Please recheck that class name is specified as canonical name or read how to configure short
name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also
recheck that provided ClassLoader to Checker is configured correctly.
After I saw this in my neon.1 workspace, I also noticed that my older workspace running in Mars.2 was also showing the same problem.
I've managed to resolve this.
The parent POM of the project I work on had a change to its checkstyle configuration, and it now requires adding the "seventu" auxiliary checkstyle plugin, which I found at https://github.com/sevntu-checkstyle/sevntu.checkstyle . Once I installed that (and did the usual "Maven Update Projects" invocation), the errors went away.

IntelliJ does not find native libraries for OpenCV when adding jar as a dependency for Play project

I am currently working on a Play 2.1 project, in which requests to the web-service will handle downloading user-supplied images, re-sizing and re-cropping them, and also filtering out known bad photos (for example, we don't want users to upload company logos). We are trying to use OpenCV to handle the back-end work, but I can't seem to get IntelliJ to add the OpenCV jar in a way that works with the java project.
I've been able to build OpenCV from source, without issue. This left me with the following folder:
/home/charles/opencv/release
Inside this folder, I have three files of interest:
bin/opencv-246.jar
lib/cv2.so
lib/libopencv_java246.so
If I try to add the jar file to IntelliJ as a new Java library, it seemingly finds all the classes/methods, and I can write code using the auto-complete. I can also click on the respective classes or methods, and it brings me to the right files.
However, when I try to run the Play project, I get this error:
[info] Loading project definition from /home/charles/Github/ImageProject
[info] Set current project to ImageProject (in build file:/home/charles/Github/ImageProject/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
Server started, use Alt+D to stop
[info] Compiling 1 Java source to /home/charles/Github/ImageProject/target/scala-2.10/classes...
[error] /home/charles/Github/ImageProject/app/controllers/Application.java:7: error: package org.opencv.core does not exist
[error] import org.opencv.core.Core;
[error] ^
I've also tried adding a copy of the jar file directly into the project (so putting opencv-246.jar into ImageProject/lib), and then adding the java library from that location instead. But that just leaves me with a different error:
java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
I suspect part of the problem may be related to the native libraries that the Java OpenCV wrapper uses (file 2 or 3 above). In Eclipse, when you add a jar file, you can explicitly set the native library location, which makes OpenCV work fine. I've read suggestions of using this to fix the problem:
-Djava.library.path=/home/charles/opencv/release/lib
But that doesn't seem to work (though maybe I'm setting it in the wrong place? I've tried setting it as a JVM parameter in the run config for the project, and in the IDE settings, but neither seem to be used or respected).
Note: Just to clarify again, this is a Play2 project, not an Android project. There seems to be some Android-specific help out there, that isn't relevant in this case.
This feels like it should be a rather straight forward thing, but I've been spending several days trying to find an answer at this point, and still have nothing. Any ideas?
Additional details:
I also tried following the "Running SBT samples" of the OpenCV documentation here:
http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html
And I also get a similar error:
charles#charles-VirtualBox:~/JavaSample$ sbt run
[info] Loading project definition from /home/charles/JavaSample/project
[info] Set current project to JavaSample (in build file:/home/charles/JavaSample/)
[info] Compiling 1 Java source to /home/charles/JavaSample/target/scala-2.10/classes...
[info] Running HelloOpenCV
Hello, OpenCV
[error] (run-main) java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at HelloOpenCV.main(HelloOpenCV.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 2 s, completed Jul 17, 2013 5:11:39 PM
When you want to use OpenCV or any other native libraries on Playframework, You MUST run your application with "play start" command, not "play run".
"play run" command starts your application in development mode and "play start" command starts in production mode. I don't know every difference between them but one obvious thing is ,
Only when we use "play start", a new JVM for you application is launched and it loads native libraries you specified by System.load("/absolute/path/to/your/so/or/jnilib/inOSX/not/dylib/filename.jnilib");
How to load native lib is following.
Create Global.java which has empty package name. (refer this link )
public class Global extends GlobalSettings {
#Override
public void beforeStart(Application app) {
// TODO Auto-generated method stub
super.beforeStart(app);
String libopencv_java = "/Users/yoonjechoi/git/myFirstApp/target/native_libraries/64bits/libopencv_java246.jnilib";
System.load(libopencv_java);
}
}
then you can use classes of OpenCV in your Play application's controllers.
System.loadLibrary("opencv_java246") doesn't works. I don't know why. I don't have time to dig why. -_-;
Please give hints if you know why.
for windows 64 bit set
-Djava.library.path=/full-path/OpenCV/build/java/x64
I would have used the lib/libopencv_java246.so
It's always important to map the .so file to build library. It's suppose to work out of the box

Categories

Resources