Ignite event listener registration error - events

I am trying to implement a remote listener on Apache ignite, but for some reason the registration seems to be failing, use the following code.
IgniteMessaging message = ignite.message(ignite.cluster());
message.remoteListen("topic1", new IgniteBiPredicate<UUID, String>() {
#Override
public boolean apply(UUID e1, String e2) {
System.out.println("message received" + e2);
return true;
}
});
But I get the following error during registration.
Exception in thread "main" class org.apache.ignite.spi.IgniteSpiException: Failed to marshal custom event: StartRoutineDiscoveryMessage [startReqData=StartRequestData [prjPred=AlwaysTruePredicate [], clsName=null, depInfo=null, hnd=GridMessageListenHandler [pred=independent.messaging.Receiver$1#e24ddd0, clsName=null, depInfo=null, depEnabled=false], bufSize=1, interval=0, autoUnsubscribe=false], keepBinary=false, routineId=13f09f06-4ebe-4cc8-9671-54162472df15]
at org.apache.ignite.spi.discovery.tcp.ServerImpl.sendCustomEvent(ServerImpl.java:773)
at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.sendCustomEvent(TcpDiscoverySpi.java:453)
at org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.sendCustomEvent(GridDiscoveryManager.java:2090)
at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.startRoutine(GridContinuousProcessor.java:748)
at org.apache.ignite.internal.IgniteMessagingImpl.remoteListen(IgniteMessagingImpl.java:212)
at independent.messaging.Receiver.listenForMessages(Receiver.java:71)
at independent.messaging.Receiver.main(Receiver.java:55)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to serialize object: StartRoutineDiscoveryMessage [startReqData=StartRequestData [prjPred=AlwaysTruePredicate [], clsName=null, depInfo=null, hnd=GridMessageListenHandler [pred=independent.messaging.Receiver$1#e24ddd0, clsName=null, depInfo=null, depEnabled=false], bufSize=1, interval=0, autoUnsubscribe=false], keepBinary=false, routineId=13f09f06-4ebe-4cc8-9671-54162472df15]
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:85)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:70)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:99)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.marshal(AbstractNodeNameAwareMarshaller.java:58)
at org.apache.ignite.internal.util.IgniteUtils.marshal(IgniteUtils.java:9815)
at org.apache.ignite.spi.discovery.tcp.ServerImpl.sendCustomEvent(ServerImpl.java:769)
... 6 more
Caused by: java.io.NotSerializableException: independent.messaging.Receiver
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.ignite.internal.GridMessageListenHandler.writeExternal(GridMessageListenHandler.java:244)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.ignite.internal.processors.continuous.StartRequestData.writeExternal(StartRequestData.java:241)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.marshal0(JdkMarshaller.java:80)
... 11 more
What could be the possible reason for this error?

Your IgniteBiPredicate will be serialized and sent to the other nodes, so, in your case, as this class is anonymous, outer class will be serialized too.
I would recommend creating private static class for predicate with this implementation and creating instance of it as an argument for remoteListen method

Related

java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler

I dont know anymore what to do. I am sitting on this problem since 3 days.
I have an OSGi-Bundle and in this bundle I create an ExportOperation:
public void createExportOperation(IProject project, IPath buildLocation, IPath exportLocation) throws CoreException{
try {
FeatureExportInfo exportInfo = this.initExport(buildLocation, exportLocation, project);
exportInfo.qualifier = AdvancedFeatureExportOperation.getDateQualifier();
Job job = new AdvancedFeatureExportOperation(exportInfo, "Project Deployment");
job.setUser(true);
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.schedule();
} catch (Exception exception) {
exception.printStackTrace();
}
}
AdvancedFeatureExportOperation is only a wrapper and extends org.eclipse.pde.internal.core.exports.FeatureExportOperation
If I run my bundle within eclipse (OSGi HostConsole) it works. But if I start the bundle separate in OSGi only, I get after 10mins in one of the last steps of the export operation the following error in my logs:
!ENTRY org.eclipse.core.jobs 4 2 2022-09-22 20:24:07.425
!MESSAGE An internal error occurred during: "Project Deployment".
!STACK 0
java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:613)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:574)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:613)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:574)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.eclipse.pde.internal.build.site.BuildTimeFeatureFactory.parseBuildFeature(BuildTimeFeatureFactory.java:79)
at org.eclipse.pde.internal.build.site.BuildTimeFeatureFactory.createFeature(BuildTimeFeatureFactory.java:50)
at org.eclipse.pde.internal.build.site.BuildTimeSite.createFeature(BuildTimeSite.java:469)
at org.eclipse.pde.internal.build.site.compatibility.FeatureReference.getFeature(FeatureReference.java:39)
at org.eclipse.pde.internal.build.site.BuildTimeSite.resolveFeatureReferences(BuildTimeSite.java:327)
at org.eclipse.pde.internal.build.site.BuildTimeSite.findFeature(BuildTimeSite.java:296)
at org.eclipse.pde.internal.build.site.BuildTimeSite.findFeature(BuildTimeSite.java:288)
at org.eclipse.pde.internal.build.BuildScriptGenerator.generateFeatures(BuildScriptGenerator.java:252)
at org.eclipse.pde.internal.build.BuildScriptGenerator.generate(BuildScriptGenerator.java:127)
at org.eclipse.pde.internal.core.exports.FeatureExportOperation.doExport(FeatureExportOperation.java:256)
at org.eclipse.pde.internal.core.exports.FeatureExportOperation.doExport(FeatureExportOperation.java:223)
at org.eclipse.pde.internal.core.exports.FeatureExportOperation.run(FeatureExportOperation.java:107)
at com.iisy.solvatio.studio.deployment.wizards.AdvancedFeatureExportOperation.run(AdvancedFeatureExportOperation.java:24)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.helpers.DefaultHandler cannot be found by org.eclipse.equinox.p2.publisher.eclipse_1.1.200.v20130516-1953
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 45 more
I have installed exact the same bundles like they are installed in eclipse. Alle dependencies are fullfiled. I even downloaded extra org.everit.osgi.bundles.org.apache.xmlcommons.full-1.4.1-20150918.jar where org.xml.sax.helpers.DefaultHandler will be exported and in the manifest of my bundle I habe this one as Require-Bundle.
It dostn work but in eclipse I dont need extra bundles either. And because I was so desperate I even changed the manifest-file for the bunlde org.eclipse.equinox.p2.publisher.eclipse manually so org.everit.osgi.bundles.org.apache.xmlcommons.full will be listed as Require-Bundle.
But no chance, du you have any idea what is the problem or how I could track down the issue? Thank you very much for every help!
The solution was to add:
-Dorg.osgi.framework.system.packages.extra=javax.*,org.xml.sax,org.xml.sax.helpers -Dorg.osgi.framework.bootdelegation=javax.*,org.xml.sax,org.xml.sax.helpers
... for OSGi-Start in shell. In Eclipse it works because they are not so strickt.
I found the solution after reading: https://developer.ibm.com/articles/osgi-demystified-part-2-unraveling-java-and-osgi-class-loader-problems/

Is #OnWebSocketClose always gets called ? I am getting #onwebsocketerror and #onwebsocketclose is not getting called

Is #onwebsocketclose always gets called ? I am getting #onwebsocketerror and #onwebsocketclose is not getting called .
There might be some broken pipe connection .
StackTrace :
org.eclipse.jetty.io.EofException: null
at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:283) ~[application.jar:?]
at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:422) ~[application.jar:?]
at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:378) ~[application.jar:?]
at org.eclipse.jetty.io.ChannelEndPoint$3.run(ChannelEndPoint.java:132) ~[application.jar:?]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) ~[application.jar:?]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) ~[application.jar:?]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) ~[application.jar:?]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) ~[application.jar:?]
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) ~[application.jar:?]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) ~[application.jar:?]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) ~[application.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[?:1.8.0_111]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[?:1.8.0_111]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[?:1.8.0_111]
at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[?:1.8.0_111]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)~[?:1.8.0_111]
at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:261) ~[application.jar:?]
the Close method is called for WebSocket handshake completion or abnormal completion.
I/O errors, idle timeouts, harsh disconnects, and other errors are on the Error method.
Any event on onClose() or onError() signals the end of your session.
Exceptional closures (throwables) are racy on which of the 2 application event methods are called.
Some behaviors:
We try to notify onClose() only once.
We try to notify onError() only once.
If onClose() is called, onError() will not be called.
If onError() is called, onClose() will not be called.
If the closure is determined to be from an exception, then:
the exception is logged on DEBUG level
the application onError() is called (if not already called)
the close frame is queued (if not already sent or queued)
the on success or failure of close frame send, the connection is disconnected. (there is no wait for the remote close frame in this exceptional case)
Failures during handshake are ...
On a WebSocket Client the connect will fail with an exception (this could be reported as a failure when attempting to get the Session object from the connect future)
On a WebSocket Server the connect will not succeed, no WebSocket Session is created, no Endpoint is created, no onOpen() is called.

ItemViewModel: method code is too large

I have a database table with 270 columns I need to work with. I wrote some code generators to help me keep my sanity, but I have an issue with ItemViewModel class - it refuses to compile with 'Method code too large' exception.
The class is plain:
class F321PModel: ItemViewModel<F321P>() {
val id = bind(F321P::idProperty)
// 269 more lines below
I receive method too large exception even for 50 columns. Is bind introduces so huge overhead ? I don't think that 50 columns table is something extreme, maybe it is possible to optimize something ?
Here is problem classes https://gist.github.com/anonymous/d0978899ad569839797b025ad081bbf7
Error:Kotlin: [Internal Error] java.lang.RuntimeException: Error generating class file ru/abinet/blt/updateapplication/models/F321PModel.class (compiled from [C:\Users\hachatryan\IdeaProjects\updateapplication\src\main\kotlin\ru\abinet\blt\updateapplication\models\321PModel.kt]): Method code too large!
at org.jetbrains.kotlin.codegen.ClassFileFactory$OutputClassFile.asByteArray(ClassFileFactory.java:255)
at org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt.writeAll(outputUtils.kt:32)
at org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt.writeAll(outputUtils.kt:42)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.writeOutput(KotlinToJVMBytecodeCompiler.kt:98)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.access$writeOutput(KotlinToJVMBytecodeCompiler.kt:67)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$createOutputFilesFlushingCallbackIfPossible$1.invoke(KotlinToJVMBytecodeCompiler.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$createOutputFilesFlushingCallbackIfPossible$1.invoke(KotlinToJVMBytecodeCompiler.kt:67)
at org.jetbrains.kotlin.codegen.state.GenerationStateKt$GenerationStateEventCallback$1.invoke(GenerationState.kt:259)
at org.jetbrains.kotlin.codegen.state.GenerationStateKt$GenerationStateEventCallback$1.invoke(GenerationState.kt:258)
at org.jetbrains.kotlin.codegen.state.GenerationState.afterIndependentPart(GenerationState.kt:215)
at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:67)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.generatePackage(KotlinCodegenFacade.java:100)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:78)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:45)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:450)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:152)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:158)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:61)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:380)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:892)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:919)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:891)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:378)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: Method code too large!
at org.jetbrains.org.objectweb.asm.MethodWriter.getSize(MethodWriter.java:2036)
at org.jetbrains.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:850)
at org.jetbrains.kotlin.codegen.ClassBuilderFactories$2.asBytes(ClassBuilderFactories.java:126)
at org.jetbrains.kotlin.codegen.DelegatingClassBuilderFactory.asBytes(DelegatingClassBuilderFactory.kt:36)
at org.jetbrains.kotlin.codegen.DelegatingClassBuilderFactory.asBytes(DelegatingClassBuilderFactory.kt:36)
at org.jetbrains.kotlin.codegen.DelegatingClassBuilderFactory.asBytes(DelegatingClassBuilderFactory.kt:36)
at org.jetbrains.kotlin.codegen.ClassFileFactory$ClassBuilderAndSourceFileList.asBytes(ClassFileFactory.java:287)
at org.jetbrains.kotlin.codegen.ClassFileFactory$OutputClassFile.asByteArray(ClassFileFactory.java:252)
... 45 more
I've come across this same error with ~60 properties, I managed to get around it by wrapping each bind call in a lazy delegate:
val id: LongProperty by lazy<LongProperty> {
bind(F321P::idProperty)
}

Drools. cannot be cast to java.lang.Number

I have these declarations:
declare Event
#role(event)
#timestamp(time)
//#expires(100ms)
//params : Map<String, Object>
param : long
time : long
end
declare Expectation
event: Event
state: int //-1 pending, 0 violated, 1 fulfilled
end
declare ExpectationLeftArmStr extends Expectation
end
And in a rule I've written:
ExpectationLeftArmStr exp = new ExpectationLeftArmStr();
exp.setEvent($ev);
exp.setState(-1);//pending
insert(exp);
And $ev is a correct Event that I use into a rule.
The error is: rec.dom.LeftArmStr cannot be cast to java.lang.Number where LeftArmStr is $ev.
Exception in thread "main" Exception executing consequence for rule "Operazions on LeftArmStr event 33399" in rec.dom: java.lang.ClassCastException: rec.dom.LeftArmStr cannot be cast to java.lang.Number
at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at org.rec.Session.notify(Session.java:136)
at org.ece.reasoner.ReasonerECE.notifyEvent(ReasonerECE.java:73)
at org.ece.main.MainLaucher.main(MainLaucher.java:245)
Caused by: java.lang.ClassCastException: rec.dom.LeftArmStr cannot be cast to java.lang.Number
at org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedRight(BeforeEvaluatorDefinition.java:306)
at org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80)
at org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:134)
at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:156)
at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:192)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:186)
at rec.dom.Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05c.defaultConsequence(Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05c.java:19)
at rec.dom.Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05cDefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at rec.dom.Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05cDefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 8 more

H2 database throwing null pointer exception

I am new to H2 database, I ran into a particular problem where I was running a function named format.
public static String format(Double sumValue,Integer decimalValue){
if(sumValue==null)
return null;
else{
//format in particular order.
}
}
There are chances of sumValue getting null value.
when I am running a query it is throwing a following exception
SELECT format(commamount,2) as formatted FROM pshipcommdetail [90105-153]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.message.DbException.convertInvocation(DbException.java:295)
at org.h2.engine.FunctionAlias$JavaMethod.getValue(FunctionAlias.java:405)
at org.h2.expression.JavaFunction.getValue(JavaFunction.java:38)
at org.h2.expression.Alias.getValue(Alias.java:35)
at org.h2.command.dml.Select.queryFlat(Select.java:519)
at org.h2.command.dml.Select.queryWithoutCache(Select.java:614)
at org.h2.command.dml.Query.query(Query.java:269)
at org.h2.command.dml.Query.query(Query.java:239)
at org.h2.command.dml.Query.query(Query.java:37)
at org.h2.command.CommandContainer.query(CommandContainer.java:78)
at org.h2.command.Command.executeQuery(Command.java:181)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:278)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:137)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at reports.functions.Format.format(Format.java:15)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.h2.engine.FunctionAlias$JavaMethod.getValue(FunctionAlias.java:393)
I went through the documentation and was able to figure out that the aruguments should be of wrapper class hence I changed to double!
Can anyone of you please help me to figure out where the actual problem is?
Thanking you
With Regards
Phani Kumar
This question was answered on the H2 mailing list:
http://groups.google.com/group/h2-database/browse_thread/thread/a4105b923d79bf28#
It was a bug in Phani's code.

Resources