java.lang.NoClassDefFoundError: Could not initialize class hudson.util.ProcessTree$UnixReflection - java

I am having this problem when trying to build my project with Jenkins:
java.lang.NoClassDefFoundError: Could not initialize class hudson.util.ProcessTree$UnixReflection.
java.lang.NoClassDefFoundError: Could not initialize class hudson.util.ProcessTree$UnixReflection
at hudson.util.ProcessTree$Unix.get(ProcessTree.java:506)
at hudson.util.ProcessTree.killAll(ProcessTree.java:144)
at hudson.Proc$LocalProc.destroy(Proc.java:380)
at hudson.Proc$LocalProc.join(Proc.java:353)
at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:155)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405)
I have tried to downgrade from JAVA JDK 1.8 to 1.7 but still not resolving the problem.
This is a JavaScript project, the test are passing but build failed because of that error.
Could you help me?

We fixed it by reducing jenkins stdout/stderr output. Just redirect called commands' output to files and try again.
It is just a workaround until Jenkins team fix it but it works pretty well for us.

Related

Error: NoClassDefFoundError When Using Eclipse To Run COMSOL Model

I am trying to use Eclipse to run a COMSOL model and I have read the guide from programming reference manual. However, Eclipse always report the error as follows,
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter at com.comsol.client.interfaces.b.(SourceFile:60) at com.comsol.client.interfaces.b.(SourceFile:39) at com.comsol.clientapi.engine.APIEngine$c.b(SourceFile:497) at com.comsol.clientapi.engine.APIEngine.a(SourceFile:115) at com.comsol.clientapi.engine.APIEngine.connect(SourceFile:98) at com.comsol.clientapi.engine.APIEngine.connect(SourceFile:87) at com.comsol.clientapi.engine.ClientModelUtil.connect(SourceFile:145) at com.comsol.clientapi.engine.ClientModelUtil.connect(SourceFile:133) at com.comsol.model.util.ModelUtil.connect(SourceFile:248) at PFCZM_3PBending_QuasiBrittle.main(PFCZM_3PBending_QuasiBrittle.java:16750) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) ... 10 more
I believe I have imported the JAR files correctly and set the path for the project and it seems that the error is due to lack of source file for COMSOL API JAR files. I have checked those JAR file and found they are indeed all class files without definition. How can I solve this problem? Thanks!

Exception in thread "main" java.lang.reflect.InvocationTargetException while installing maven project

I'm trying to install maven project but facing an
exception: Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test
(default-test)
There are test failures.
When I looked at the .dump file I see this:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_c13123e.PreMain.premain(PreMain.java:47)
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.base/java.lang.Class.getField(Class.java:1999)
org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at line: 422
I'm pretty sure there is no any problems in the code as it works well on other computers. Skipping tests is not an option because it is an integration-tests module
The answer below helped. For me it was a problem between Jacoco version and my JDK.
There are two options to solve this:
Make sure that there is an appropriate version for your JDK and upgrade jacoco
Use an older JDK
Just to add to the given answer. My issue was due to the fact that I was using Java 14. JaCoCo needed an older version. So I downloaded and installed JDK 1.8.0. Now in IntelliJ:
Go to project structure (top right)
Click on Project under Project Settings
Then select JDK 1.8

java.lang.NoSuchFieldException error from jacoco

I am trying to run the tests of the kotlin code provided from here : https://github.com/ligi/ipfs-api-kotlin with gradlew
I got the error listed below.
Could someone tell me what this error means ?
> Task :test FAILED
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_c13123e.PreMain.premain(PreMain.java:47)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.base/java.lang.Class.getField(Class.java:1999)
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at line: 422
I was missing the following from my build.gradle:
jacoco {
toolVersion = "0.8.6"
}
While obvious, build.gradle can inherit properties from other gradle files and for reasons I can't figure out, jacoco was passing through in to one subproject but not to another.
Ensure you are using JDK-11,
if using maven, ensure;
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Ensure you are using latest jacoco.
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
Fixed this error changing Java SDK in my project from 14 to 11 and my tests started working fine.
Solution:
IntellijIDEA: File > Project Structure > Project Tab > SDK adopt-opendjdk-11 (in my case for Ubuntu).
Oh! Make sure Gradle Settings are also using the same JVM!
Hope that helps someone out there.
The issue comes from the Java version which needs not to be too recent.
sdk install java 19.3.0.2.r8-grl
makes things ok.
After followed below steps it's working fine for me.
In Eclipse,Go to Window--Preferences--java.Right-click on installed JRE. There add an installed JDK path & remove others.
I had similar issue when I upgraded my jdk1.8 to openjdk11 but it was solved by updating the toolVersion = "0.8.6" (used toolVersion = "0.8.1" with jdk1.8)
Fix in my case was to download and install Java 8 (jdk1.8.0_301) and set it in Project Settings

Timezone Error when running GWT/GAE app

I'm getting this error when running my GWT/GAE app:
java.lang.RuntimeException: Unable to restore the previous TimeZone at com.google.appengine.tools.development.DevAppServerImpl.restoreLocalTimeZone(DevAppServerImpl.java:348) at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:251) at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97) at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509) at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068) at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811) at com.google.gwt.dev.DevMode.main(DevMode.java:311) Caused by: java.lang.NoSuchMethodException: java.util.TimeZone.setDefaultInAppContext(java.util.TimeZone) at java.lang.Class.getDeclaredMethod(Class.java:2117) at com.google.appengine.tools.development.DevAppServerImpl.restoreLocalTimeZone(DevAppServerImpl.java:344) at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:251) at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:97) at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509) at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068) at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811) at com.google.gwt.dev.DevMode.main(DevMode.java:311)
Although I added -Dappengine.user.timezone=UTC and -Dappengine.user.timezone.impl=UTC
If you're getting java.lang.NoSuchMethodException error on JDK 8, its likely this bug https://github.com/GoogleCloudPlatform/gcloud-maven-plugin/issues/54
The solution discussed there is to add config to the appengine maven plugin.
<jvm_flag>
<jvm_flag>-Dappengine.user.timezone=UTC</jvm_flag>
</jvm_flag>
Passing the argume as -D does not work (nor adding .impl) as discuess in older solutions.
Try this.
TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00"));
for example this is for Bogota, Lima, Quito .. you can choose your Zone here
The error got fixed when I updated the GAE version from 1.8.0 to 1.8.8+

Runtime ERROR : java.lang.ClassNotFoundException: com.caucho.server.resin.EnvInit

When I checkout and run the jee6-cdi I'm getting the below Run Time error.
Any idea how to resolve this issue?
com.caucho.config.ConfigRuntimeException: java.lang.ClassNotFoundException: com.caucho.server.resin.EnvInit
at com.caucho.config.ConfigException.create(ConfigException.java:168)
Maybe you haven't added the external library in build path

Categories