I am trying to run some junit tests within Intellij 14 on Windows 7. I have run these tests before, many many times, without issue.
Yesterday, I started getting the error on SOME tests only:
java.lang.SecurityException: sealing violation: package xxx is sealed
I cannot google up a satisfactory answer to this. I initially thought it was something odd that suddenly went wrong in intellij 15, so I reverted back to 14 (cleaned up the settings folder too) but same issue.
Same tests, run from Linux using an ant script and the same jar file run just fine.
What does this error mean and what must I do to fix it?
It sounds like you could have a class that is being packed into multiple jar. Do you have a production jar and maybe a test jar which share some class between them?
Related
Newbie to Java having issue with an existing code base.
It seems Java files in /src/code are not being picked up.
Other devs here use IntelliJ, which runs tests fine out of the box (default config). I'm trying to use VSCode but also get the same result running via the terminal:
Running a test gives me a "cannot find symbol" error trying to import local classes from /src/test/... If I copy the problematic file into /src/main/... that file imports fine but error reappears with the next imported file, and so on.
Note that command clicking the 'missing' file opens its source in VSCode, so I know it's there.
import is standard:
import com.foo.bar.baz.math.TestMathModelFactory;
File exists under:
work/src/test/java/com/foo/bar/baz/math/TestMathModelFactory.java
It builds if I put it under:
work/src/main/java/com/foo/bar/baz/math/TestMathModelFactory.java
Expect it to import, but get:
RTPTest.java:3: error: cannot find symbol
import com.foo.bar.baz.math.TestMathModelFactory;
^
I know I'm doing something stupid, but ¯\_(ツ)_/¯
LOL, was my own Pebkac issue. I was trying to run the tests via the VScode "Code Runner" extension – which, in retrospect, has no idea how the project is set up. When I ran the tests via the "Java Test Runner" extension, they ran fine.
I told you the issue was my stupidity! Thanks for the ideas anyways!
I am trying to compile and run the project
https://github.com/jitsi/jitsi-android on Eclipse by Importing.
I have imported the project successfully,Added External Jar files and Fix some of compilation errors.
When I try to run app, It is giving
Conversion to Dalvik format failed with error 1 Error on the console.So that I Clean the project, checked the all the jar files from Order and Export tab and build it again.
but it doesn't work for me.
Finally, I unchecked the all the libraries from Order and Export tab,build and run it again.
But still its giving me same error and my application is getting crashed every time i run it.
Any help will be appreciated , i really want to run this application.
here is my libs folder screenshot:-
I've had the same problem once.
Here is what I found out when I was trying to solve my issue:
The error is caused when there are two Classes/Packages with the same name (For example when LibaryX has Class org.a.b.c.Sample and LibaryY has class org.a.b.c.Sample aswell)
Different approaches which worked for some people (So if you have the error yourself, make sure to test following things out):
A) Two Libaries have the exactly same package/class-> Delete the class in one of the Libaries
B) One Jar is detected twice because it's for example in the project source folder and in the Java Build Path Libaries aswell
C) Updating Proguard often fixes it aswell (Put the new Proguard jars in [Android SDK folder]\tools\proguard\lib)
D) Cleaning the Project also helped many people (you already did that, so that won't be your solution)
When I had this issue myself it was caused because I did not follow the instructions of one of the libaries that I used. After following the libary instructions step by step, everything worked fine again.
Greetings
Felix
I recently upgraded to IntelliJ 14, then added Scala support.
My main files stopped running. For example the GUI file, which has no errors and is a totally self contained hello world style for testing this error:
Exception in thread "main" java.lang.ClassNotFoundException: GUI
It makes no sense and I'm pretty frustrated that the IntelliJ devs are slacking in not auto-detecting a solution to this. I have tried everything to fix it. From settings, compilers, to making the project from scratch.
I only had a bit of luck when making it from scratch, but as soon as I started to add my other files (files that were not even being used!) it starts with the error.
It seems that any files outside of the original project module (when creating a new project to test fix) will not run giving ClassNotFoundException.
This may be related to my other question: https://stackoverflow.com/questions/27516673/cannot-run-file-located-out-of-main-module-intellij-14-java-scala
Sample View of the problem
I had the same problem and was able to fix it by right clicking the directory my class was in, and clicking Mark as sources root. This should make your class discoverable and able to run.
Solution
Turns out that Make, No Error Check does not work the same for scala as it does for Java.
Errors in the scala files will cause an ambiguous error message on run, with no clear link to the error.
Fixing the scala files fixes the error.
In my case, the solution was at the JDK and java level.
When I set JDK 14 this error occurred.
So when I work with a scala project, I set java 8 everywhere in the project(module) settings and in the configuration of the main method.
In project(module) settings section: Project, Modules, SDK's
In main method settings: JRE
I have recently installed NB 7.3.1, and installed the JUnit plugin. In the old days, JUnit was bundled with NetBeans. I used it all that time.
I want to use it now, but I can't find any command, button, tool, etc to cause Netbeans to create the shell unit tests for me.
What am I doing wrong? How do I find it?
Thx
Make sure you have a test folder. Go to your project properties, and under Sources, in Test Package Folders, make sure you have at least one folder where you want to put your test sources.
If the button is still greyed out after that, you can go to File > New File > Unit Tests > JUnit Test. If it gives you an error message, it may help you solve the problem.
I have two different java projects (I'll call them project 1 and Project 2 for simplicity's sake) loaded into eclipse, and project 1 is added to the build path of project 2. I have imported the only package in the src folder of project 1 into a test class for project 2, and within the code of that test class I have simple object declarations of classes from project 1 as such:
ProjectOneClass object = new ProjectOneClass();
This code compiles without error, the compiler recognizes that these classes are on the build path. When I run the code as a Java application via Junit4, though, the program throws ClassNotFoundExceptions when it comes across these lines of code. The code is supposed to print these ClassNotFoundExceptions to the error log, but for some reason nothing is being printed. I'm using a simple
try {
...
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
structure, so I don't know why it's not printing to the error log.
The JUnit printout is simply:
Junit execution complete
Summary: 4 succeeded, 3 failed.
The four that succeed do not reference the imported project 1 package.
I have tried all manners of changes to the build path configurations, and nothing has shown any promise of improvement. The only thing I can think might be able to fix this is the order of the build path as specified in the Order And Export tab of the build path configuration window. Right now the order is:
project 2 packages
EAR Libraries
JRE System Libraries
JUnit4
a few JAR files (c3p0, commons-codec, ojdbc6)
project 1
I don't know for sure if the problem lies here or elsewhere, though. If anyone can help me out with this, I'd be very grateful. Thanks for reading.
I figured out the issue. Project 1 relies on several JARs that Project 2 doesn't have as part of its build path. I figured that since Project 1 had those JARs set within its build path, it would still work fine. Upon creating instances of classes from Project 1, however, I found that Project 2 required these JARs in its own build path.
This would make sense to me if the classes I was instantiating were implementations/extensions of a class from one of these JARs, but they weren't.
Regardless, by adding a couple of JARs to Project 2 I fixed the problem. Thanks everyone.
You should set the Run Configuration for your Project 2 class file.
In Eclipse, you can right click -- Select Run As -- Run Configuration and then in the classpath tab, make sure Project 1 is added by clicking on Add Projects.
Let's narrow down the problem and see if it relates to a JUnit launch config, or a more general problem involving the two Eclipse projects.
Create a class in Project 2 with a main(String[]) method. In that method, reference one or more of the types in Project 1 that appear to be causing your CNFE's. Run this class using the Java Application launch configuration type. (I'm assuming from your post that you're having trouble with launches based on the "JUnit Test" Launch Configuration type.) Report back.
Also, I've seen some funny behavior using the JUnit Test launch configuration type with JUnit 4 tests of late, although I don't think it's totally broken. So you could try a JUnit 3 configuration.