Currently I am working for some homework, with postgis.jdbc in combination with postgis.geometry and postgresql.
The problem is now that Intellij always throws the following error when running the programm.
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules postgis.geometry and
postgis.jdbc export package org.postgis to module org.postgresql.jdbc
Process finished with exit code 1
I tried different ways to import, but nothing seems to work.
According to the following entry I should use classpath instead of modulepath but I can't find a setting to import a jar file using class path instead of module path.
I tried to import using Runtime instead of compile option but the packages are no longer recognized by Intellij, so this is not a working option for me.
Thanks for help.
Related
I'm new to the whole programming stuff but here's my problem:
I used to add my JUnit test cases in Eclipse by right clicking on the project, and just add New > JUnit Test Case.
Currently, I am not able to implement any test methods because Eclipse tells me on the line
import static org.junit.jupiter.api.Assertions.*;
the error message
The type org.junit.jupiter.api.Assertions is not accessible.
Error I get in the IDE:
I tried the following:
Reinstalling Eclipse, using a fresh workplace.
Adding the JUnit to Build path
Nothing helped.
It worked and works in older projects just fine.
Here is how the Package Explorer looks:
What am I missing?
You use the Java Platform Module System (JPMS) by having a module-info.java file in the default package probably without the required requires <module>; statement. JPMS was introduced in Java 9.
Do one of the following:
Delete the module-info.java file (if needed, you can recreate it via right-clicking the project folder and choosing Configure > Create module-info.java)
In module-info.java add the corresponding requires statement, e.g. by going to the line with the import statement and using the corresponding Quick Fix (Ctrl+1)
MY SETUP:
I followed the steps for the JavaFX and IntelliJ -> Modular from IDE path.
I added the ikonli-core-12.2.0.jar, ikonli-javafx-12.2.0.jar and ikonli-carbonicons-pack-12.2.0.jar via the repository to the Scene Builder in this order. Here, they work fine.
Then I added those same .jars in that same order to the IntelliJ as described here: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project.
My module-info.java file contains the following code:
module project {
requires javafx.controls;
requires javafx.fxml;
requires org.kordamp.ikonli.core;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.carbonicons;
opens com.project to javafx.fxml;
exports com.project;
}
Picture of my libraries:
PROBLEM:
When I add an icon to the .fxml file and I click on Run, I get the following error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.kordamp.ikonli.javafx not found, required by project
The module name varies. Sometimes it says it's the javafx, others the core or the carbonicons.
I'm not sure why this happens. When I'm typing in the module-info.java file I get the autofill prompts, , but when I try, for example, import org.kordamp.ikonli.core; in my Main.java, it doesn't detect them.
I'm not sure why this happens. When I'm typing in the module-info.java file or try import org.kordamp.ikonli.javafx.FontIcon; in my Main.java, I get the autofill prompts, so it means it's detecting them.
If I remove the "ikonli requires" from the module-info.java and run it, I get this error (which is kind of understandable):
java.lang.ClassNotFoundException: org.kordamp.ikonli.javafx.FontIcon
SOLUTIONS I'VE TRIED:
Adding the .jars via File -> Project Settings -> Libraries.
This seems to automatically add them to the Modules -> Dependencies, but even so, the problem persists.
Adding them in the VM Options (Run -> Edit Configuration -> Modify Options -> VM Options) in various ways, right after the --module-path ${PATH_TO_FX}:out/production mentioned in the steps linked above (out can be safely changed to mods but I chose not to do that).
First:
--module-path ${PATH_TO_IKONLI_CORE}, --module-path ${PATH_TO_IKONLI_JAVAFX} and --module-path ${PATH_TO_IKONLI_CARBONICONS}
Doing this makes it so my actual project module doesn't get detected. I.E. I get this error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module project not found
Second:
--add-modules ${PATH_TO_IKONLI_CORE},${PATH_TO_IKONLI_JAVAFX},${PATH_TO_IKONLI_CARBONICONS}
This one produces a smiliar error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module /directory/path/to/file/ikonli-core-12.2.0.jar not found
Third:
--add-modules org.kordamp.ikonli.core,org.kordamp.ikonli.javafx,org.kordamp.ikonli.carbonicons
A similar error shows up:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.kordamp.ikonli.core not found
I tried File -> Reload all from disk and Invalidate Caches / Restart options, but they seem to have had no effect.
I created a lib folder in my src project folder, put the .jars there and added them as dependencies. Now they didn't show up in the External Libraries section (because they're not external obviously) but the problem remains (I'll re-add them as external again).
ADDITIONAL INFORMATION:
I've added controlsfx.jar the same way as the Ikonli .jars. The same error occurs for it as well.
They all have their module-info.class file in the proper directory as stated in the official javadoc, yet the ModuleFinder still throws the exception.
I've also checked my project.iml file and they all have the module-libraries with the correct directories present.
I've revisted the official Ikonli installation steps multiple times and everything checks out.
Though, in there it mentions that I need to have requires javafx.base; requires javafx.graphics; in the module descriptor. Not true, at least in my case, because when I add --show-module-resolution to the VM Options, it shows that they're loaded fine, but even when I do add them, the error still appears.
END
Sorry for the long post, I'm out of ideas and I don't know what else to try.
One of the comments here mentioned that they'd put their .jar in the mods/production folder. I did the same... and it worked. (╯°□°)╯︵ ┻━┻
I guess "Modular from IDE" doesn't agree with the IDE.
Looks like the proper way to go about modular is to use Maven/Gradle. I'll rebuild and go with Gradle.
I am running a webapp using a connection to MongoDB where products reviews are stored. The current version of the webapp works correctly. (i.e. it writes and stores new reviews in the MongoDB collection).
Nonetheless, when I make changes and try to compile a new version of the MongoDB Utilities class I keep getting:
error package com.mongodb.XXX does not exist
import com.mongodb.BasicDBObject;
^
I do have the following .jar files in the \lib directory:
mongodb-driver-3.6.3
mongodb-driver-core-3.6.3
mongodb-java-driver-3.6.3
bson-3.6.3
and I mentioned them in the CLASSPATH variable:
set CLASSPATH=.;C:\apache-tomcat-7.0.34\lib\servlet-api.jar;C:\apache-tomcat-7.0.34\lib\jsp-api.jar;C:\apache-tomcat-7.0.34\lib\el-api.jar;C:\apache-tomcat-7.0.34\lib\commons-beanutils-1.8.3.jar; C:\apache-tomcat-7.0.34\lib\mongo-java-driver-3.6.3.jar; C:\apache-tomcat-7.0.34\lib\bson-3.6.3;C:\apache-tomcat-7.0.34\lib\mongodb-driver-3.6.3; C:\apache-tomcat-7.0.34\lib\mongodb-driver-core-3.6.3; C:\apache-tomcat-7.0.34\lib\mysql-connector-java-5.1.38-bin.jar;
What am I doing wrong? How can I get java to compile my new MongoDB Utilities class?
I couldn't reproduce the same behaviour, but I only reference mongodb-java-driver-3.6.3 in my build scripts.
Since the mongodb-java-driver is an uber JAR that contains mongodb-driver, mongodb-driver-core, and bson, you could try removing these latter three from your classpath and build scripts and see if that resolves the issue.
I was able to solve my issue so I post this answer in case someone is stuck in the same problem.
Thanks to what user "nos" posts in the answer to this question I used the -verbose option when compiling e.g.:
javac -verbose className.java
In the errors log I noticed that the Java compiler was searching for the MongoDB classes in a different \lib folder than the one I used in my CLASSPATH definition. So I added a copy of the mongodb-java-driver there and the compilation worked.
As craigcaulfield correctly mentions above there is no need to add the other drivers ( mongodb-driver, mongodb-driver-core, and bson).
I am trying to use JackRabbit lbrary for SVN chekin operation.
What I run my code through individual program this works fine. But when I run using web based project it doesn't work.
Code compiles fine but gives me runtime exception at following line :
MkActivityMethod activityMethod = new MkActivityMethod(url);
The exception is :
java.lang.NoClassDefFoundError: org/apache/jackrabbit/webdav/client/methods/MkActivityMethod
My project has jackrabbit-standalone-2.6.4.jar included in my eclipse jars as well as in project web-Inf/lib folder
Please let me know where I am going wrong.
There is obviously something wrong with your classpath. What Web Server Are You Using?
Here is my solution :
Try to build the project once again
Check the JDK version for the builder and Server JRE
Try clean the project (In eclipse , Project menu -> Clean )
Reason :
After you compile your code, you end up with .class files for each class in your program. These binary files are the bytecode that Java interprets to execute your program. The NoClassDefFoundError indicates that the classloader, which is responsible for dynamically loading classes, cannot find the .class file for the class that you're trying to use. It probably indicates that you haven't set the classpath option when executing your code. This link explains how to set the classpath when you execute.
So I'm working on a java-made plugin of the well known Cooja Simulator..when I click on a button, I get the exception you see in the title..
I've already read many posts related to the same issue and I have put the issuing classes in the classpath environment var, in this way (I'm working on Ubuntu):
The classes contained in "com/sun/image/codec/jpeg/JPEGCodec" are located here:
"/home/user/contiki-2.6/jar_files/lib", so that the full path is "/home/user/contiki-2.6/jar_files/lib/com/sun/image/codec/jpeg/JPEGCodec".
I've edited the bashrc file and I've inserted the following line:
export CLASSPATH=.:/path1:/path2:/path3:/home/user/contiki-2.6/jar_files/lib
Where the latter one is the path where my problematic classes are located..in the source code, the classes are imported in this way:
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
And I make the Cooja Simulator starts using the command:
ant run
I've also tried to force the required jar/classes by issuing:
ant -lib /home/user/contiki-2.6/jar_files/lib/com/sun/image/codec/jpeg run_bigmem
but I got the same error.. Anyone who can help me to solve this issue? thanks a lot..
Cooja has its own classloader. To add additional jars add a lib-folder to your plugin and copy the jars into that folder. Then add
se.sics.cooja.GUI.JARFILES = + file1.jar file2.jar
to the cooja.config.
Look at https://github.com/contiki-os/contiki/tree/master/tools/cooja/apps/mspsim as an example - here the required jars are copied by Ant.