I have a Java/Spring project for which I am responsible for familiarizing myself with the code. To do this, I am debug stepping through different parts of the program and studying the variable states and call stack. I would like to run this in IDEA since I like that IDE more and have used it before. Whereas the program runs fine in Eclipse-STS, when run in IDEA, I get this:
[ERROR] Application [main]: Can't build application context: Error creating bean with name 'entityManagerFactory' defined in class path resource [springconfig.xml]: Invocation of init method failed; nested exception is java.lang.SecurityException: class "org.eclipse.persistence.internal.helper.Helper"'s signer information does not match signer information of other classes in the same package
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [springconfig.xml]: Invocation of init method failed; nested exception is java.lang.SecurityException: class "org.eclipse.persistence.internal.helper.Helper"'s signer information does not match signer information of other classes in the same package
I noticed that there is a class Helper.java in our software but it is the only class in it's package so why would it complain about this class's signer information not matching that of the rest of the classes in the same package?
Elsewhere on Stack Overflow, I learned this can happen when a particular class is being imported by multiple JARs into the same project, hence causing the conflict. I wasn't sure how this conflict could be because as the image before shows this class is a native *.java file in the project and not imported from any JAR. What's more, it's the only class in it's package which makes the error message difficult to understand. But then I realized that our project also imports a JAR which has this class in it. Namely, we import eclipselink-2.5.0.jar. So, I thought that our source class when compiled might be conflicting with the Helper.class in this package.
So, I thought the original error message is about our Helper.class being treated as belonging to the JAR and so the IDE complaining that the JAR's manifest signature didn't match with any signature on our Helper.class.
So, as an experiment I tried to delete this JAR's signature manifest as well as delete the Helper.class from within it. Then I cleaned and recompiled the project to no avail.
Related
I'm trying to migrate a Java application that uses Tika from OracleJDK 1.8 to OPenJDK 13.
My IDE is Eclipse.
I have created the file module-info.java to indicate the required modules for my application.
In order to be able to use Tika classes such as AbstractParser, Detector, etc., I have added requires org.apache.tika.core; in module-info.java.
My code also uses the class org.apache.tika.parser.pdf.PDFParserConfig to extract embedded images:
PDFParserConfig pdfConfig = new PDFParserConfig();
pdfConfig.setExtractInlineImages(true);
context.set(PDFParserConfig.class, pdfConfig);'
I get the compilation error:
PDFParserConfig cannot be resolved to a type
Eclipse suggests to add requires org.apache.tika.parsers; to module-info.java: Eclipse suggestion screenshot.
When I add this module requirement to module-info.java, the application compiles properly.
That is, at this stage we have included in module-info.java:
module myapp {
/** others ... */
requires org.apache.tika.core;
requires org.apache.tika.parsers;
}
However, when trying to execute the compiled application, we get the error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Admin\.m2\repository\org\apache\tika\tika-parsers\1.24\tika-parsers-1.24.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.tika.parser.onenote.OneNoteParser not in module
Inspecting the project Libraries in Eclipse, I can see that tika-core and tika-parsers (v1.24) are both modular: Eclipse Java Build Path
In conclusion: If I don't add org.apache.tika.parsers as a required module, the application won't compile, and if I add it I get the runtime error saying org.apache.tika.parser.onenote.OneNoteParser is not in the module.
I have inspected the JAR files for these packages to see the dependencies they have. The core packages seems to be right:
$ jar --file=tika-core-1.24.jar --describe-module
No module descriptor found. Derived automatic module.
org.apache.tika.core#1.24 automatic
requires java.base mandated
contains org.apache.tika
contains org.apache.tika.concurrent
contains org.apache.tika.config
contains org.apache.tika.detect
contains org.apache.tika.embedder
contains org.apache.tika.exception
contains org.apache.tika.extractor
contains org.apache.tika.fork
contains org.apache.tika.io
contains org.apache.tika.language
contains org.apache.tika.language.detect
contains org.apache.tika.language.translate
contains org.apache.tika.metadata
contains org.apache.tika.mime
contains org.apache.tika.parser
contains org.apache.tika.parser.digest
contains org.apache.tika.parser.external
contains org.apache.tika.sax
contains org.apache.tika.sax.xpath
contains org.apache.tika.utils
...but the 'parsers' jar gives an error:
$ jar --file=tika-parsers-1.24.jar --describe-module
Unable to derive module descriptor for: tika-parsers-1.24.jar
Provider class org.apache.tika.parser.onenote.OneNoteParser not in module
Does this mean the jar package for parsers is not well formed?
Is there any workaround for this?
Thank you.
EDIT:
If I try with version 1.24.1, I get the execution error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\Admin\.m2\repository\org\apache\tika\tika-parsers\1.24.1\tika-parsers-1.24.1.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.apache.tika.parser.external.CompositeExternalParser not in module
That is: the failing class is CompositeExternalParser instead of OneNoreParser.
Inspecting META-INF/services/org.apache.tika.parser.Parser of tika-parsers-1.42.1.jarI can see the entryorg.apache.tika.parser.external.CompositeExternalParser` but the package does not contain this class.
So, it seems to be an error in this META-INF file. Id this due to an error when compiling the package and submitting it to Maven Central?
I've found a JIRA issue, TIKA-2929, where they say "Apache Tika needs to be on the Java Classpath, not the module path". I've tried this, but, as explained before, I get a compilation error if I don't add it to the module path and set requires org.apache.tika.parsers;.
This is a hard puzzle...
Ran into the same issues.
Also found the faulty entries in
org.apache.tika.parser.Parser (and also org.apache.tika.parser.Detector) in META-INF/services/
A quick fix is to ...
Unpack those files
delete the lines that seem to reference non existing classes
pack them back into the jar
My project compiled after that.
For sure no longterm solution, but since even older versions i tried ran into that problem, it might help out some people.
This question already has answers here:
Random NoClassDefFound error in Web Application
(1 answer)
Why am I getting a NoClassDefFoundError in Java?
(31 answers)
Closed 6 years ago.
I am trying to run a spring project in intellij.
When I import the code and add the necessary jars, it there is no error during compile time. However, when I run the project, I get the following error
Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/company/access/KeyValueAccess
The KeyValueAccess class is present in the cassandra-access-1.12.0.jar as highlighted in the image.
I have tried to add jars as modules and also as libraries.
What is the correct way to avoid this runtime error?
PS: This is the case for only manually added external libraries. The libraries downloaded with maven work just fine.
Edit
The following code generates the exception
#Bean
public KeyValueAccess keyValueAccess() {
return new CassandraAccessDatastax(); //This doesn't matter, the return type itself creates the exception
}
Exception generated is as below:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.worksap.bootcamp.webeditor.config.WebEditorConfig#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/company/access/KeyValueAccess
I also checked that the jar does it fact have the required class files.
Edit2
I manually ran maven to add the jar files, so I can now find them in ~/.m2/repository. When I call a class in the jar, it seems to find it but when that class calls another class in the same jar, it gives java.lang.NoClassDefFoundError
As I see in your screen, you added cassandra manually, not using maven? So this may be the problem. Add dependencies to pom.xml. Watch them here.
Also check if your dependencies added to special module, not just in libraries. Go to file->project structure->modules. Choose your module in which you use cassandra and click on "dependencies" tab. Press "+" and "library" from dropdown menu and then add your libraries to project.
I'm using netbeans to generate a web service client from a WSDL doc.
The client works fine until we put it in our production environment. The jars were generated against javax.ws.xxxxx classes from jaxws-api.jar and jaxb-api.jar, which we placed in out production classpath.
In our production environment we have other code that depends on xfire libraries. When we attempt to instantiate SubmissionAPI(), we are getting a NoClassDefFound Exception. I'm pasting the stack trace below.
UBLSoapTest class appears to call the correct 'Service' class, but the 'Service' class
is calling org.codehaus.xfire.jaxws.Provider.
I've checked the source for javax.xml.ws.Service, and it has 'import javax.xml.ws.spi.Provider;'
We've tried assembling the jar with the javax.xxxx classes inside and still get the same result. I suspect we need to set a classpath in the manifest file, but I'm not sure what needs to be there.
FAIL: Exception: java.lang.NoClassDefFoundError: Could not initialize class
org.codehaus.xfire.jaxws.JAXWSHelper
org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:33)
org.codehaus.xfire.jaxws.ServiceDelegate.<init>(ServiceDelegate.java:53)
org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32)
javax.xml.ws.Service.<init>(Service.java:56)
org.ubl.soap.test.SubmissionAPI.<init>(SubmissionAPI.java:44)
I'm a bit at a loss of even where to look from here.
We've tried setting classpath in the manifest, with little success.
The basic jar structures we've tries are:
/org/xxxx
/META-INF/xxx
and
/org/xxx
/META-INF/xxx
/javax/xxx
and
/org/xxx
/META-INF/xxx
/jaxws-api.jar
/jaxb.jar
It seems that you are missing the impl jar for JAX-WS. If you are relying on Codehaus to provide the impl, you might want to make sure their impl works. According to their site, it's a newly supported component.
The alternative is to provide your own impl jar and put it in the class path so JAX-WS interfaces are found there. But usually the app server where you deploy your web service app should include the impl in its class path.
in my google app engine project Log section write out
java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate...
I have read java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate and did as it is written. But its' had no effect and my server is not working
The exception says, No class def found. That mean the JVM is not able to load the said class file. You will have to make sure that this class is available in the commons-lang project.
Validate that you have commons-lang-<>.jar is added to class path of your project configuration. If not please do add the said jar file in the class path.
I am using eclipse to develop my application. In my application i have few projects and those projects have reference in EAR project.
In one of project i have created a interface and impementation for that interface.
I am trying to craete object for that class
MyInterface myObj = new MyClass();
It was not working so i started server in debug mode. I am getting NoClassDefFoundError.
Any idea why i am getting this error. I have already added new project in my project build path. If i write
MyInterface myObj = null;
i do not get any error.
Check the classpath used by the runtime configuration you're running in Eclipse, which is normally defined by the project libraries and source folders.
Since you're working with an EAR, you probably use an app server, and you need to know that most of them work with one parent classloader and a child classloader per ear or war. That means that if a class loaded by a parent classloader tries to instantiate a class which is only in a child classloader you get a NoClassDefinedError (the other way around you don't).
This was happening to me. The problem was not that "MyClass" was missing from the classpath. What was missing in my case was one of the dependencies inside MyClass (i.e. an import) and when the constructor was called it failed.
Check my related question and the answer: Class Constructor fails throwing Exception on Class Loading as well as the question before that which is when all my problems started: Weird behavior with Constructor and Class. Application hangs `forever` on Constructor