I’m trying to use dl4j in my project which runs on openjdk-15.0.2.7 and I use gradle to manage my dependencies. The project builds with no errors but when the code is executed it crashes immediately with the error:
java.lang.module.InvalidModuleDescriptorException: Provider class com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReaderSpi not in module
I haven’t really worked with java modules, since I have only used java 8 so far but to me this looks like its missing a bunch of packages and I don’t know what to do about it. Do I need to put something into the module-info.java file? I have not used any dl4j classes or methods so far in the project.
Thanks in advance.
Here is how I added the dependencies:
implementation group: ‘org.deeplearning4j’, name: ‘deeplearning4j-core’, version: ‘1.0.0-beta6’
implementation group: ‘org.nd4j’, name: ‘nd4j-cuda-10.2-platform’, version: ‘1.0.0-beta6’
Related
I know this has been asked multiple times but the questions have multiple answers.
I'm trying to use a Java package that's a dependency of my dependency. Let's say I've built this gradle project called "ee_tools". And that has a dependency called "my_models", which has a package called "com.mycompany.my_models.db". So in the ee_tools project build.gradle, I've got
dependencies {
// My stuff
implementation group: "com.mycompany", name: "my_models", version: "1.0.0"
}
Then in my current project, I've got
dependencies {
// My stuff
implementation group: "com.mycompany", name: "ee_tools", version: "1.0.0"
Shouldn't this mean that the public classes in my_models are accessible through ee_tools to my current project? Gradle was able to find both in my artifactory instance. And the gradle dependencies command shows ee_tools under the compileClasspath, implementation, and testCompileClasspath trees, but not with its children dependencies. It also shows up in the runtimeClasspath and testRuntimeClasspath trees with its children dependencies, including my_models.
I am also able to see that package inside the jar on the left side of IntelliJ, under the "External Libraries" tree, along with some classes.
But when I try to use the my_models package in my current project, IntelliJ can't find it and it fails a gradle build with the error
error: package com.company.my_models.db does not exist
It can't find any package in that dependency. What gives? Am I declaring the dependencies incorrectly? Or is this a gap between the gradle binary in my command line vs IntellJ and gradlew?
If ee_tools depends on my_models, then your gradle file in ee_tools should be like
implementation project(path: ":path:to:my_models", configuration: 'default')
:path:to:my_models is defined in settings.gradle in project root path like this:
include ':path:to:my_models'
I have an Apache Tomcat servlet in which I would like to run some other language - for this purpose, I would like to try to get Graalvm functionality working within OpenJDK 17.
I added the following dependency to my build.gradle file:
// https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk
implementation group: 'org.graalvm.sdk', name: 'graal-sdk', version: '22.1.0'
The Gradle file parses and runs without issue, however when I try to access the Graalvm classes in my application (servlet), nothing is found!?
import org.graalvm; // is not found
For a first test, I'd like to get something simple like the following to work:
import org.graalvm.polyglot.*;
import org.graalvm.polyglot.proxy.*;
...
try (Context context = Context.create()) {
context.eval("js", "print('Hello JavaScript!');");
}
But this fails, as the required class (Context) is not found. I'm sure I'm missing something simple, but what?
Update
Thanks to #Mohammed Fataka suggestion, the Gradle build now runs successfully. My IDE (eclipse) was still showing compile errors, however a "Refresh Gradle Project" resolved that issue. (Right-click on the project within the Package Explorer, then Gradle -> Refresh Gradle Project).
I now have a new problem in that the resultant servlet crashes with the following error message: IllegalStateException: No language and polyglot implementation was found on the classpath. Make sure the truffle-api.jar is on the classpath.
So I added the following dependency:
// https://mavenlibs.com/maven/dependency/com.oracle/truffle-api
implementation group: 'com.oracle', name: 'truffle-api', version: '0.8'
But this hasn't helped, the same error still occurs.
Update 2
I finally have it working, I needed to use a different dependency:
// https://mvnrepository.com/artifact/org.graalvm.truffle/truffle-api
implementation group: 'org.graalvm.truffle', name: 'truffle-api', version: '22.1.0'
// https://mvnrepository.com/artifact/org.graalvm.js/js
implementation group: 'org.graalvm.js', name: 'js', version: '22.1.0'
I hope this helps others...
hey there please try to see if you are required to add compiler for that, if yes then add to your plugins section in build.gradle
id "org.graalvm.plugin.compiler" version "0.1.0-alpha2"
btw,i run the code you got i have no issue and i can access to them, try to see your repositories as well.
docs are here
I've been having this issue on and off for the past few weeks after beginning to learn how to use Gradle.
I added the dependency to my build.gradle file
compile group: 'org.apache.xmlgraphics', name: 'batik-all', version: '1.12', ext: 'pom'
I used VSCode's command palette to "refresh", cleaned the server workspace and ran gradle build but the new dependency does not show up in my "Project and External Dependencies" and I cannot import org.apache.batik.*
Hoping to find a fix for this in VSCode as I have seen some other IDE specific fixes.
So the issue was that in the map notation you were specifying the ext: 'pom' part. This effectively told Gradle to only import the POM file and not treat the dependency as a regular one.
When you moved to the different notation, you did not keep that pom element in the coordinates and so you got the right behaviour.
Note: compile has been replaced by implementation for a while now and is even deprecated in Gradle 6.x. Have a look at the documentation for more information on this.
The problem:
Gradle error: "Multiple dex files define Lorg/apache/http/impl/conn/AbstractClientConnAdapter;"
The question:
The error message doesn't include much detail. Is there a way to find out which files it's referring to? How can I narrow this down? I'm hoping there's an easy way to do this.
What I've tried:
Putting this for each library in the Gradle file:
exclude module: 'org.apache.http.impl.conn.AbstractClientConnAdapter'
E.g.
implementation (group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2') {
exclude module: 'org.apache.http.impl.conn.AbstractClientConnAdapter'
}
However this doesn't seem to make a difference as I still get the error. I have a multi module project but I'm only running "assemble" on one module which I believe is the problem. There are only 4 library dependencies and no local jars for this module.
What am I not understanding about how "exclude works"? If they're all excluded then where is it coming from?
Other Info:
This is an Android project but the module I'm having the problem with is a pure Java module.
I'm using Android Studio 3.0.
p.s. what is the "L" before org in the error?
Here is quite a strange effect I get when trying to compile my project that uses groovy as scripting language. The setup is pretty simple:
I have a java application that can be configured by a groovy script. The parsing of the config file is all handled by groovy code and generate several classes that contain the extracted information from the script and which than are made available to the java app.
The configuration classes all implement interfaces, to decouple the groovy aspect so that the java app is not aware that it actually talks to groovy objects.
So, with the interfaces the only dependency i have here is from groovy to java. This should be the normal case, since the groovy plugin executes compileJava before compileGroovy by default.
This worked till today!!!
A few hours ago things started getting strange. Trying to test my app with gradle test resulted in errors telling me that the groovy classes do no see the java interfaces. I tried than to compile the java and groovy seperately with compileJava followed by compileGroovy and noticed that the latter simply deletes all class files generated by the java task. I also found a strange output when running with the --info option:
Output file /home/tomas/projects/unnecessary-wizard/build/classes/main has changed.
Output file /home/tomas/projects/unnecessary-wizard/build/classes/main/de/tlongo/unneccesarywizard/java/core/Wizard.class has changed.
Output file /home/tomas/projects/unnecessary-wizard/build/classes/main/de/tlongo/unneccesarywizard/java/core/ConstructorInjector.class has changed.
Why does the groovy task change java classes at all?
As I said, I tried to reproduce the errors with a simple showcase where a groovy class also implements a java interface, w/o success.
Here is my build.script which is pretty 9-to-5, imo:
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
group = 'de.tlongo'
version = '0.3-SNAPSHOT'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.5'
compile 'commons-configuration:commons-configuration:1.7'
compile 'ch.qos.logback:logback-classic:1.1.1'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'org.reflections:reflections:0.9.9-RC1'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.mockito:mockito-all:1.9.5'
}
Any idea what is going wrong? Or do I not understand the concept of how gradle compiles this kind of projects.
When compiling both Java and Groovy source in Gradle, you should generally put all your source in the 'src/main/groovy' directory to allow for cross-compiling. They can be separate (java in java, groovy in groovy); however, if there are cross-language dependencies you can run into compilation issues - this is what is seems you are running into.
Also, as a side note, you don't need to apply the java plugin when you apply the groovy plugin - the groovy plugin depends on the java plugin so it will already be available.
This should only ever happen after a Groovy class has been ported to Java. It's a known limitation that results from the fact that both GroovyCompile and JavaCompile delete the class files they produced on the previous run in order to prevent stale class files.