You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Andreas Vogler <an...@me.com.INVALID> on 2021/03/03 17:00:39 UTC

OPC UA Subscribe throws casting error ...

Hi,

I have tried to subscribe to an OPC UA node - just took the few lines from the subscription example - and I get following stack trace. 

I hope someone can tell me what I am doing wrong… :-) 

val builder: PlcSubscriptionRequest.Builder = plc!!.subscriptionRequestBuilder()
topics.forEach {
    builder.addChangeOfStateField(it.payload, it.payload)
}
val request = builder.build()
val response = request.execute()
val subscribeResponse = response.get() ==> the exception is thrown here

[2021-03-03 17:52:26][INFO   ][opc                           ] Subscribe nodes [1] 
java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
	at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
	at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
	at at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
	at at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
	at at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
	at io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
	at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
	at io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
	at io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
	at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
	at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
	at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
	at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
	at at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
	at at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
	at at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
	at io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
	at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
	at io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
	at io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
	at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
	at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)




Re: OPC UA Subscribe throws casting error ...

Posted by Andreas Vogler <an...@me.com.INVALID>.
Hi Ben,

Thanks! 

My project is very young… a lot of things what I want to add… e.g. SQL (Calcite?), CrateDB, IotDB, Kafka, DDS, Redundancy … don’t know where to begin :-) and to less time… and there are still missing MQTT features: QoS, TLS, Auth, ...

ad Sparkplug, right, looks promising (will Sparkplug be there in future?)…  but it seems not to be that easy… and I am a fan of „keep it simple“…

ad IoTDB - I will take a look at it, always interested in databases… how does it compare to e.g. InfluxDB or CrateDB? 

ad Cluster: VertX is pretty cool and it is easy to form a cluster …and it is pretty performant: https://www.linkedin.com/posts/andreas-vogler-361115122_graphql-mqtt-vertx-activity-6769029730797719552-ZkjG <https://www.linkedin.com/posts/andreas-vogler-361115122_graphql-mqtt-vertx-activity-6769029730797719552-ZkjG>

Regarding polling: does not matter, I already have implemented a quick polling with old/new comparison by myself (for the gateway)

regards,
Andreas




> Am 06.03.2021 um 12:57 schrieb Ben Hutcheson <be...@gmail.com>:
> 
> Looking into it further,
> 
> A default duration/samplinginterval of 1 second gets generated when using
> the change of state api. This is interpreted as a minimum sampling interval
> by milo/opcua. If the source changes quicker than this then it will default
> to this sampling interval, if it doesn't then it does report by exception
> as expected. It would be good to add a minimum sampling interval to the
> api, we can bring it up in a separate thread for discussion.
> 
> /**
> * Adds a new field to the to be constructed request which should be
> updated as soon as
> * a value changes in the PLC.
> *
> * @param name       alias of the field.
> * @param fieldQuery field query string for accessing the field.
> * @return builder.
> */
> PlcSubscriptionRequest.Builder addChangeOfStateField(String name,
> String fieldQuery);
> 
> There's a reference in the getting started example on the website to the
> cyclic subscription it wouldn't however report by exception.
> 
> builder.addCyclicField("value-2", "{some address}", Duration.ofMillis(1000));
> 
> I'm not too sure about having support for subscriptions for protocols that
> don't support it in PLC4X (I think it's possible but the one
> non-subscription protocol I've worked on, Modbus, doesn't have a
> subscription interface). Others might though.
> 
> Bit disappointed not seeing iotdb or sparkplug in your gateway but other
> than that biased criticism it looks very cool. I especially like how you
> are aiming to be able to form a cluster of nodes. There has been the
> occassional talk about PLC4X supporting MQTT but I don't think anyone has
> put thier hand up yet.
> 
> Kind regards
> 
> Ben
> 
> On Fri, Mar 5, 2021 at 8:11 AM Andreas Vogler <an...@me.com.invalid>
> wrote:
> 
>> Thank you Ben, for me it is not super important. For OPC UA I use Eclipse
>> Milo “native” (without PLC4X)… I just wanted to test subscriptions with
>> PLC4X.
>> 
>> Is there a documentation of this sampling subscription api? I assume I can
>> use that kind of subscription also with drivers which does not support
>> subscriptions? I already thought about to implement a polling with old/new
>> compare in my gateway (https://github.com/vogler75/opcua-gateway <
>> https://github.com/vogler75/opcua-gateway>) to have some kind of
>> subscription option for Milo-Drivers which do not support subscriptions …
>> but if PLC4X can already do that for me… would be nice.
>> 
>> Best regards,
>> Andreas
>> 
>> 
>> 
>> 
>> 
>>> On 05.03.2021, at 13:51, Ben Hutcheson <be...@gmail.com> wrote:
>>> 
>>> Hi Andreas,
>>> 
>>> It looks like there's a bit of a mismatch between the PLC4X change of
>> state
>>> api and the Milo subscription api. When using the change of state
>>> subscription that is used in the example a default duration gets used of
>> 1
>>> second it also doesn't look like it reports by exception which I would
>>> expect.
>>> 
>>> Using the sampling subscription PLC4X api you could specify the sampling
>>> interval. I can take a look tomorrow if no one looks at it today.
>>> 
>>> Kind Regards
>>> 
>>> Ben
>>> 
>>> On Fri, Mar 5, 2021 at 7:32 AM Andreas Vogler
>> <an...@me.com.invalid>
>>> wrote:
>>> 
>>>> Thx, it works now.
>>>> 
>>>> BUT: I only get values every one second…
>>>> 
>>>> 13:21:54.177 [milo-shared-thread-pool-0] INFO
>>>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>>>> {"value":2.0,"isNullable":false}
>>>> 13:21:55.178 [milo-shared-thread-pool-0] INFO
>>>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>>>> {"value":7.0,"isNullable":false}
>>>> 13:21:56.178 [milo-shared-thread-pool-0] INFO
>>>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>>>> {"value":12.0,"isNullable":false}
>>>> 13:21:57.179 [milo-shared-thread-pool-0] INFO
>>>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>>>> {"value":17.0,"isNullable":false}
>>>> 13:21:58.179 [milo-shared-thread-pool-1] INFO
>>>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>>>> {"value":22.0,"isNullable":false}
>>>> 
>>>> The tag increases one by one every 200ms, and here in PLC4X we miss
>> value
>>>> changes..
>>>> 
>>>> Is there a way to adjust the opc ua subscription sampling interval
>> and/or
>>>> monitoring options with PLC4X?
>>>> 
>>>> Regards,
>>>> Andreas
>>>> 
>>>> 
>>>> 
>>>>> On 05.03.2021, at 12:42, Ben Hutcheson <be...@gmail.com> wrote:
>>>>> 
>>>>> Hi Andreas,
>>>>> 
>>>>> That looks like an issue specific to your setup. It seems it's not
>>>> finding
>>>>> some of the other modules that the opcua driver and the example rely
>> on.
>>>>> Can you build the entire project 'mvn clean && mvn install'?
>>>>> 
>>>>> If you could send through some more info, maven logs, etc.. it would be
>>>>> helpful.
>>>>> 
>>>>> Kind Regards
>>>>> 
>>>>> Ben
>>>>> 
>>>>> 
>>>>> On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler
>>>> <an...@me.com.invalid>
>>>>> wrote:
>>>>> 
>>>>>> Hi Ben,
>>>>>> 
>>>>>> with this Branch I get a build error - just opened it in Intellij and
>>>>>> tried to run the subscribe example...
>>>>>> 
>>>>>> 
>>>> 
>> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
>>>>>> java: package org.apache.plc4x.java.ads.readwrite does not exist
>>>>>> 
>>>>>> I see in e.g. OpcuaField.java: Cannot resolve symbol
>>>> 'OpcuaIdentifierType'
>>>>>> 
>>>>>> Regards,
>>>>>> Andreas
>>>>>> 
>>>>>>> On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
>>>>>>> 
>>>>>>> Hi Andreas,
>>>>>>> 
>>>>>>> I also saw the same issue running the example. I have just pushed a
>>>>>> branch
>>>>>>> to fix this bug/opcua_subscription. If you can try it out that would
>> be
>>>>>>> great.
>>>>>>> 
>>>>>>> Kind Regards
>>>>>>> 
>>>>>>> Ben
>>>>>>> 
>>>>>>> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
>>>>>> <an...@me.com.invalid>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> Hi Matthias,
>>>>>>>> 
>>>>>>>> It’s
>>>>>>>> * Java 11.0.9 (Amazon Corretto)
>>>>>>>> * Intellij 2020.3.2
>>>>>>>> * git clone https://github.com/apache/plc4x.git <
>>>>>>>> https://github.com/apache/plc4x.git>
>>>>>>>> 
>>>>>>>> The attached stack trace was from my project - Kotlin - maybe “app”
>>>>>> comes
>>>>>>>> from there.
>>>>>>>> But you can just use the subscription example from the plc4x.git, it
>>>>>>>> throws the same error.
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> Andreas
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
>>>>>>>> matthias.strljic@gmail.com> wrote:
>>>>>>>>> 
>>>>>>>>> Hi Andreas,
>>>>>>>>> 
>>>>>>>>> can you give us a bit more information about your scenario and
>> setup?
>>>>>>>>> Project config, java version, java jvm, IDE environment, PLC4X
>>>> version
>>>>>> /
>>>>>>>>> Github branch?
>>>>>>>>> Because the " are in unnamed module of loader 'app'" confuses me a
>>>> bit.
>>>>>>>>> 
>>>>>>>>> Greetings Matthias
>>>>>>>>> 
>>>>>>>>> ------------------------------
>>>>>>>>>> *Von:* Christofer Dutz <ch...@c-ware.de>
>>>>>>>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
>>>>>>>>>> *An:* dev@plc4x.apache.org
>>>>>>>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>>>>>>>>>> 
>>>>>>>>>> Hi,
>>>>>>>>>> 
>>>>>>>>>> perhaps Matthias can help you with this one?
>>>>>>>>>> 
>>>>>>>>>> Chris
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> -----Ursprüngliche Nachricht-----
>>>>>>>>>> Von: Andreas Vogler <an...@me.com.INVALID>
>>>>>>>>>> Gesendet: Mittwoch, 3. März 2021 20:22
>>>>>>>>>> An: dev@plc4x.apache.org
>>>>>>>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
>>>>>>>>>> 
>>>>>>>>>> Same happens with the plc4j hello-world-plc4x-subscription example
>>>>>> from
>>>>>>>>>> the GitHub repository.
>>>>>>>>>> 
>>>>>>>>>>> On 03.03.2021, at 18:00, Andreas Vogler
>>>>>> <andreas.vogler@me.com.INVALID
>>>>>>>>> 
>>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> Hi,
>>>>>>>>>>> 
>>>>>>>>>>> I have tried to subscribe to an OPC UA node - just took the few
>>>> lines
>>>>>>>>>> from the subscription example - and I get following stack trace.
>>>>>>>>>>> 
>>>>>>>>>>> I hope someone can tell me what I am doing wrong… :-)
>>>>>>>>>>> 
>>>>>>>>>>> val builder: PlcSubscriptionRequest.Builder =
>>>>>>>>>>> plc!!.subscriptionRequestBuilder()
>>>>>>>>>>> topics.forEach {
>>>>>>>>>>> builder.addChangeOfStateField(it.payload, it.payload) } val
>> request
>>>>>>>>>>> = builder.build() val response = request.execute() val
>>>>>>>>>>> subscribeResponse = response.get() ==> the exception is thrown
>> here
>>>>>>>>>>> 
>>>>>>>>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
>>>>>>>> Subscribe
>>>>>>>>>> nodes [1]
>>>>>>>>>>> java.util.concurrent.ExecutionException:
>>>>>> java.lang.ClassCastException:
>>>>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>>>>>> cannot be
>>>>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>>>> module
>>>>>> of
>>>>>>>>>> loader 'app')
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>>>>>   at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>>>>>   at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>>>>>   at
>>>>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>>>>>   at
>> io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>>>>>   at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
>>>> be
>>>>>>>> cast
>>>>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>>>> module
>>>>>> of
>>>>>>>>>> loader 'app')
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>>>>>   at
>>>>>>>>>>> 
>>>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>>>>>> Thread.java:183)
>>>>>>>>>>> java.util.concurrent.ExecutionException:
>>>>>> java.lang.ClassCastException:
>>>>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>>>>>> cannot be
>>>>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>>>> module
>>>>>> of
>>>>>>>>>> loader 'app')
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>>>>>   at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>>>>>   at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>>>>>   at
>>>>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>>>>>   at
>> io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>>>>>   at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
>>>> be
>>>>>>>> cast
>>>>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>>>> module
>>>>>> of
>>>>>>>>>> loader 'app')
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>>>>>   at
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>>>>>   at
>>>>>>>>>>> 
>>>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>>>>>> Thread.java:183)
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: OPC UA Subscribe throws casting error ...

Posted by Ben Hutcheson <be...@gmail.com>.
Looking into it further,

A default duration/samplinginterval of 1 second gets generated when using
the change of state api. This is interpreted as a minimum sampling interval
by milo/opcua. If the source changes quicker than this then it will default
to this sampling interval, if it doesn't then it does report by exception
as expected. It would be good to add a minimum sampling interval to the
api, we can bring it up in a separate thread for discussion.

/**
 * Adds a new field to the to be constructed request which should be
updated as soon as
 * a value changes in the PLC.
 *
 * @param name       alias of the field.
 * @param fieldQuery field query string for accessing the field.
 * @return builder.
 */
PlcSubscriptionRequest.Builder addChangeOfStateField(String name,
String fieldQuery);

There's a reference in the getting started example on the website to the
cyclic subscription it wouldn't however report by exception.

builder.addCyclicField("value-2", "{some address}", Duration.ofMillis(1000));

I'm not too sure about having support for subscriptions for protocols that
don't support it in PLC4X (I think it's possible but the one
non-subscription protocol I've worked on, Modbus, doesn't have a
subscription interface). Others might though.

Bit disappointed not seeing iotdb or sparkplug in your gateway but other
than that biased criticism it looks very cool. I especially like how you
are aiming to be able to form a cluster of nodes. There has been the
occassional talk about PLC4X supporting MQTT but I don't think anyone has
put thier hand up yet.

Kind regards

Ben

On Fri, Mar 5, 2021 at 8:11 AM Andreas Vogler <an...@me.com.invalid>
wrote:

> Thank you Ben, for me it is not super important. For OPC UA I use Eclipse
> Milo “native” (without PLC4X)… I just wanted to test subscriptions with
> PLC4X.
>
> Is there a documentation of this sampling subscription api? I assume I can
> use that kind of subscription also with drivers which does not support
> subscriptions? I already thought about to implement a polling with old/new
> compare in my gateway (https://github.com/vogler75/opcua-gateway <
> https://github.com/vogler75/opcua-gateway>) to have some kind of
> subscription option for Milo-Drivers which do not support subscriptions …
> but if PLC4X can already do that for me… would be nice.
>
> Best regards,
> Andreas
>
>
>
>
>
> > On 05.03.2021, at 13:51, Ben Hutcheson <be...@gmail.com> wrote:
> >
> > Hi Andreas,
> >
> > It looks like there's a bit of a mismatch between the PLC4X change of
> state
> > api and the Milo subscription api. When using the change of state
> > subscription that is used in the example a default duration gets used of
> 1
> > second it also doesn't look like it reports by exception which I would
> > expect.
> >
> > Using the sampling subscription PLC4X api you could specify the sampling
> > interval. I can take a look tomorrow if no one looks at it today.
> >
> > Kind Regards
> >
> > Ben
> >
> > On Fri, Mar 5, 2021 at 7:32 AM Andreas Vogler
> <an...@me.com.invalid>
> > wrote:
> >
> >> Thx, it works now.
> >>
> >> BUT: I only get values every one second…
> >>
> >> 13:21:54.177 [milo-shared-thread-pool-0] INFO
> >> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> >> {"value":2.0,"isNullable":false}
> >> 13:21:55.178 [milo-shared-thread-pool-0] INFO
> >> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> >> {"value":7.0,"isNullable":false}
> >> 13:21:56.178 [milo-shared-thread-pool-0] INFO
> >> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> >> {"value":12.0,"isNullable":false}
> >> 13:21:57.179 [milo-shared-thread-pool-0] INFO
> >> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> >> {"value":17.0,"isNullable":false}
> >> 13:21:58.179 [milo-shared-thread-pool-1] INFO
> >> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> >> {"value":22.0,"isNullable":false}
> >>
> >> The tag increases one by one every 200ms, and here in PLC4X we miss
> value
> >> changes..
> >>
> >> Is there a way to adjust the opc ua subscription sampling interval
> and/or
> >> monitoring options with PLC4X?
> >>
> >> Regards,
> >> Andreas
> >>
> >>
> >>
> >>> On 05.03.2021, at 12:42, Ben Hutcheson <be...@gmail.com> wrote:
> >>>
> >>> Hi Andreas,
> >>>
> >>> That looks like an issue specific to your setup. It seems it's not
> >> finding
> >>> some of the other modules that the opcua driver and the example rely
> on.
> >>> Can you build the entire project 'mvn clean && mvn install'?
> >>>
> >>> If you could send through some more info, maven logs, etc.. it would be
> >>> helpful.
> >>>
> >>> Kind Regards
> >>>
> >>> Ben
> >>>
> >>>
> >>> On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler
> >> <an...@me.com.invalid>
> >>> wrote:
> >>>
> >>>> Hi Ben,
> >>>>
> >>>> with this Branch I get a build error - just opened it in Intellij and
> >>>> tried to run the subscribe example...
> >>>>
> >>>>
> >>
> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
> >>>> java: package org.apache.plc4x.java.ads.readwrite does not exist
> >>>>
> >>>> I see in e.g. OpcuaField.java: Cannot resolve symbol
> >> 'OpcuaIdentifierType'
> >>>>
> >>>> Regards,
> >>>> Andreas
> >>>>
> >>>>> On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
> >>>>>
> >>>>> Hi Andreas,
> >>>>>
> >>>>> I also saw the same issue running the example. I have just pushed a
> >>>> branch
> >>>>> to fix this bug/opcua_subscription. If you can try it out that would
> be
> >>>>> great.
> >>>>>
> >>>>> Kind Regards
> >>>>>
> >>>>> Ben
> >>>>>
> >>>>> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
> >>>> <an...@me.com.invalid>
> >>>>> wrote:
> >>>>>
> >>>>>> Hi Matthias,
> >>>>>>
> >>>>>> It’s
> >>>>>> * Java 11.0.9 (Amazon Corretto)
> >>>>>> * Intellij 2020.3.2
> >>>>>> * git clone https://github.com/apache/plc4x.git <
> >>>>>> https://github.com/apache/plc4x.git>
> >>>>>>
> >>>>>> The attached stack trace was from my project - Kotlin - maybe “app”
> >>>> comes
> >>>>>> from there.
> >>>>>> But you can just use the subscription example from the plc4x.git, it
> >>>>>> throws the same error.
> >>>>>>
> >>>>>> Regards,
> >>>>>> Andreas
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
> >>>>>> matthias.strljic@gmail.com> wrote:
> >>>>>>>
> >>>>>>> Hi Andreas,
> >>>>>>>
> >>>>>>> can you give us a bit more information about your scenario and
> setup?
> >>>>>>> Project config, java version, java jvm, IDE environment, PLC4X
> >> version
> >>>> /
> >>>>>>> Github branch?
> >>>>>>> Because the " are in unnamed module of loader 'app'" confuses me a
> >> bit.
> >>>>>>>
> >>>>>>> Greetings Matthias
> >>>>>>>
> >>>>>>> ------------------------------
> >>>>>>>> *Von:* Christofer Dutz <ch...@c-ware.de>
> >>>>>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
> >>>>>>>> *An:* dev@plc4x.apache.org
> >>>>>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
> >>>>>>>>
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> perhaps Matthias can help you with this one?
> >>>>>>>>
> >>>>>>>> Chris
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> -----Ursprüngliche Nachricht-----
> >>>>>>>> Von: Andreas Vogler <an...@me.com.INVALID>
> >>>>>>>> Gesendet: Mittwoch, 3. März 2021 20:22
> >>>>>>>> An: dev@plc4x.apache.org
> >>>>>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
> >>>>>>>>
> >>>>>>>> Same happens with the plc4j hello-world-plc4x-subscription example
> >>>> from
> >>>>>>>> the GitHub repository.
> >>>>>>>>
> >>>>>>>>> On 03.03.2021, at 18:00, Andreas Vogler
> >>>> <andreas.vogler@me.com.INVALID
> >>>>>>>
> >>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I have tried to subscribe to an OPC UA node - just took the few
> >> lines
> >>>>>>>> from the subscription example - and I get following stack trace.
> >>>>>>>>>
> >>>>>>>>> I hope someone can tell me what I am doing wrong… :-)
> >>>>>>>>>
> >>>>>>>>> val builder: PlcSubscriptionRequest.Builder =
> >>>>>>>>> plc!!.subscriptionRequestBuilder()
> >>>>>>>>> topics.forEach {
> >>>>>>>>> builder.addChangeOfStateField(it.payload, it.payload) } val
> request
> >>>>>>>>> = builder.build() val response = request.execute() val
> >>>>>>>>> subscribeResponse = response.get() ==> the exception is thrown
> here
> >>>>>>>>>
> >>>>>>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
> >>>>>> Subscribe
> >>>>>>>> nodes [1]
> >>>>>>>>> java.util.concurrent.ExecutionException:
> >>>> java.lang.ClassCastException:
> >>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> >>>>>> cannot be
> >>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> >> module
> >>>> of
> >>>>>>>> loader 'app')
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>>>>>>>    at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>>>>>>>    at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>>>>>>>    at
> >>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>>>>>>>    at
> >>>>>>>>
> >> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>>>>>>>    at
> >>>>>>>>
> >> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>>>>>>>    at
> io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>>>>>>>    at java.base/java.lang.Thread.run(Thread.java:829)
> >>>>>>>>> Caused by: java.lang.ClassCastException: class
> >>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
> >> be
> >>>>>> cast
> >>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> >> module
> >>>> of
> >>>>>>>> loader 'app')
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>>>>>>>    at
> >>>>>>>>>
> >>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>>>>>>>> Thread.java:183)
> >>>>>>>>> java.util.concurrent.ExecutionException:
> >>>> java.lang.ClassCastException:
> >>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> >>>>>> cannot be
> >>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> >> module
> >>>> of
> >>>>>>>> loader 'app')
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>>>>>>>    at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>>>>>>>    at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>>>>>>>    at
> >>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>>>>>>>    at
> >>>>>>>>
> >> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>>>>>>>    at
> >>>>>>>>
> >> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>>>>>>>    at
> io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>>>>>>>    at java.base/java.lang.Thread.run(Thread.java:829)
> >>>>>>>>> Caused by: java.lang.ClassCastException: class
> >>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
> >> be
> >>>>>> cast
> >>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> >> module
> >>>> of
> >>>>>>>> loader 'app')
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>>>>>>>    at
> >>>>>>>>
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>>>>>>>    at
> >>>>>>>>>
> >>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>>>>>>>> Thread.java:183)
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>
> >>
>
>

Re: OPC UA Subscribe throws casting error ...

Posted by Andreas Vogler <an...@me.com.INVALID>.
Thank you Ben, for me it is not super important. For OPC UA I use Eclipse Milo “native” (without PLC4X)… I just wanted to test subscriptions with PLC4X.

Is there a documentation of this sampling subscription api? I assume I can use that kind of subscription also with drivers which does not support subscriptions? I already thought about to implement a polling with old/new compare in my gateway (https://github.com/vogler75/opcua-gateway <https://github.com/vogler75/opcua-gateway>) to have some kind of subscription option for Milo-Drivers which do not support subscriptions … but if PLC4X can already do that for me… would be nice.

Best regards,
Andreas

 



> On 05.03.2021, at 13:51, Ben Hutcheson <be...@gmail.com> wrote:
> 
> Hi Andreas,
> 
> It looks like there's a bit of a mismatch between the PLC4X change of state
> api and the Milo subscription api. When using the change of state
> subscription that is used in the example a default duration gets used of 1
> second it also doesn't look like it reports by exception which I would
> expect.
> 
> Using the sampling subscription PLC4X api you could specify the sampling
> interval. I can take a look tomorrow if no one looks at it today.
> 
> Kind Regards
> 
> Ben
> 
> On Fri, Mar 5, 2021 at 7:32 AM Andreas Vogler <an...@me.com.invalid>
> wrote:
> 
>> Thx, it works now.
>> 
>> BUT: I only get values every one second…
>> 
>> 13:21:54.177 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":2.0,"isNullable":false}
>> 13:21:55.178 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":7.0,"isNullable":false}
>> 13:21:56.178 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":12.0,"isNullable":false}
>> 13:21:57.179 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":17.0,"isNullable":false}
>> 13:21:58.179 [milo-shared-thread-pool-1] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":22.0,"isNullable":false}
>> 
>> The tag increases one by one every 200ms, and here in PLC4X we miss value
>> changes..
>> 
>> Is there a way to adjust the opc ua subscription sampling interval and/or
>> monitoring options with PLC4X?
>> 
>> Regards,
>> Andreas
>> 
>> 
>> 
>>> On 05.03.2021, at 12:42, Ben Hutcheson <be...@gmail.com> wrote:
>>> 
>>> Hi Andreas,
>>> 
>>> That looks like an issue specific to your setup. It seems it's not
>> finding
>>> some of the other modules that the opcua driver and the example rely on.
>>> Can you build the entire project 'mvn clean && mvn install'?
>>> 
>>> If you could send through some more info, maven logs, etc.. it would be
>>> helpful.
>>> 
>>> Kind Regards
>>> 
>>> Ben
>>> 
>>> 
>>> On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler
>> <an...@me.com.invalid>
>>> wrote:
>>> 
>>>> Hi Ben,
>>>> 
>>>> with this Branch I get a build error - just opened it in Intellij and
>>>> tried to run the subscribe example...
>>>> 
>>>> 
>> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
>>>> java: package org.apache.plc4x.java.ads.readwrite does not exist
>>>> 
>>>> I see in e.g. OpcuaField.java: Cannot resolve symbol
>> 'OpcuaIdentifierType'
>>>> 
>>>> Regards,
>>>> Andreas
>>>> 
>>>>> On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
>>>>> 
>>>>> Hi Andreas,
>>>>> 
>>>>> I also saw the same issue running the example. I have just pushed a
>>>> branch
>>>>> to fix this bug/opcua_subscription. If you can try it out that would be
>>>>> great.
>>>>> 
>>>>> Kind Regards
>>>>> 
>>>>> Ben
>>>>> 
>>>>> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
>>>> <an...@me.com.invalid>
>>>>> wrote:
>>>>> 
>>>>>> Hi Matthias,
>>>>>> 
>>>>>> It’s
>>>>>> * Java 11.0.9 (Amazon Corretto)
>>>>>> * Intellij 2020.3.2
>>>>>> * git clone https://github.com/apache/plc4x.git <
>>>>>> https://github.com/apache/plc4x.git>
>>>>>> 
>>>>>> The attached stack trace was from my project - Kotlin - maybe “app”
>>>> comes
>>>>>> from there.
>>>>>> But you can just use the subscription example from the plc4x.git, it
>>>>>> throws the same error.
>>>>>> 
>>>>>> Regards,
>>>>>> Andreas
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
>>>>>> matthias.strljic@gmail.com> wrote:
>>>>>>> 
>>>>>>> Hi Andreas,
>>>>>>> 
>>>>>>> can you give us a bit more information about your scenario and setup?
>>>>>>> Project config, java version, java jvm, IDE environment, PLC4X
>> version
>>>> /
>>>>>>> Github branch?
>>>>>>> Because the " are in unnamed module of loader 'app'" confuses me a
>> bit.
>>>>>>> 
>>>>>>> Greetings Matthias
>>>>>>> 
>>>>>>> ------------------------------
>>>>>>>> *Von:* Christofer Dutz <ch...@c-ware.de>
>>>>>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
>>>>>>>> *An:* dev@plc4x.apache.org
>>>>>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>>>>>>>> 
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> perhaps Matthias can help you with this one?
>>>>>>>> 
>>>>>>>> Chris
>>>>>>>> 
>>>>>>>> 
>>>>>>>> -----Ursprüngliche Nachricht-----
>>>>>>>> Von: Andreas Vogler <an...@me.com.INVALID>
>>>>>>>> Gesendet: Mittwoch, 3. März 2021 20:22
>>>>>>>> An: dev@plc4x.apache.org
>>>>>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
>>>>>>>> 
>>>>>>>> Same happens with the plc4j hello-world-plc4x-subscription example
>>>> from
>>>>>>>> the GitHub repository.
>>>>>>>> 
>>>>>>>>> On 03.03.2021, at 18:00, Andreas Vogler
>>>> <andreas.vogler@me.com.INVALID
>>>>>>> 
>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Hi,
>>>>>>>>> 
>>>>>>>>> I have tried to subscribe to an OPC UA node - just took the few
>> lines
>>>>>>>> from the subscription example - and I get following stack trace.
>>>>>>>>> 
>>>>>>>>> I hope someone can tell me what I am doing wrong… :-)
>>>>>>>>> 
>>>>>>>>> val builder: PlcSubscriptionRequest.Builder =
>>>>>>>>> plc!!.subscriptionRequestBuilder()
>>>>>>>>> topics.forEach {
>>>>>>>>> builder.addChangeOfStateField(it.payload, it.payload) } val request
>>>>>>>>> = builder.build() val response = request.execute() val
>>>>>>>>> subscribeResponse = response.get() ==> the exception is thrown here
>>>>>>>>> 
>>>>>>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
>>>>>> Subscribe
>>>>>>>> nodes [1]
>>>>>>>>> java.util.concurrent.ExecutionException:
>>>> java.lang.ClassCastException:
>>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>>>> cannot be
>>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>>>    at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>>>    at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>>>    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>>>    at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
>> be
>>>>>> cast
>>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>>>    at
>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>>>    at
>>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>>>> Thread.java:183)
>>>>>>>>> java.util.concurrent.ExecutionException:
>>>> java.lang.ClassCastException:
>>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>>>> cannot be
>>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>>>    at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>>>    at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>>>    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>>>    at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
>> be
>>>>>> cast
>>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>>>    at
>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>>>    at
>>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>>>> Thread.java:183)
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: OPC UA Subscribe throws casting error ...

Posted by Ben Hutcheson <be...@gmail.com>.
Hi Andreas,

It looks like there's a bit of a mismatch between the PLC4X change of state
api and the Milo subscription api. When using the change of state
subscription that is used in the example a default duration gets used of 1
second it also doesn't look like it reports by exception which I would
expect.

Using the sampling subscription PLC4X api you could specify the sampling
interval. I can take a look tomorrow if no one looks at it today.

Kind Regards

Ben

On Fri, Mar 5, 2021 at 7:32 AM Andreas Vogler <an...@me.com.invalid>
wrote:

> Thx, it works now.
>
> BUT: I only get values every one second…
>
> 13:21:54.177 [milo-shared-thread-pool-0] INFO
> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> {"value":2.0,"isNullable":false}
> 13:21:55.178 [milo-shared-thread-pool-0] INFO
> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> {"value":7.0,"isNullable":false}
> 13:21:56.178 [milo-shared-thread-pool-0] INFO
> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> {"value":12.0,"isNullable":false}
> 13:21:57.179 [milo-shared-thread-pool-0] INFO
> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> {"value":17.0,"isNullable":false}
> 13:21:58.179 [milo-shared-thread-pool-1] INFO
> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
> {"value":22.0,"isNullable":false}
>
> The tag increases one by one every 200ms, and here in PLC4X we miss value
> changes..
>
> Is there a way to adjust the opc ua subscription sampling interval and/or
> monitoring options with PLC4X?
>
> Regards,
> Andreas
>
>
>
> > On 05.03.2021, at 12:42, Ben Hutcheson <be...@gmail.com> wrote:
> >
> > Hi Andreas,
> >
> > That looks like an issue specific to your setup. It seems it's not
> finding
> > some of the other modules that the opcua driver and the example rely on.
> > Can you build the entire project 'mvn clean && mvn install'?
> >
> > If you could send through some more info, maven logs, etc.. it would be
> > helpful.
> >
> > Kind Regards
> >
> > Ben
> >
> >
> > On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler
> <an...@me.com.invalid>
> > wrote:
> >
> >> Hi Ben,
> >>
> >> with this Branch I get a build error - just opened it in Intellij and
> >> tried to run the subscribe example...
> >>
> >>
> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
> >> java: package org.apache.plc4x.java.ads.readwrite does not exist
> >>
> >> I see in e.g. OpcuaField.java: Cannot resolve symbol
> 'OpcuaIdentifierType'
> >>
> >> Regards,
> >> Andreas
> >>
> >>> On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
> >>>
> >>> Hi Andreas,
> >>>
> >>> I also saw the same issue running the example. I have just pushed a
> >> branch
> >>> to fix this bug/opcua_subscription. If you can try it out that would be
> >>> great.
> >>>
> >>> Kind Regards
> >>>
> >>> Ben
> >>>
> >>> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
> >> <an...@me.com.invalid>
> >>> wrote:
> >>>
> >>>> Hi Matthias,
> >>>>
> >>>> It’s
> >>>> * Java 11.0.9 (Amazon Corretto)
> >>>> * Intellij 2020.3.2
> >>>> * git clone https://github.com/apache/plc4x.git <
> >>>> https://github.com/apache/plc4x.git>
> >>>>
> >>>> The attached stack trace was from my project - Kotlin - maybe “app”
> >> comes
> >>>> from there.
> >>>> But you can just use the subscription example from the plc4x.git, it
> >>>> throws the same error.
> >>>>
> >>>> Regards,
> >>>> Andreas
> >>>>
> >>>>
> >>>>
> >>>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
> >>>> matthias.strljic@gmail.com> wrote:
> >>>>>
> >>>>> Hi Andreas,
> >>>>>
> >>>>> can you give us a bit more information about your scenario and setup?
> >>>>> Project config, java version, java jvm, IDE environment, PLC4X
> version
> >> /
> >>>>> Github branch?
> >>>>> Because the " are in unnamed module of loader 'app'" confuses me a
> bit.
> >>>>>
> >>>>> Greetings Matthias
> >>>>>
> >>>>> ------------------------------
> >>>>>> *Von:* Christofer Dutz <ch...@c-ware.de>
> >>>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
> >>>>>> *An:* dev@plc4x.apache.org
> >>>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> perhaps Matthias can help you with this one?
> >>>>>>
> >>>>>> Chris
> >>>>>>
> >>>>>>
> >>>>>> -----Ursprüngliche Nachricht-----
> >>>>>> Von: Andreas Vogler <an...@me.com.INVALID>
> >>>>>> Gesendet: Mittwoch, 3. März 2021 20:22
> >>>>>> An: dev@plc4x.apache.org
> >>>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
> >>>>>>
> >>>>>> Same happens with the plc4j hello-world-plc4x-subscription example
> >> from
> >>>>>> the GitHub repository.
> >>>>>>
> >>>>>>> On 03.03.2021, at 18:00, Andreas Vogler
> >> <andreas.vogler@me.com.INVALID
> >>>>>
> >>>>>> wrote:
> >>>>>>>
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> I have tried to subscribe to an OPC UA node - just took the few
> lines
> >>>>>> from the subscription example - and I get following stack trace.
> >>>>>>>
> >>>>>>> I hope someone can tell me what I am doing wrong… :-)
> >>>>>>>
> >>>>>>> val builder: PlcSubscriptionRequest.Builder =
> >>>>>>> plc!!.subscriptionRequestBuilder()
> >>>>>>> topics.forEach {
> >>>>>>> builder.addChangeOfStateField(it.payload, it.payload) } val request
> >>>>>>> = builder.build() val response = request.execute() val
> >>>>>>> subscribeResponse = response.get() ==> the exception is thrown here
> >>>>>>>
> >>>>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
> >>>> Subscribe
> >>>>>> nodes [1]
> >>>>>>> java.util.concurrent.ExecutionException:
> >> java.lang.ClassCastException:
> >>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> >>>> cannot be
> >>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> module
> >> of
> >>>>>> loader 'app')
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>>>>>     at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>>>>>     at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>>>>>     at
> >>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>>>>>     at
> >>>>>>
> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>>>>>     at
> >>>>>>
> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>>>>>     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>>>>>     at java.base/java.lang.Thread.run(Thread.java:829)
> >>>>>>> Caused by: java.lang.ClassCastException: class
> >>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
> be
> >>>> cast
> >>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> module
> >> of
> >>>>>> loader 'app')
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>>>>>     at
> >>>>>>
> >> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>>>>>     at
> >>>>>>>
> >> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>>>>>> Thread.java:183)
> >>>>>>> java.util.concurrent.ExecutionException:
> >> java.lang.ClassCastException:
> >>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> >>>> cannot be
> >>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> module
> >> of
> >>>>>> loader 'app')
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>>>>>     at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>>>>>     at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>>>>>     at
> >>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>>>>>     at
> >>>>>>
> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>>>>>     at
> >>>>>>
> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>>>>>     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>>>>>     at java.base/java.lang.Thread.run(Thread.java:829)
> >>>>>>> Caused by: java.lang.ClassCastException: class
> >>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot
> be
> >>>> cast
> >>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
> module
> >> of
> >>>>>> loader 'app')
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>>>>>     at
> >>>>>>
> >> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>>>>>     at
> >>>>>>
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>>>>>     at
> >>>>>>>
> >> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>>>>>> Thread.java:183)
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>
> >>
>
>

Re: OPC UA Subscribe throws casting error ...

Posted by Andreas Vogler <an...@me.com.INVALID>.
Thx, it works now.

BUT: I only get values every one second…

13:21:54.177 [milo-shared-thread-pool-0] INFO  o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value: {"value":2.0,"isNullable":false}
13:21:55.178 [milo-shared-thread-pool-0] INFO  o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value: {"value":7.0,"isNullable":false}
13:21:56.178 [milo-shared-thread-pool-0] INFO  o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value: {"value":12.0,"isNullable":false}
13:21:57.179 [milo-shared-thread-pool-0] INFO  o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value: {"value":17.0,"isNullable":false}
13:21:58.179 [milo-shared-thread-pool-1] INFO  o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value: {"value":22.0,"isNullable":false}

The tag increases one by one every 200ms, and here in PLC4X we miss value changes..

Is there a way to adjust the opc ua subscription sampling interval and/or monitoring options with PLC4X?

Regards,
Andreas



> On 05.03.2021, at 12:42, Ben Hutcheson <be...@gmail.com> wrote:
> 
> Hi Andreas,
> 
> That looks like an issue specific to your setup. It seems it's not finding
> some of the other modules that the opcua driver and the example rely on.
> Can you build the entire project 'mvn clean && mvn install'?
> 
> If you could send through some more info, maven logs, etc.. it would be
> helpful.
> 
> Kind Regards
> 
> Ben
> 
> 
> On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler <an...@me.com.invalid>
> wrote:
> 
>> Hi Ben,
>> 
>> with this Branch I get a build error - just opened it in Intellij and
>> tried to run the subscribe example...
>> 
>> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
>> java: package org.apache.plc4x.java.ads.readwrite does not exist
>> 
>> I see in e.g. OpcuaField.java: Cannot resolve symbol 'OpcuaIdentifierType'
>> 
>> Regards,
>> Andreas
>> 
>>> On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
>>> 
>>> Hi Andreas,
>>> 
>>> I also saw the same issue running the example. I have just pushed a
>> branch
>>> to fix this bug/opcua_subscription. If you can try it out that would be
>>> great.
>>> 
>>> Kind Regards
>>> 
>>> Ben
>>> 
>>> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
>> <an...@me.com.invalid>
>>> wrote:
>>> 
>>>> Hi Matthias,
>>>> 
>>>> It’s
>>>> * Java 11.0.9 (Amazon Corretto)
>>>> * Intellij 2020.3.2
>>>> * git clone https://github.com/apache/plc4x.git <
>>>> https://github.com/apache/plc4x.git>
>>>> 
>>>> The attached stack trace was from my project - Kotlin - maybe “app”
>> comes
>>>> from there.
>>>> But you can just use the subscription example from the plc4x.git, it
>>>> throws the same error.
>>>> 
>>>> Regards,
>>>> Andreas
>>>> 
>>>> 
>>>> 
>>>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
>>>> matthias.strljic@gmail.com> wrote:
>>>>> 
>>>>> Hi Andreas,
>>>>> 
>>>>> can you give us a bit more information about your scenario and setup?
>>>>> Project config, java version, java jvm, IDE environment, PLC4X version
>> /
>>>>> Github branch?
>>>>> Because the " are in unnamed module of loader 'app'" confuses me a bit.
>>>>> 
>>>>> Greetings Matthias
>>>>> 
>>>>> ------------------------------
>>>>>> *Von:* Christofer Dutz <ch...@c-ware.de>
>>>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
>>>>>> *An:* dev@plc4x.apache.org
>>>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> perhaps Matthias can help you with this one?
>>>>>> 
>>>>>> Chris
>>>>>> 
>>>>>> 
>>>>>> -----Ursprüngliche Nachricht-----
>>>>>> Von: Andreas Vogler <an...@me.com.INVALID>
>>>>>> Gesendet: Mittwoch, 3. März 2021 20:22
>>>>>> An: dev@plc4x.apache.org
>>>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
>>>>>> 
>>>>>> Same happens with the plc4j hello-world-plc4x-subscription example
>> from
>>>>>> the GitHub repository.
>>>>>> 
>>>>>>> On 03.03.2021, at 18:00, Andreas Vogler
>> <andreas.vogler@me.com.INVALID
>>>>> 
>>>>>> wrote:
>>>>>>> 
>>>>>>> Hi,
>>>>>>> 
>>>>>>> I have tried to subscribe to an OPC UA node - just took the few lines
>>>>>> from the subscription example - and I get following stack trace.
>>>>>>> 
>>>>>>> I hope someone can tell me what I am doing wrong… :-)
>>>>>>> 
>>>>>>> val builder: PlcSubscriptionRequest.Builder =
>>>>>>> plc!!.subscriptionRequestBuilder()
>>>>>>> topics.forEach {
>>>>>>> builder.addChangeOfStateField(it.payload, it.payload) } val request
>>>>>>> = builder.build() val response = request.execute() val
>>>>>>> subscribeResponse = response.get() ==> the exception is thrown here
>>>>>>> 
>>>>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
>>>> Subscribe
>>>>>> nodes [1]
>>>>>>> java.util.concurrent.ExecutionException:
>> java.lang.ClassCastException:
>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>> cannot be
>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
>> of
>>>>>> loader 'app')
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>     at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>     at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>     at
>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>     at
>>>>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>     at
>>>>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>     at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
>>>> cast
>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
>> of
>>>>>> loader 'app')
>>>>>>>     at
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>     at
>>>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>     at
>>>>>>> 
>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>> Thread.java:183)
>>>>>>> java.util.concurrent.ExecutionException:
>> java.lang.ClassCastException:
>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>> cannot be
>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
>> of
>>>>>> loader 'app')
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>     at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>     at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>     at
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>     at
>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>     at
>>>>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>     at
>>>>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>     at
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>     at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
>>>> cast
>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
>> of
>>>>>> loader 'app')
>>>>>>>     at
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>     at
>>>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>     at
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>     at
>>>>>>> 
>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>> Thread.java:183)
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: OPC UA Subscribe throws casting error ...

Posted by Ben Hutcheson <be...@gmail.com>.
Hi Andreas,

That looks like an issue specific to your setup. It seems it's not finding
some of the other modules that the opcua driver and the example rely on.
Can you build the entire project 'mvn clean && mvn install'?

If you could send through some more info, maven logs, etc.. it would be
helpful.

Kind Regards

Ben


On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler <an...@me.com.invalid>
wrote:

> Hi Ben,
>
> with this Branch I get a build error - just opened it in Intellij and
> tried to run the subscribe example...
>
> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
> java: package org.apache.plc4x.java.ads.readwrite does not exist
>
> I see in e.g. OpcuaField.java: Cannot resolve symbol 'OpcuaIdentifierType'
>
> Regards,
> Andreas
>
> > On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
> >
> > Hi Andreas,
> >
> > I also saw the same issue running the example. I have just pushed a
> branch
> > to fix this bug/opcua_subscription. If you can try it out that would be
> > great.
> >
> > Kind Regards
> >
> > Ben
> >
> > On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
> <an...@me.com.invalid>
> > wrote:
> >
> >> Hi Matthias,
> >>
> >> It’s
> >> * Java 11.0.9 (Amazon Corretto)
> >> * Intellij 2020.3.2
> >> * git clone https://github.com/apache/plc4x.git <
> >> https://github.com/apache/plc4x.git>
> >>
> >> The attached stack trace was from my project - Kotlin - maybe “app”
> comes
> >> from there.
> >> But you can just use the subscription example from the plc4x.git, it
> >> throws the same error.
> >>
> >> Regards,
> >> Andreas
> >>
> >>
> >>
> >>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
> >> matthias.strljic@gmail.com> wrote:
> >>>
> >>> Hi Andreas,
> >>>
> >>> can you give us a bit more information about your scenario and setup?
> >>> Project config, java version, java jvm, IDE environment, PLC4X version
> /
> >>> Github branch?
> >>> Because the " are in unnamed module of loader 'app'" confuses me a bit.
> >>>
> >>> Greetings Matthias
> >>>
> >>> ------------------------------
> >>>> *Von:* Christofer Dutz <ch...@c-ware.de>
> >>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
> >>>> *An:* dev@plc4x.apache.org
> >>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
> >>>>
> >>>> Hi,
> >>>>
> >>>> perhaps Matthias can help you with this one?
> >>>>
> >>>> Chris
> >>>>
> >>>>
> >>>> -----Ursprüngliche Nachricht-----
> >>>> Von: Andreas Vogler <an...@me.com.INVALID>
> >>>> Gesendet: Mittwoch, 3. März 2021 20:22
> >>>> An: dev@plc4x.apache.org
> >>>> Betreff: Re: OPC UA Subscribe throws casting error ...
> >>>>
> >>>> Same happens with the plc4j hello-world-plc4x-subscription example
> from
> >>>> the GitHub repository.
> >>>>
> >>>>> On 03.03.2021, at 18:00, Andreas Vogler
> <andreas.vogler@me.com.INVALID
> >>>
> >>>> wrote:
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> I have tried to subscribe to an OPC UA node - just took the few lines
> >>>> from the subscription example - and I get following stack trace.
> >>>>>
> >>>>> I hope someone can tell me what I am doing wrong… :-)
> >>>>>
> >>>>> val builder: PlcSubscriptionRequest.Builder =
> >>>>> plc!!.subscriptionRequestBuilder()
> >>>>> topics.forEach {
> >>>>>  builder.addChangeOfStateField(it.payload, it.payload) } val request
> >>>>> = builder.build() val response = request.execute() val
> >>>>> subscribeResponse = response.get() ==> the exception is thrown here
> >>>>>
> >>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
> >> Subscribe
> >>>> nodes [1]
> >>>>> java.util.concurrent.ExecutionException:
> java.lang.ClassCastException:
> >>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> >> cannot be
> >>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
> of
> >>>> loader 'app')
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>>>      at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>>>      at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>>>      at
> >>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>>>      at
> >>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>>>      at
> >>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>>>      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>>>      at
> >>>>
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>>>      at java.base/java.lang.Thread.run(Thread.java:829)
> >>>>> Caused by: java.lang.ClassCastException: class
> >>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
> >> cast
> >>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
> of
> >>>> loader 'app')
> >>>>>      at
> >>>>
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>>>      at
> >>>>
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>>>      at
> >>>>>
> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>>>> Thread.java:183)
> >>>>> java.util.concurrent.ExecutionException:
> java.lang.ClassCastException:
> >>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> >> cannot be
> >>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
> of
> >>>> loader 'app')
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>>>      at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>>>      at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>>>      at
> >>>>
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>>>      at
> >>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>>>      at
> >>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>>>      at
> >>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>>>      at
> >>>>
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>>>      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>>>      at
> >>>>
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>>>      at
> >>>>
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>>>      at java.base/java.lang.Thread.run(Thread.java:829)
> >>>>> Caused by: java.lang.ClassCastException: class
> >>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
> >> cast
> >>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module
> of
> >>>> loader 'app')
> >>>>>      at
> >>>>
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>>>      at
> >>>>
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>>>      at
> >>>>
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>>>      at
> >>>>>
> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>>>> Thread.java:183)
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>
> >>
>
>

Re: OPC UA Subscribe throws casting error ...

Posted by Andreas Vogler <an...@me.com.INVALID>.
Hi Ben, 

with this Branch I get a build error - just opened it in Intellij and tried to run the subscribe example...
/Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
java: package org.apache.plc4x.java.ads.readwrite does not exist

I see in e.g. OpcuaField.java: Cannot resolve symbol 'OpcuaIdentifierType'

Regards,
Andreas

> On 05.03.2021, at 11:05, Ben Hutcheson <be...@gmail.com> wrote:
> 
> Hi Andreas,
> 
> I also saw the same issue running the example. I have just pushed a branch
> to fix this bug/opcua_subscription. If you can try it out that would be
> great.
> 
> Kind Regards
> 
> Ben
> 
> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler <an...@me.com.invalid>
> wrote:
> 
>> Hi Matthias,
>> 
>> It’s
>> * Java 11.0.9 (Amazon Corretto)
>> * Intellij 2020.3.2
>> * git clone https://github.com/apache/plc4x.git <
>> https://github.com/apache/plc4x.git>
>> 
>> The attached stack trace was from my project - Kotlin - maybe “app” comes
>> from there.
>> But you can just use the subscription example from the plc4x.git, it
>> throws the same error.
>> 
>> Regards,
>> Andreas
>> 
>> 
>> 
>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
>> matthias.strljic@gmail.com> wrote:
>>> 
>>> Hi Andreas,
>>> 
>>> can you give us a bit more information about your scenario and setup?
>>> Project config, java version, java jvm, IDE environment, PLC4X version /
>>> Github branch?
>>> Because the " are in unnamed module of loader 'app'" confuses me a bit.
>>> 
>>> Greetings Matthias
>>> 
>>> ------------------------------
>>>> *Von:* Christofer Dutz <ch...@c-ware.de>
>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
>>>> *An:* dev@plc4x.apache.org
>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>>>> 
>>>> Hi,
>>>> 
>>>> perhaps Matthias can help you with this one?
>>>> 
>>>> Chris
>>>> 
>>>> 
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Andreas Vogler <an...@me.com.INVALID>
>>>> Gesendet: Mittwoch, 3. März 2021 20:22
>>>> An: dev@plc4x.apache.org
>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
>>>> 
>>>> Same happens with the plc4j hello-world-plc4x-subscription example from
>>>> the GitHub repository.
>>>> 
>>>>> On 03.03.2021, at 18:00, Andreas Vogler <andreas.vogler@me.com.INVALID
>>> 
>>>> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I have tried to subscribe to an OPC UA node - just took the few lines
>>>> from the subscription example - and I get following stack trace.
>>>>> 
>>>>> I hope someone can tell me what I am doing wrong… :-)
>>>>> 
>>>>> val builder: PlcSubscriptionRequest.Builder =
>>>>> plc!!.subscriptionRequestBuilder()
>>>>> topics.forEach {
>>>>>  builder.addChangeOfStateField(it.payload, it.payload) } val request
>>>>> = builder.build() val response = request.execute() val
>>>>> subscribeResponse = response.get() ==> the exception is thrown here
>>>>> 
>>>>> [2021-03-03 17:52:26][INFO   ][opc                           ]
>> Subscribe
>>>> nodes [1]
>>>>> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>> cannot be
>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>>>> loader 'app')
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>      at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>      at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>      at
>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>      at
>>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>      at
>>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>      at
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>      at java.base/java.lang.Thread.run(Thread.java:829)
>>>>> Caused by: java.lang.ClassCastException: class
>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
>> cast
>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>>>> loader 'app')
>>>>>      at
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>      at
>>>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>      at
>>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>> Thread.java:183)
>>>>> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>> cannot be
>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>>>> loader 'app')
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>      at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>      at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>      at
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>      at
>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>      at
>>>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>      at
>>>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>      at
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>      at
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>      at
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>      at java.base/java.lang.Thread.run(Thread.java:829)
>>>>> Caused by: java.lang.ClassCastException: class
>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
>> cast
>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>>>> loader 'app')
>>>>>      at
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>      at
>>>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>      at
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>      at
>>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>> Thread.java:183)
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: OPC UA Subscribe throws casting error ...

Posted by Ben Hutcheson <be...@gmail.com>.
Hi Andreas,

I also saw the same issue running the example. I have just pushed a branch
to fix this bug/opcua_subscription. If you can try it out that would be
great.

Kind Regards

Ben

On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler <an...@me.com.invalid>
wrote:

> Hi Matthias,
>
> It’s
> * Java 11.0.9 (Amazon Corretto)
> * Intellij 2020.3.2
> * git clone https://github.com/apache/plc4x.git <
> https://github.com/apache/plc4x.git>
>
> The attached stack trace was from my project - Kotlin - maybe “app” comes
> from there.
> But you can just use the subscription example from the plc4x.git, it
> throws the same error.
>
> Regards,
> Andreas
>
>
>
> > On 03.03.2021, at 21:04, Matthias Milan Strljic <
> matthias.strljic@gmail.com> wrote:
> >
> > Hi Andreas,
> >
> > can you give us a bit more information about your scenario and setup?
> > Project config, java version, java jvm, IDE environment, PLC4X version /
> > Github branch?
> > Because the " are in unnamed module of loader 'app'" confuses me a bit.
> >
> > Greetings Matthias
> >
> > ------------------------------
> >> *Von:* Christofer Dutz <ch...@c-ware.de>
> >> *Gesendet:* Mittwoch, 3. März 2021 20:40
> >> *An:* dev@plc4x.apache.org
> >> *Betreff:* AW: OPC UA Subscribe throws casting error ...
> >>
> >> Hi,
> >>
> >> perhaps Matthias can help you with this one?
> >>
> >> Chris
> >>
> >>
> >> -----Ursprüngliche Nachricht-----
> >> Von: Andreas Vogler <an...@me.com.INVALID>
> >> Gesendet: Mittwoch, 3. März 2021 20:22
> >> An: dev@plc4x.apache.org
> >> Betreff: Re: OPC UA Subscribe throws casting error ...
> >>
> >> Same happens with the plc4j hello-world-plc4x-subscription example from
> >> the GitHub repository.
> >>
> >>> On 03.03.2021, at 18:00, Andreas Vogler <andreas.vogler@me.com.INVALID
> >
> >> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I have tried to subscribe to an OPC UA node - just took the few lines
> >> from the subscription example - and I get following stack trace.
> >>>
> >>> I hope someone can tell me what I am doing wrong… :-)
> >>>
> >>> val builder: PlcSubscriptionRequest.Builder =
> >>> plc!!.subscriptionRequestBuilder()
> >>> topics.forEach {
> >>>   builder.addChangeOfStateField(it.payload, it.payload) } val request
> >>> = builder.build() val response = request.execute() val
> >>> subscribeResponse = response.get() ==> the exception is thrown here
> >>>
> >>> [2021-03-03 17:52:26][INFO   ][opc                           ]
> Subscribe
> >> nodes [1]
> >>> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
> >> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> cannot be
> >> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> >> loader 'app')
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>       at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>       at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>       at
> >> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>       at
> >> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>       at
> >> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>       at
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>       at
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>       at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>       at
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>       at
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>       at
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>       at java.base/java.lang.Thread.run(Thread.java:829)
> >>> Caused by: java.lang.ClassCastException: class
> >> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
> cast
> >> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> >> loader 'app')
> >>>       at
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>       at
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>       at
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>       at
> >> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>       at
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>       at
> >>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>> Thread.java:183)
> >>> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
> >> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
> cannot be
> >> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> >> loader 'app')
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >>>       at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >>>       at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >>>       at
> >>
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >>>       at
> >> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >>>       at
> >> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >>>       at
> >> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >>>       at
> >>
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >>>       at
> >>
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >>>       at
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >>>       at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >>>       at
> >>
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >>>       at
> >>
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >>>       at
> >>
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >>>       at java.base/java.lang.Thread.run(Thread.java:829)
> >>> Caused by: java.lang.ClassCastException: class
> >> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
> cast
> >> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> >> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> >> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> >> loader 'app')
> >>>       at
> >>
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >>>       at
> >>
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >>>       at
> >>
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >>>       at
> >>
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >>>       at
> >> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >>>       at
> >>
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >>>       at
> >>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> >>> Thread.java:183)
> >>>
> >>>
> >>>
> >>
> >>
>
>

Re: OPC UA Subscribe throws casting error ...

Posted by Andreas Vogler <an...@me.com.INVALID>.
Hi Matthias,

It’s 
* Java 11.0.9 (Amazon Corretto)
* Intellij 2020.3.2
* git clone https://github.com/apache/plc4x.git <https://github.com/apache/plc4x.git>

The attached stack trace was from my project - Kotlin - maybe “app” comes from there.
But you can just use the subscription example from the plc4x.git, it throws the same error.

Regards,
Andreas



> On 03.03.2021, at 21:04, Matthias Milan Strljic <ma...@gmail.com> wrote:
> 
> Hi Andreas,
> 
> can you give us a bit more information about your scenario and setup?
> Project config, java version, java jvm, IDE environment, PLC4X version /
> Github branch?
> Because the " are in unnamed module of loader 'app'" confuses me a bit.
> 
> Greetings Matthias
> 
> ------------------------------
>> *Von:* Christofer Dutz <ch...@c-ware.de>
>> *Gesendet:* Mittwoch, 3. März 2021 20:40
>> *An:* dev@plc4x.apache.org
>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>> 
>> Hi,
>> 
>> perhaps Matthias can help you with this one?
>> 
>> Chris
>> 
>> 
>> -----Ursprüngliche Nachricht-----
>> Von: Andreas Vogler <an...@me.com.INVALID>
>> Gesendet: Mittwoch, 3. März 2021 20:22
>> An: dev@plc4x.apache.org
>> Betreff: Re: OPC UA Subscribe throws casting error ...
>> 
>> Same happens with the plc4j hello-world-plc4x-subscription example from
>> the GitHub repository.
>> 
>>> On 03.03.2021, at 18:00, Andreas Vogler <an...@me.com.INVALID>
>> wrote:
>>> 
>>> Hi,
>>> 
>>> I have tried to subscribe to an OPC UA node - just took the few lines
>> from the subscription example - and I get following stack trace.
>>> 
>>> I hope someone can tell me what I am doing wrong… :-)
>>> 
>>> val builder: PlcSubscriptionRequest.Builder =
>>> plc!!.subscriptionRequestBuilder()
>>> topics.forEach {
>>>   builder.addChangeOfStateField(it.payload, it.payload) } val request
>>> = builder.build() val response = request.execute() val
>>> subscribeResponse = response.get() ==> the exception is thrown here
>>> 
>>> [2021-03-03 17:52:26][INFO   ][opc                           ] Subscribe
>> nodes [1]
>>> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>> loader 'app')
>>>       at
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>       at
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>       at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>       at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>       at
>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>       at
>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>       at
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>       at
>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>       at
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>       at
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>       at
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>       at
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>       at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>       at
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>       at
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>       at
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>       at java.base/java.lang.Thread.run(Thread.java:829)
>>> Caused by: java.lang.ClassCastException: class
>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast
>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>> loader 'app')
>>>       at
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>       at
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>       at
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>       at
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>       at
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>       at
>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>       at
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>       at
>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>> Thread.java:183)
>>> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>> loader 'app')
>>>       at
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>       at
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>       at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>       at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>       at
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>       at
>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>       at
>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>       at
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>       at
>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>       at
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>       at
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>       at
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>       at
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>       at
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>       at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>       at
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>       at
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>       at
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>       at java.base/java.lang.Thread.run(Thread.java:829)
>>> Caused by: java.lang.ClassCastException: class
>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast
>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
>> loader 'app')
>>>       at
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>       at
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>       at
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>       at
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>       at
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>       at
>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>       at
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>       at
>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>> Thread.java:183)
>>> 
>>> 
>>> 
>> 
>> 


Re: OPC UA Subscribe throws casting error ...

Posted by Matthias Milan Strljic <ma...@gmail.com>.
Hi Andreas,

can you give us a bit more information about your scenario and setup?
Project config, java version, java jvm, IDE environment, PLC4X version /
Github branch?
Because the " are in unnamed module of loader 'app'" confuses me a bit.

Greetings Matthias

------------------------------
> *Von:* Christofer Dutz <ch...@c-ware.de>
> *Gesendet:* Mittwoch, 3. März 2021 20:40
> *An:* dev@plc4x.apache.org
> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>
> Hi,
>
> perhaps Matthias can help you with this one?
>
> Chris
>
>
> -----Ursprüngliche Nachricht-----
> Von: Andreas Vogler <an...@me.com.INVALID>
> Gesendet: Mittwoch, 3. März 2021 20:22
> An: dev@plc4x.apache.org
> Betreff: Re: OPC UA Subscribe throws casting error ...
>
> Same happens with the plc4j hello-world-plc4x-subscription example from
> the GitHub repository.
>
> > On 03.03.2021, at 18:00, Andreas Vogler <an...@me.com.INVALID>
> wrote:
> >
> > Hi,
> >
> > I have tried to subscribe to an OPC UA node - just took the few lines
> from the subscription example - and I get following stack trace.
> >
> > I hope someone can tell me what I am doing wrong… :-)
> >
> > val builder: PlcSubscriptionRequest.Builder =
> > plc!!.subscriptionRequestBuilder()
> > topics.forEach {
> >    builder.addChangeOfStateField(it.payload, it.payload) } val request
> > = builder.build() val response = request.execute() val
> > subscribeResponse = response.get() ==> the exception is thrown here
> >
> > [2021-03-03 17:52:26][INFO   ][opc                           ] Subscribe
> nodes [1]
> > java.util.concurrent.ExecutionException: java.lang.ClassCastException:
> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> loader 'app')
> >        at
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >        at
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >        at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >        at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >        at
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >        at
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >        at
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >        at
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >        at
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >        at
> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >        at
> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >        at
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >        at
> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >        at
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >        at
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >        at
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >        at
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >        at
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >        at
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >        at
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >        at java.base/java.lang.Thread.run(Thread.java:829)
> > Caused by: java.lang.ClassCastException: class
> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast
> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> loader 'app')
> >        at
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >        at
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >        at
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >        at
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >        at
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >        at
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >        at
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >        at
> > java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> > Thread.java:183)
> > java.util.concurrent.ExecutionException: java.lang.ClassCastException:
> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be
> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> loader 'app')
> >        at
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >        at
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> >        at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> >        at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> >        at
> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> >        at
> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> >        at
> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> >        at
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> >        at
> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> >        at
> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> >        at
> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> >        at
> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> >        at
> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> >        at
> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> >        at
> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> >        at
> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> >        at
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> >        at
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> >        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> >        at
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> >        at
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> >        at
> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> >        at java.base/java.lang.Thread.run(Thread.java:829)
> > Caused by: java.lang.ClassCastException: class
> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast
> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and
> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of
> loader 'app')
> >        at
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> >        at
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> >        at
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> >        at
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >        at
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> >        at
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> >        at
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> >        at
> > java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> > Thread.java:183)
> >
> >
> >
>
>

AW: OPC UA Subscribe throws casting error ...

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi,

perhaps Matthias can help you with this one?

Chris


-----Ursprüngliche Nachricht-----
Von: Andreas Vogler <an...@me.com.INVALID> 
Gesendet: Mittwoch, 3. März 2021 20:22
An: dev@plc4x.apache.org
Betreff: Re: OPC UA Subscribe throws casting error ...

Same happens with the plc4j hello-world-plc4x-subscription example from the GitHub repository.

> On 03.03.2021, at 18:00, Andreas Vogler <an...@me.com.INVALID> wrote:
> 
> Hi,
> 
> I have tried to subscribe to an OPC UA node - just took the few lines from the subscription example - and I get following stack trace. 
> 
> I hope someone can tell me what I am doing wrong… :-)
> 
> val builder: PlcSubscriptionRequest.Builder = 
> plc!!.subscriptionRequestBuilder()
> topics.forEach {
>    builder.addChangeOfStateField(it.payload, it.payload) } val request 
> = builder.build() val response = request.execute() val 
> subscribeResponse = response.get() ==> the exception is thrown here
> 
> [2021-03-03 17:52:26][INFO   ][opc                           ] Subscribe nodes [1] 
> java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> 	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> 	at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> 	at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> 	at at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> 	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> 	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> 	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> Caused by: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> 	at 
> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> Thread.java:183)
> java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> 	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> 	at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> 	at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> 	at at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> 	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> 	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> 	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> Caused by: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> 	at 
> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
> Thread.java:183)
> 
> 
> 


Re: OPC UA Subscribe throws casting error ...

Posted by Andreas Vogler <an...@me.com.INVALID>.
Same happens with the plc4j hello-world-plc4x-subscription example from the GitHub repository.

> On 03.03.2021, at 18:00, Andreas Vogler <an...@me.com.INVALID> wrote:
> 
> Hi,
> 
> I have tried to subscribe to an OPC UA node - just took the few lines from the subscription example - and I get following stack trace. 
> 
> I hope someone can tell me what I am doing wrong… :-) 
> 
> val builder: PlcSubscriptionRequest.Builder = plc!!.subscriptionRequestBuilder()
> topics.forEach {
>    builder.addChangeOfStateField(it.payload, it.payload)
> }
> val request = builder.build()
> val response = request.execute()
> val subscribeResponse = response.get() ==> the exception is thrown here
> 
> [2021-03-03 17:52:26][INFO   ][opc                           ] Subscribe nodes [1] 
> java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> 	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> 	at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> 	at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> 	at at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> 	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> 	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> 	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> Caused by: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
> java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> 	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
> 	at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
> 	at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
> 	at at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
> 	at at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
> 	at at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
> 	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
> 	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
> 	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
> 	at io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
> 	at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
> 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
> 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
> 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
> 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> Caused by: java.lang.ClassCastException: class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField cannot be cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField and org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed module of loader 'app')
> 	at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
> 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
> 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
> 
> 
>