After upgrading to new Jenkins version, builds are failing - java

I just upgraded the jenkins from 2.63 to 2.117 (Which I'm regretting now)
Here is the error message I'm getting at the end of all the jobs.
Please help me to understand and resolve this.
FATAL: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild
java.lang.UnsupportedOperationException: Refusing to marshal java.io.PrintStream for security reasons; see https://jenkins.io/redirect/class-filter/
at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:543)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
Caused: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.EnvironmentVarSetter#log for class org.jenkinsci.plugins.EnvironmentVarSetter
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
Caused: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class hudson.model.FreeStyleBuild
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
at hudson.XmlFile.write(XmlFile.java:193)
Caused: java.io.IOException
at hudson.XmlFile.write(XmlFile.java:200)
at hudson.model.Run.save(Run.java:1923)
at hudson.model.Run.setDisplayName(Run.java:803)
at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.setDisplayName(BuildNameSetter.java:76)
at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter.access$000(BuildNameSetter.java:31)
at org.jenkinsci.plugins.buildnamesetter.BuildNameSetter$1.tearDown(BuildNameSetter.java:64)
at hudson.model.Build$BuildExecution.doRun(Build.java:174)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1727)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Note: Others who are using older version of jenkins, there is a big chance that all your jobs will be messed up. So, Please do not update jenkins as of now. (https://jenkins.io/blog/2018/03/15/jep-200-lts/)

You can try the solution given in the official site of Jenkins
https://issues.jenkins-ci.org/browse/JENKINS-49144
Add the three following entries to whitelisted-classes.txt:
java.util.concurrent.locks.ReentrantLock
java.util.concurrent.locks.ReentrantLock$NonfairSync
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject

It is to do with the two things.
Permission to be updated to the .war file.
Build Pipeline plugin needs to be updated.
This solved my problem.

It's a known security fix in Jenkins https://github.com/jenkinsci/jep/tree/master/jep/200.
You can check list of affected plugins https://wiki.jenkins.io/display/JENKINS/Plugins+affected+by+fix+for+JEP-200 and upgrade your affected ones to overcome the error.

Related

Logstash unable to start pipeline

I am working with Logstash v7.15.1 and when I am trying to run it, I am getting below error which I am unable to figure out. Will someone help me to fix this?
Note - I have removed several plugins comes bundled with Logstash as all were not part of my requirement.
[2021-11-10T11:38:45.045Z][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:logstash, :exception=>"Java::JavaLang::NoSuchMethodError", :message=>"java.nio.MappedByteBuffer.position(I)Ljava/nio/MappedByteBuffer;", :backtrace=>["org.logstash.ackedqueue.io.MmapPageIOV2.create(MmapPageIOV2.java:194)", "org.logstash.ackedqueue.Queue.newCheckpointedHeadpage(Queue.java:352)", "org.logstash.ackedqueue.Queue.openPages(Queue.java:209)", "org.logstash.ackedqueue.Queue.open(Queue.java:176)", "org.logstash.ackedqueue.ext.JRubyAckedQueueExt.open(JRubyAckedQueueExt.java:123)", "org.logstash.ackedqueue.ext.JRubyWrappedAckedQueueExt.initialize(JRubyWrappedAckedQueueExt.java:65)", "org.logstash.ackedqueue.QueueFactoryExt.create(QueueFactoryExt.java:62)", "org.logstash.execution.AbstractPipelineExt.openQueue(AbstractPipelineExt.java:205)", "org.logstash.execution.AbstractPipelineExt$INVOKER$i$0$0$openQueue.call(AbstractPipelineExt$INVOKER$i$0$0$openQueue.gen)", "org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:355)", "org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:144)", "org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:345)", "org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)", "org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:86)", "org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:73)", "org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:85)", "org.jruby.RubyClass.newInstance(RubyClass.java:939)", "org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)", "org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:207)", "opt.logstash.logstash_minus_core.lib.logstash.pipeline_action.create.RUBY$method$execute$0(/opt/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52)", "opt.logstash.logstash_minus_core.lib.logstash.pipeline_action.create.RUBY$method$execute$0$__VARARGS__(/opt/logstash/logstash-core/lib/logstash/pipeline_action/create.rb)", "org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:80)", "org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:70)", "org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:207)", "opt.logstash.logstash_minus_core.lib.logstash.agent.RUBY$block$converge_state$2(/opt/logstash/logstash-core/lib/logstash/agent.rb:391)", "org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBody.java:138)", "org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:58)", "org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:52)", "org.jruby.runtime.Block.call(Block.java:139)", "org.jruby.RubyProc.call(RubyProc.java:318)", "org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:105)", "java.lang.Thread.run(Thread.java:748)"]}
warning: thread "Converge PipelineAction::Create<logstash>" terminated with exception (report_on_exception is true):
LogStash::Error: Don't know how to handle `Java::JavaLang::NoSuchMethodError` for `PipelineAction::Create<logstash>`
create at org/logstash/execution/ConvergeResultExt.java:135
Apologies for posting incomplete information. After hours of troubleshooting, I was able to fix the issue. It was related to using different version of ruby and java. FYI, I am running Logstash in container and then deploying it on K8s cluster. I have removed plugins from Logstash source code itself and then build it.

Unable to Connect to PowerDesigner through java

I have a requirement to automate the process of connecting to PowerDesigner through java to extract the models from repository. I have used the OLE Automation JavaProxy document to configure the process.
when trying to run, I'm getting this error:
Exception in thread "main" java.lang.NoSuchMethodError: org.eclipse.swt.internal.ole.win32.COM.CoCreateInstance(Lorg/eclipse/swt/internal/ole/win32/GUID;IILorg/eclipse/swt/internal/ole/win32/GUID;[I)I
at
com.sybase.stf.powerdesigner.PdCommon.Application.start(Application.java:57)
at
com.sybase.stf.powerdesigner.PdCommon.Application.(Application.java:31)
at
com.sybase.stf.powerdesigner.PdCommon.Application.getInstance(Application.java:42)
at OOM.src.createOOM.CreateOOM.CreateAndDisplayOOM(CreateOOM.java:37)
at OOM.src.createOOM.CreateOOM.main(CreateOOM.java:28)
Versions:
PowerDesigner - 16.5.5.0
Eclipse 4.18
Supporting Jars:
pdj2com_16.5.5.jar
org.eclipse.swt.win32.win32.x86_64_3.115.100.v20201202-1103.jar
The above issue is resolved Thanks!
Now i'm facing trouble connecting again with the below issue.
org.eclipse.swt.SWTException: Action can not be performed. result = -2137456383 (com.sybase.stf.powerdesigner.com.COMException: COM Failure [HRESULT: 0x80990101])
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:345)
at com.sybase.stf.powerdesigner.com.COMException.raiseOnFail(COMException.java:83)
at com.sybase.stf.powerdesigner.com.IDispatchEx.raisingInvoke(IDispatchEx.java:231)
at com.sybase.stf.powerdesigner.PdCommon.IApplication.CreateModel(IApplication.java:84)
at OOM.src.createOOM.CreateOOM.createOOM(CreateOOM.java:68)
at OOM.src.createOOM.CreateOOM.CreateAndDisplayOOM(CreateOOM.java:42)
at OOM.src.createOOM.CreateOOM.main(CreateOOM.java:28)
Caused by: com.sybase.stf.powerdesigner.com.COMException: COM Failure [HRESULT: 0x80990101]
at com.sybase.stf.powerdesigner.com.COMException.raiseOnFail(COMException.java:88)
... 5 more
Is there anything else to add to the code to connect?
I am not able to find any solution online. Kindly help me figure this out. Thanks in advance.
The swt.win.win32.x86_64 jar is for 64-bit, so I assume you're using a 64-bit Java.
In my case, the pdj2com jar is named something like pdj2com_16.N.Nx64.jar for the 64-bit version. pdj2com_16.N.N.jar is the name of the 32-bit version.

Intermittent failure of dependencyCheck on Jenkins

We are using the owasp dependencyCheck plugin in our project.
Version used: 1.4.5
We are facing the following issue in our build jobs on Jenkins:
The build job fails intermittently saying " :dependencyCheck FAILED "
The stacktrace of the error is as follows:
:dependencyCheck
Verifying dependencies for project stock-service
Checking for updates and analyzing vulnerabilities for dependencies
Unable to update Cached Web DataSource, using local data instead. Results may not include recent vulnerabilities.
Exception occurred initializing CPE Analyzer.
Generating report for project stock-service
Found 0 vulnerabilities in project stock-service
:dependencyCheck FAILED
Caused by: org.owasp.dependencycheck.exception.ExceptionCollection: One or more exceptions occurred during dependency-check analysis
org.xml.sax.SAXException: Unable to get primary key for new cpe: cpe:/a:uchida_yoko_co._ltd:assetbase:8.0
org.owasp.dependencycheck.data.nvdcve.DatabaseException: Unable to get primary key for new cpe: cpe:/a:uchida_yoko_co._ltd:assetbase:8.0
An exception occurred accessing the database
at org.owasp.dependencycheck.Engine.analyzeDependencies(Engine.java:543)
at org.owasp.dependencycheck.Engine$analyzeDependencies$0.call(Unknown Source)
at org.owasp.dependencycheck.gradle.tasks.Check.check(Check.groovy:86)
... 66 more
If your code has multiple microservices, then all the services create a database locally on Jenkins and update it as part of owasp dependencyCheck task on the following location:
/{your jenkins
directory}/.gradle/caches/modules-2/files-2.1/org.owasp/dependency-check-utils/dependency-check-data/3.0/dc.h2.db
Since this file is shared by all the services, there are locking issues. If any one service fails during build, the lock that it created on the file is not removed and thus the other services would subsequently fail.
Following link describes the issue and suggests a solution:
https://github.com/jeremylong/DependencyCheck/issues/410
This solution was not usable as is, we had to change the "autoUpdate=true" so that the service creates a db file if it does not already exist.
After the above change ( i.e adding "data directory" configuration in dependencyCheck task [visit the above link for this config]),
the issue seems to have been fixed.

Broken pipe error when running Gradle test

I've got a problem regarding running tests in gradle. I know that in other machines my gradle config works but in mine unfortunately not. We have got junit test and testNG and both of them, when try to execute, produces stacktrace like this:
Could not write standard input into: Gradle Worker 1.
java.io.IOException: The pipe is being closed
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:318)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:53)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Which continuously will produce this error with different number (Gradle Worker 2, Gradle Worker 3, etc). Has anybody ever faced similar problem?
I'm using gradle 1.6.
EDIT: I forgot to tell that I'm using gradle wrapper
EDIT: After changing to version 1.12 I'm receiving error:
Caused by: org.gradle.api.InvalidUserDataException: Could not create task '(custome taks name)': Unknown argument(s) in task definition: [mustRunAfter]
11:20:17.990 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.TaskFactory.validateArgs(TaskFactory.java:147)
11:20:17.991 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.TaskFactory.checkTaskArgsAndCreateDefaultValues(TaskFactory.java:134)
11:20:17.991 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:72)
EDIT: Ok I think I have found what cause this problem - it was Antivirus. When I disable it script moves a little bit forward but ended with:
org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [e42b57ea-ced6-4bb6-9369-3186ab4983d6 port:63631, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].
at org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector.connect(TcpOutgoingConnector.java:62)
at org.gradle.messaging.remote.internal.hub.MessageHubBackedClient.getConnection(MessageHubBackedClient.java:35)
at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:54)
at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:85)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:41)
at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:43)
at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:32)
at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:46)
at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:32)
at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:32)
at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:37)
Caused by: java.net.ConnectException: Connection refused: connect
Searching with google on this error gives me nothing (only some old gradle 1.1 errors info). Anybody faced this kind of problem?
Whew, after whole day struggling with gradle I think I've finally found what cause problems. Guilty of that was antivirus - COMODO. After uninstalling it and installing another one, everything started to working fine. So all Gradle Users - please be careful with COMODO because even disabled, it could cause problems when using Gradle . Be aware :)
I faced the similar issue while running the test classes. I can able to build the project, but I couldn't able to run, so after some research I found one of the solution, which is to remove the some of the workerThread-jar from the .gradle/cache folder. I tried and it worked for me. You can use below commands to solve this.
In terminal I invoked gradle test --info command,
In response, I receive the logs, where I searched the for the
Gradle worker Daemon
key, to fetch the location of my gradle-worker.jar. Typically in windows you can find this under the following location C:\Users\.gradle\caches\\workerMain\gradle-worker.jar.
To fix this, one approach is to remove the the workerMain folder itself, and run the test classes.
You really don't need to disable or remove COMODO Antivirus. Just do the following steps:
Go to COMODO Client Panel
Open the Advanced Tasks option under the Task menu.
See all active tasks and select the Gradle process that is being blocked.
Right click on the task and 'Add to Trusted Files'
I got this same error, except it said Gradle Worker 2. I restarted my command line (powershell) and then tried to build again with gradle and it worked. I had changed my environment variables to point to the Java version the project was expecting and had not thought to restart- not sure if that had anything to do with it.
None of the other answers here were helpful in my case.
What I had to do was disable the coroutine agent.
Open Settings (File - Settings)
Select Kotlin under Build... - Debugger - Data Views
Check the box "Disable coroutine agent"
Alternatively, go to your build.gradle file and upgrade the version used for the coroutines dependencies.

deploy java app on Heroku launch.main error

I want to deploy a java appa on HEROKU. I am new to maven. I made all set up as per in the deploy a sample app to heroku (java+maven+ tomcat7)documentation.
and i made a bulid,It was successfull. But as soon i typed sh /target/bin/weapps i am getting the following error. Can anybody help me to sort out this issue.
Exception in thread "main" java.lang.NoClassDefFoundError: launch/Main
Caused by: java.lang.ClassNotFoundException: launch.Main</br>
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: launch.Main. Program will exit.
regards,
arunbv
I had a similar problem, I (well, almost) solved it this way, just remove:
<packaging>war</packaging>
from pom.xml. I know this is not an ideal solution, but somehow the embedded tomcat plugin doesn't work with war packaging!
I don't have enough points to comment, but what article are you following? Can you link it?
Based on the error, I suspect your Main.java is not in src/main/java/launch. If you follow these instructions, I think you should be able to clear up the error:
http://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
If that's the article you're following and you're still having trouble, it may ease the problems you're having if you simply clone the sample repo:
git clone git://github.com/heroku/devcenter-embedded-tomcat.git
Since you said you are new to maven, I think the reason of this error is that you simply put your *.java code under the root folder of the project, while you are rather expected to put it under ./src/main/java/
This should work for you. I experienced the same problem and figured this out.
This is probably dead, but in case it helps people of the future.
I was getting up and running with a java app on Heroku, using an Ubuntu machine for development - and got this same Exception in thread "main" java.lang.NoClassDefFoundError.
Double check that you're using the same java compiler version as your java sdk version.
type java -version & javac -version. Make sure they are the same version.
If not, you can fix this by reconfiguring your environment to use the same for both.
Assuming you have downloaded and installed the java version you want to use, type :
`sudo update-alternatives --config java`
You'll get a nice menu with options
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/jdk1.7.0/bin/java 1
Select the version you wish to use. Done.
Now try to build.

Categories