Akka-ZMQ subscriber creation error (poll) - akka

I successfully created publisher but failed to create subscriber by using the following:
public static void main(String [] args)
{
ActorSystem system = ActorSystem.create("System");
ActorRef subscriber = system.actorOf(new Props(Sub.class), "subscriber");
subscriber.tell(new MyActor("CharlieParker", 50, 25), subscriber);
}
public class Sub extends UntypedActor
{
ActorRef subSocket = ZeroMQExtension.get(getContext().system()).newSubSocket(
new Connect("tcp://127.0.0.1:1237"),
new Listener(getSelf()), Subscribe.all());
}
Got this error:
Uncaught error from thread [System-akka.zeromq.socket-dispatcher-7] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[System]
java.lang.NoSuchMethodError: org.zeromq.ZMQ$Poller.poll(J)J
at akka.zeromq.ConcurrentSocketActor$$anonfun$10.apply(ConcurrentSocketActor.scala:180)
at akka.zeromq.ConcurrentSocketActor$$anonfun$10.apply(ConcurrentSocketActor.scala:179)
at akka.zeromq.ConcurrentSocketActor.akka$zeromq$ConcurrentSocketActor$$doPoll(ConcurrentSocketActor.scala:197)
at akka.zeromq.ConcurrentSocketActor$$anonfun$receive$1.applyOrElse(ConcurrentSocketActor.scala:46)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
at akka.actor.ActorCell.invoke(ActorCell.scala:386)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
at akka.dispatch.Mailbox.run(Mailbox.scala:212)
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)
What does it mean?

I had the same type of error while trying to work with akka-zeromq and did some investigation on the subject. So the situation is the following: the error message states that it didn't find a method long poll(long timeout) in the class ZMQ.Poller (see this answer for the error message interpretation). This happens because of the following reasons
Akka is built with zeromq-scala bindings.
zeromq-scala is supposed to be compatible with jzmq , but unfortunately it's not at the moment because in scala bindings you have method long poll(long timeout) while in jzmq you have int poll(long timeout)
To overcome your problem locally you either have to rebuild Akka with zmq.jar, or use a quick and dirty workaround: change the return type for the method poll(long timeout) in jzmq ZMQ.Poller class and rebuild the java bindings. For more details and bindings compatibility discussion take a look here
However there is a global java/scala bindings compatibility problem, but it's outside of the scope of your question.

it seems like you are either missing or having the wrong version of zeromq-scala-binding on your path.
Which version of akka and zeromq are you using?

Related

Error when run command (start IOUFlow iouValue: 99, otherParty: "O=PartyB,L=New York,C=US") in (hello world 1)

i have followed all the steps in hello world 1
https://docs.corda.net/hello-world-template.html
https://github.com/corda/cordapp-template-kotlin
but when run this command
i have faced this error:
[ERROR] 20:14:21+0200 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=ue63ey, moreInformationAt=https://errors.corda.net/OS/4.0/ue63ey] {actor_id=internalShell, actor_owning_identity=O=PartyA, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ef20094f-ecea-4004-b6dc-e687f88fdce9, invocation_id=c783d17e-1a70-4ec9-93ca-cb08714afac7, invocation_timestamp=2019-03-12T18:14:18.869Z, origin=internalShell, session_id=e7787152-785d-47fc-a5a6-e8893a730942, session_timestamp=2019-03-12T18:14:02.935Z, thread-id=221, tx_id=E38133ECBB005885B0DFD501A214C928AB67C34188C7B0F0BD659825487A27AF}
I can't understand the meaning of the error
how can solve this error ?
It got resolved by adding #BelongsToContract annotation on IOUState class. Thanks to gerferra for helping :)
#BelongsToContract(TemplateContract.class)
public class IOUState implements ContractState {
...
}
This error means the real exception can be found in the node logs.
We will probably adjust this in a future release so all exceptions are sent back to the RPC client instead of just some of them.
I'm having the same problem. The node logs report:
net.corda.core.contracts.TransactionVerificationException$TransactionRequiredContractUnspecifiedException:
State of class com.template.IOUState does not have a specified owning
contract. Add the #BelongsToContract annotation to this class to
ensure that it can only be bundled in a TransactionState with the
correct contract.
Adding the annotation to the IOUState class solved the problem.
[Thread-19 (ActiveMQ-client-global-threads)] custom.ThrowableSerializer.fromProxy - Unexpected exception de-serializing throwable: net.corda.core.contracts.TransactionVerificationException$TransactionRequiredContractUnspecifiedException. Converting to CordaRuntimeException. [errorCode=39z9vh, moreInformationAt=https://errors.corda.net/OS/4.0/39z9vh]
java.lang.reflect.InvocationTargetException: null
|
|
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method net.corda.core.contracts.TransactionVerificationException$TransactionRequiredContractUnspecifiedException., parameter state
at net.corda.core.contracts.TransactionVerificationException$TransactionRequiredContractUnspecifiedException.(TransactionVerificationException.kt) ~[corda-core-4.0.jar:?]

Equinox Jetty: ClassNotFound when trying use JDBCSessionManager

I am getting a ClassNotFoundException from Jetty (Equninox embedded) when trying to use JDBCSessionManager and JDBCSessionIdManager.
Exception:
2017-01-06 10:37:02.620:WARN:oejss.JDBCSessionManager:qtp1215746443-29: Unable to load session 192168178229yf02ln7ut25phh97b49003w
java.lang.ClassNotFoundException: org.eclipse.equinox.http.servlet.internal.servlet.HttpSessionAdaptor$ParentSessionListener cannot be found by org.eclipse.jetty.util_9.3.9.v20160517
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:628)
at org.eclipse.jetty.util.ClassLoadingObjectInputStream.resolveClass(ClassLoadingObjectInputStream.java:59)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
at java.util.HashMap.readObject(HashMap.java:1404)
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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1909)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1808)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
at org.eclipse.jetty.server.session.JDBCSessionManager$1.run(JDBCSessionManager.java:970)
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1262)
at org.eclipse.jetty.server.session.JDBCSessionManager.loadSession(JDBCSessionManager.java:992)
at org.eclipse.jetty.server.session.JDBCSessionManager.getSession(JDBCSessionManager.java:502)
at org.eclipse.jetty.server.session.JDBCSessionManager.getSession(JDBCSessionManager.java:75)
at org.eclipse.jetty.server.session.AbstractSessionManager.getHttpSession(AbstractSessionManager.java:331)
at org.eclipse.jetty.server.session.SessionHandler.checkRequestedSessionId(SessionHandler.java:275)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:151)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1106)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:524)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
I am using a JettyCustomizer to hook into the Jetty startup to change the default HashSessionManager with the JDBCSessionManager. The JettyCustomizer is located in a Fragment Bundle which belongs to
Fragment-Host: org.eclipse.equinox.http.jetty
I got this idea from https://wiki.eclipse.org/RAP/FAQ#How_can_I_use_Jetty_basic_authentication_in_my_application.3F
This setup works ok, and JDBCSessionManager places a session in the Database. The session is Serialized to a Byte-BLOB and stored in the DB. I can see it there.
But it seems the serialization is done by org.equinox.http and it places class reference like org.eclipse.equinox.http.servlet.internal.servlet.HttpSessionAdaptor$ParentSessionListener into the BLOB.
Note, that internal.servlet.HttpSessionAdaptor is an internal class which is not exported to other bundles.
Now when the session information is read again from the database (e.g. when I access the webpage again later with the same sessionCookie) I run into this problem when org.eclipse.jetty.util.ClassLoadingObjectInputStream.resolveClass(ClassLoadingObjectInputStream.java:59) tries to load the classHttpSessionAdaptor$ParentSessionListener but cannot see it (because it is a) internal and / or b) in another bundle.
org.eclipse.jetty.util.ClassLoadingObjectInputStream lives in bundle org.eclipse.jetty.util but org.eclipse.equinox.http.servlet.internal.servlet.HttpSessionAdaptor$ParentSessionListener lives in bundle org.eclipse.equinox.http.servlet.
org.eclipse.jetty.util.ClassLoadingObjectInputStream seems to do the following:
#Override
public Class<?> resolveClass (java.io.ObjectStreamClass cl) throws IOException, ClassNotFoundException
{
try
{
return Class.forName(cl.getName(), false, Thread.currentThread().getContextClassLoader());
}
catch (ClassNotFoundException e)
{
return super.resolveClass(cl);
}
}
Is there anybody from the OSGI experts with an ideas?
I would describe the problem as that Session byte-BLOB contains Class References to internal classes which cannot be seen by org.eclipse.jetty.util.ClassLoadingObjectInputStream.resolveClass
Does that seem like a bug? Or is the approach with the FragmentBundle with the the wrong approach? (IMO it is the only way I found to exchange the SessionManager)
The issue is probably because ClassLoadingObjectInputStream is using the TCCL for class resolution, which - in Equinox - by default is the org.eclipse.osgi.internal.framework.ContextFinder. It is finding the first bundle on the call stack. This is likely the Jetty bundle, which does not see any of the Equinox classes.
As far as the Equinox HTTP Service is concerned, the fragment approach is the right one for hooking into Jetty. If I'm reading the code path right, you could try the following things.
(1) Set class loader on ContextHandler
In your JettyCustomizer.customizeContext you should inspect the context. It should be a ServletContextHandler. Use its setClassLoader method to give it a class loader that knows about the Equinox classes (which any fragment of org.eclipse.equinox.http.jetty should know anyway) and any other classes of your own custom code.
(2) Fork/patch JDBCSessionManager
If approach 1 does not work then you likely need to create your own fork of JDBCSessionManager. Extending might not work because of visibility issues (some methods are private). You need to override/patch/reimplement the JDBCSessionManager.loadSession method to use the correct class loader for loading. In the original implementation you can see why approach 1 should work (in theory). The code of your implementation can be much simpler, though.
If your fragment also imports the packages of your code, then simple use your fragment class loader. Otherwise you can create a custom one that delegates to the correct bundles for resolution.

Usage of send and receive task in camunda BPMN

I am using a send task to which the following Javadelegate class is attached.
public class SendTaskDelegate implements JavaDelegate {
public void execute(DelegateExecution execution) throws Exception {
execution.getProcessEngineServices()
.getRuntimeService()
.createMessageCorrelation("someMessage")
.processInstanceBusinessKey("someBusinessKey")
.correlate();
}
}
But I am getting this error::
An error happend while submitting the task form : Cannot submit task form c0e85bad-719f-11e5-94aa-d897baecf24a: Cannot correlate message someMessage: No process definition or execution matches the parameters
How can I debug it?
The error message says, that your JavaDelegate code just gets excuted correctly. The process engine tries to find a running process instance with 'someBusinessKey' as business key and currently waiting for a message 'someMessage', but does not find such an instance. Your code acts as if there were such an instance and you try to find it and tell it about a message. See the docs section about correlation methods - in principle the mechanism is used to 'route' a message to the correct instance targeting it.
As a sidenote: your JavaDelegate seems to get called in the same transaction with which you also try to complete a task. The "borders of transactions" in your process can be managed with 'async' attributes described in the docs section about transactions in processes.

IBMIOTF/BlueMix Publish Command Syntax

I am attempting to assemble a small proof of concept system on IBM's Bluemix/Internet of Things. Currently this comprises of a Raspberry Pi feeding events up to the cloudbased app, which currently stores those events away, and periodically attempts to send down a command, using the following code block:
def sendCmd(command, payload, device="raspberrypi" ):
deviceId = #Fixed value
global cmdCount
client.publishCommand("raspberrypi", deviceId, str(command), "json", payload)
print "Sending '%s' cmd, payload '%s' to device %s" % (command, payload, deviceId)
cmdCount = cmdCount + 1
As far as the documentation is concerned this appears to be the correct syntax, as described by the documentation :
client.connect()
commandData={'rebootDelay' : 50}
client.publishCommand(myDeviceType, myDeviceId, "reboot", "json", myData)
No exceptions are thrown in this block of code, however the device is not receiving any commands; and the cloud foundry log is not throwing any errors. Is there a subtle point about the syntax I am missing?
This issue boiled down to having instantiated the wrong class on the Raspberry Pi. I had an instance of ibmiotf.application which registered a function to the variable self.client.commandCallback. However nothing appeared to be triggering the callback.
Once I instantiated the device with the ibmiotf.device import rather than ibmiotf.application, the command callback started to be called. This required a couple of the minor changes, to support slightly different function calls, but they were fairly self explanatory when trying to run the code.
The Device Class controls Events being published from the unit, and determines how to handle commands from upstream. Whereas the Application Class handles the receipt of Events and emission of Commands.

Operation is not valid due to the current state of the object with Full Trust Proxy

I have an event receiver accessing a SharePoint proxy operation via the following code:
var output = SPUtility.ExecuteRegisteredProxyOperation(Common.SQLOperationAssemblyName, Common.SQLOperationTypeName, args);
Every time it's hit I get the following error:
Operation is not valid due to the current state of the object.; StackTrace: at Microsoft.SharePoint.Utilities.SPUtility.ExecuteRegisteredProxyOperation(String assemblyName, String typeName, SPProxyOperationArgs args) at Segal.Extranet.Receivers.UsersReceiver.UsersReceiver.ItemAdding(SPItemEventProperties properties) c85ec89c-668d-3009-92f8-722ef549ab79
Any help would be appreciated
I figured this out the next morning. The event receiver which was accessing the proxy operation needed to be installed as a sandboxed solution. It was being installed through powershell was a farm solution.
Hope this helps anyone who comes across this!