I'm trying to do a marshal dump and load in Scala...
import scala.util.Marshal
case class Test(test: String)
val t = Test("hello")
val bytes = Marshal.dump(t)
Marshal.load[Test](bytes)
...but the call to Marshal.load is throwing a ClassNotFoundException...
java.lang.ClassNotFoundException: Test
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1461)
at java.io.Ob...
I've also tried using the fully qualified class name but with no luck. What am I missing?
Which version of SBT are you using? I had similar problems with SBT 0.7.7 and resolved them by adding the following to my build:
// cause the SBT "run" action to fork
override def fork = Some(new ForkScalaRun() {
override def scalaJars = Seq(buildLibraryJar.asFile, buildCompilerJar.asFile)
})
Causing the "run" action to fork seems to resolve class loader problems, and problems with trapping System.exit calls:
http://code.google.com/p/simple-build-tool/wiki/Forking
http://code.google.com/p/simple-build-tool/wiki/RunningProjectCode
Related
I made a java agent with bytebuddy. It works well untill target application load classes form uRLConnection.getInputStream. The target app works well without attachment the agent, but shows exception [java.lang.ClassNotFoundException] when the agent attached.
this is app's classloading line.
return this.getClass().getClassLoader().loadClass(string) //string points the name of a byte array.
In the application, the classes is provided in the form of byte array from the uRLConnection.getInputStream at runtime and the application loads those at runtime.
The eclipst stacktrace:
[Byte Buddy] COMPLETE client [app.m#7dc3712, null, loaded=false]
Exception in thread "main" java.lang.NoClassDefFoundError: kh
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at app.m.loadClass(m.java:22)
at java.lang.ClassLoader.loadClass(Unknown Source)
at app.appletviewer.b(appletviewer.java:1176)
at app.appletviewer.a(appletviewer.java:454)
at Launcher.main(Launcher.java:43)
Caused by: java.lang.ClassNotFoundException: kh
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at app.u.loadClass(u.java:79)
at java.lang.ClassLoader.findSystemClass(Unknown Source)
at app.m.loadClass(m.java:30)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
My agent is:
try {
new AgentBuilder.Default()
.with(new AgentBuilder.InitializationStrategy.SelfInjection.Eager())
.with(AgentBuilder.Listener.StreamWriting.toSystemError())
.type((ElementMatchers.any()))
.transform((builder, typeDescription, classLoader, module) -> builder
.method(ElementMatchers.any())
.intercept(Advice.to(MyAdviser.class))
).installOn(instrumentation);
} catch (Exception e) {
return;
}
I also tried
.transform(new AgentBuilder.Transformer.ForAdvice()
.include(MyAdviser.class.getClassLoader())
.advice(ElementMatchers.any(), MyAdviser.class.getName()))
But it doesn't seem to be attached.
I think your problem might be something else here. Try the second form of advice which avoids class loading where a class loading of a system class in an too ealry stage is probably is your problem in the application of loaded advice. Set an .ignore(none()) matcher for the instrumentation to make the second approach work as boot strap classes like URLConnection are not by instrumented by Byte Buddy in the default configuration.
I am using Groovy 2.4 with openCSV in Java 9. When I try to run the program with in IDE its not finding the ResutlSet class file. But it works in Gradle task.
Any help to resolve this error message?
Gradle task
// https://mvnrepository.com/artifact/com.opencsv/opencsv
compile group: 'com.opencsv', name: 'opencsv', version: '4.0'
task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'mongo.UserReport'
}
Stack trace
Error:Groovyc: While compiling Tools_main: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Unable to load class com.opencsv.CSVWriter due to missing dependency java/sql/ResultSet
at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1101)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1079)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:115)
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.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:136)
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.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovycInThisProcess(InProcessGroovyc.java:158)
at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.lambda$runGroovyc$0(InProcessGroovyc.java:88)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.NoClassDefFoundError: Unable to load class com.opencsv.CSVWriter due to missing dependency java/sql/ResultSet
at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:397)
at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:280)
at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1009)
at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1004)
at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:998)
at org.codehaus.groovy.ast.ClassNode.isDerivedFrom(ClassNode.java:941)
at org.codehaus.groovy.classgen.asm.InvocationWriter.castToNonPrimitiveIfNecessary(InvocationWriter.java:863)
at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:345)
at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:282)
at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:344)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:664)
at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:613)
at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:366)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:651)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:85)
at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:159)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:597)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:461)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:414)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:538)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1081)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:260)
at org.codehaus.groovy.control.CompilationUnit$17.call(CompilationUnit.java:825)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
I have a cluster with 2 nodes. Then I tried to run the CacheJdbcStoreExample in apache-ignite-fabric-2.1.0-bin/examples.But I got following exception:
visor> [06:51:41,113][SEVERE][tcp-disco-msg-worker-#13%null%][TcpDiscoverySpi] Failed to unmarshal discovery custom message.
class org.apache.ignite.IgniteCheckedException: Failed to find class with given class loader for unmarshalling (make sure same versions of all classes are available on all nodes or enable pee
r-class-loading) [clsLdr=sun.misc.Launcher$AppClassLoader#4aa4ceeb, cls=org.apache.ignite.examples.datagrid.store.jdbc.CacheJdbcStoreExample$1] at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:124)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:94)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:143)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9733)
at org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage.message(TcpDiscoveryCustomEventMessage.java:81)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:5436)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processCustomMessage(ServerImpl.java:5321)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2629)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2420)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$MessageWorkerAdapter.body(ServerImpl.java:6576)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2506)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.lang.ClassNotFoundException: org.apache.ignite.examples.datagrid.store.jdbc.CacheJdbcStoreExample$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8465)
at org.apache.ignite.marshaller.jdk.JdkMarshallerObjectInputStream.resolveClass(JdkMarshallerObjectInputStream.java:54)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1817)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1711)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1982)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1917)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1527)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:420)
at java.util.ArrayList.readObject(ArrayList.java:771)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2118)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:420)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:121)
... 12 more
I decompiled CacheJdbcStoreExample$1.class and got following code:
CacheJdbcStoreExample$1
package org.apache.ignite.examples.datagrid.store.jdbc;
import javax.cache.configuration.Factory;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
import org.h2.jdbcx.JdbcConnectionPool;
class CacheJdbcStoreExample$1
implements Factory<CacheStoreSessionListener>
{
public CacheStoreSessionListener create()
{
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", ""));
return lsnr;
}
}
SO I think there is something wrong at row 90 in CacheJdbcStoreExample source code:
// Configure JDBC session listener.
cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
#Override public CacheStoreSessionListener create() {
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", ""));
return lsnr;
}
});
If I run the example on only one node not a cluster, it's OK.
What should I do to fix it?
The problem is that you configured a cache with a factory of CacheStoreSessionListener-s, but this factory is not visible from other nodes as they don't have it in their classpath.
You should start additional remote nodes with org.apache.ignite.examples.ExampleNodeStartup class from examples module or add examples module to the classpath of other nodes.
I’m working on a POC with Jacoco and gradle for GigaProject and am getting this error when it gets to jacoco during "test" task aka instrumenting test source code. Any ideas? Thanks.
java.lang.instrument.IllegalClassFormatException: Error while instrumenting class org/gradle/internal/service/UnknownServiceException.
at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:91)
at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.createLoggingManager(ImplementationClassLoaderWorker.java:85)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:53)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:37)
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.io.FileNotFoundException: build\jacoco\UT\classpathdumps\org\gradle\internal\service\UnknownServiceException.class (The requested oper
ation cannot be performed on a file with a user-mapped section open)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
at org.jacoco.agent.rt.internal_5d10cad.ClassFileDumper.dump(ClassFileDumper.java:66)
at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:83)
... 22 more
java.lang.instrument.IllegalClassFormatException: Error while instrumenting class org/gradle/logging/internal/DefaultStandardOutputRedirector$WriteAct
ion.
at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:91)
at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
at org.gradle.util.FilteringClassLoader.loadClass(FilteringClassLoader.java:60)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.gradle.util.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:52)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.gradle.logging.internal.DefaultStandardOutputRedirector.<init>(DefaultStandardOutputRedirector.java:30)
at org.gradle.api.internal.tasks.testing.junit.JULRedirector.<init>(JULRedirector.java:29)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestFramework$TestClassProcessorFactoryImpl.create(JUnitTestFramework.java:96)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.startReceivingTests(TestWorker.java:81)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:64)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:44)
at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:78)
at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:81)
at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:37)
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.io.FileNotFoundException: build\jacoco\UT\classpathdumps\org\gradle\logging\internal\DefaultStandardOutputRedirector$WriteAction.class
(The requested operation cannot be performed on a file with a user-mapped section open)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
at org.jacoco.agent.rt.internal_5d10cad.ClassFileDumper.dump(ClassFileDumper.java:66)
at org.jacoco.agent.rt.internal_5d10cad.CoverageTransformer.transform(CoverageTransformer.java:83)
... 34 more
OK, that was quick. I had the following test {... } section in Gradle build.gradle file and it was using classDumpPath setting (custom folder set at my end).
test {
maxParallelForks = 5
forkEvery = 50
ignoreFailures = true
testReportDir = file("$buildDir/reports/tests/UT")
testResultsDir = file("$buildDir/test-results/UT")
//Following Jacoco test section is required only in Jenkins instance extra common file
jacoco {
//The following vars works ONLY with 1.6 of Gradle
destPath = file("$buildDir/jacoco/UT/jacocoUT.exec")
classDumpPath = file("$buildDir/jacoco/UT/classpathdumps")
//Following vars works only with versions >= 1.7 version of Gradle
//destinationFile = file("$buildDir/jacoco/UT/jacocoUT.exec")
// classDumpFile = file("$buildDir/jacoco/UT/classpathdumps")
}
}
Commenting the following line, did the trick. I'll look into it later, why it solved the issue.
//--- classDumpPath = file("$buildDir/jacoco/UT/classpathdumps")
i had the same problem. what helped me was to change the JRE version.
changed it from 15 to 14.
I'm trying to store instance of some class in mule registry on flow application startup. Below you can see my java code and flow fragment. My problem is that sometimes application deployment fails with following error:
Caused by: java.lang.ClassCastException: com.company.test.sorter.model.Config cannot be cast to org.mule.construct.AbstractFlowConstruct
at org.mule.module.management.mbean.FlowConstructService.postRegister(FlowConstructService.java:139)
at org.mule.module.management.agent.ClassloaderSwitchingMBeanWrapper.postRegister(ClassloaderSwitchingMBeanWrapper.java:101)
You can find whole stacktrace below. I must repeat: this exception is raised only sometimes, approximately every fifth deployment of unchanged application. In most cases application runs perfectly fine. I googled for this exceptions and classes but I didn't find any solution. I am using Mule 3.2.1 (standalone). Is it a bug or am I doing something wrong?
#XmlRootElement(name = "config")
public class Config {
private String x2Regex;
private String x3Regex;
private String x2QueueName;
private String x3QueueName;
// constructors, getters and setters
}
public class Initializer implements
MuleContextNotificationListener<MuleContextNotification> {
#Override
public void onNotification(MuleContextNotification notification) {
if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED) {
try {
notification.getMuleContext().getRegistry().registerObject("config", new Config());
} catch (RegistrationException e) {
// cut
}
}
}
}
<notifications>
<notification event="CONTEXT"/>
<notification-listener ref="Initializer"/>
</notifications>
<spring:beans>
<spring:bean id="Initializer" name="Initializer" class="com.company.test.sorter.Initializer" doc:name="Bean"/>
</spring:beans>
Below is fragment of mule's log with exception:
+ Failed to deploy app 'number-sorter', see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.module.launcher.DeploymentException: Failed to deploy application [number-sorter]
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:68)
at org.mule.module.launcher.DeploymentService.start(DeploymentService.java:175)
at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mule.module.reboot.MuleContainerWrapper.start(MuleContainerWrapper.java:56)
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
Caused by: org.mule.api.MuleRuntimeException: MBeans Failed to initialise
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:707)
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:685)
at org.mule.context.notification.Sender.dispatch(Sender.java:40)
at org.mule.context.notification.Policy.dispatch(Policy.java:122)
at org.mule.context.notification.ServerNotificationManager.notifyListeners(ServerNotificationManager.java:244)
at org.mule.context.notification.ServerNotificationManager.fireNotification(ServerNotificationManager.java:197)
at org.mule.DefaultMuleContext.fireNotification(DefaultMuleContext.java:404)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:226)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:146)
at org.mule.module.launcher.application.ApplicationWrapper.start(ApplicationWrapper.java:107)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:52)
... 8 more
Caused by: javax.management.RuntimeMBeanException: RuntimeException thrown in postRegister method
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.postRegisterInvoke(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source)
at org.mule.module.management.agent.JmxAgent.registerFlowConstructServices(JmxAgent.java:428)
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:700)
... 18 more
Caused by: java.lang.ClassCastException: com.company.test.sorter.model.Config cannot be cast to org.mule.construct.AbstractFlowConstruct
at org.mule.module.management.mbean.FlowConstructService.postRegister(FlowConstructService.java:139)
at org.mule.module.management.agent.ClassloaderSwitchingMBeanWrapper.postRegister(ClassloaderSwitchingMBeanWrapper.java:101)
... 25 more
Feels like a bug: after reading the source code, I find no reasonable explanation to why Mule would try to register your custom object in JMX while mistaking it for a Flow!
As a side note, why using a notification listener and the Mule registry when you can just build your object with Spring?