You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by 刘存杰 <lc...@nuaa.edu.cn> on 2020/08/25 04:53:22 UTC

plc4j in osgi env

Hello all together

I developed a small application and run in OSGi Env. with plc4j modbus driver 0.7.0, I try to do sth list below

1、I package all dependencies into a fat jar, and exception "Unable to find driver for protocol modbus", driver not registed

2、 i try
PlcConnection plcConnection = new ModbusDriver().getConnection(connectionString)

plcConnection.connect();
    and exception "Unimplement transport tcp"




3、i package the dependencies into multi bundles, and the org.apache.org.plc4x.java.osgi package missing

What can i use this project in osgi env.?

Thanks and Regards, Jeff

Re: plc4j in osgi env

Posted by Łukasz Dywicki <lu...@code-house.org>.
In case if you're looking for working 0.6 build take a look this part of
our project:
https://github.com/ConnectorIO/connectorio-addons/tree/master/features/plc4x
This was indented to be moved back to plc4x but eventually other
contributors did osgification before I could.

While below feature set installs all necessary dependencies due to
classloadeing issues in 0.6 I had to wrap some of plc4x classes together
with the code:
https://github.com/ConnectorIO/connectorio-addons/blob/master/binding/plc4x/siemens/pom.xml#L81
and initialize plc driver manager with appropriate class loader:
new PlcDriverManager(getClass().getClassLoader())
which has access to both transport and driver itself.
If you use a driver classloader you will likely miss transport classes
which are not required to parse payloads. You really need to use
classloader which has access to both, but then in 0.6 you face troubles
with scanning of classpath for META-INF/services and Class.forName calls.

The 0.7 release should be better in this regard. We had quite long
discussion on that few months ago which span from April to May:
https://mail-archives.apache.org/mod_mbox/plc4x-dev/202005.mbox/%3cCA+SiN1-OEFj7pcSP8qJccHOjvaNLf1pFk8xFheXmqsaZMGoZww@mail.gmail.com%3e

Best regards,
Łukasz

On 25.08.2020 08:58, 刘存杰 wrote:
> 
> Hi Chris, i will try the Kar bundles of the driver
> 
> Many thanks,
> Jeff
> 
>> -----原始邮件-----
>> 发件人: "Christofer Dutz" <ch...@c-ware.de>
>> 发送时间: 2020-08-25 14:40:21 (星期二)
>> 收件人: "dev@plc4x.apache.org" <de...@plc4x.apache.org>
>> 抄送: 
>> 主题: Re: plc4j in osgi env
>>
>> You could try out the Kar bundles every driver should produce. Not 100% sure the 0.7.0 already had that feature, but the 0.8.0-SNAPSHOT definitely should.
>>
>> Chris
>> ________________________________
>> Von: 刘存杰 <lc...@nuaa.edu.cn>
>> Gesendet: Dienstag, 25. August 2020 06:53
>> An: dev@plc4x.apache.org <de...@plc4x.apache.org>
>> Betreff: plc4j in osgi env
>>
>> Hello all together
>>
>> I developed a small application and run in OSGi Env. with plc4j modbus driver 0.7.0, I try to do sth list below
>>
>> 1、I package all dependencies into a fat jar, and exception "Unable to find driver for protocol modbus", driver not registed
>>
>> 2、 i try
>> PlcConnection plcConnection = new ModbusDriver().getConnection(connectionString)
>>
>> plcConnection.connect();
>>     and exception "Unimplement transport tcp"
>>
>>
>>
>>
>> 3、i package the dependencies into multi bundles, and the org.apache.org.plc4x.java.osgi package missing
>>
>> What can i use this project in osgi env.?
>>
>> Thanks and Regards, Jeff

Re: Re: plc4j in osgi env

Posted by 刘存杰 <lc...@nuaa.edu.cn>.
Hi Chris, i will try the Kar bundles of the driver

Many thanks,
Jeff

> -----原始邮件-----
> 发件人: "Christofer Dutz" <ch...@c-ware.de>
> 发送时间: 2020-08-25 14:40:21 (星期二)
> 收件人: "dev@plc4x.apache.org" <de...@plc4x.apache.org>
> 抄送: 
> 主题: Re: plc4j in osgi env
> 
> You could try out the Kar bundles every driver should produce. Not 100% sure the 0.7.0 already had that feature, but the 0.8.0-SNAPSHOT definitely should.
> 
> Chris
> ________________________________
> Von: 刘存杰 <lc...@nuaa.edu.cn>
> Gesendet: Dienstag, 25. August 2020 06:53
> An: dev@plc4x.apache.org <de...@plc4x.apache.org>
> Betreff: plc4j in osgi env
> 
> Hello all together
> 
> I developed a small application and run in OSGi Env. with plc4j modbus driver 0.7.0, I try to do sth list below
> 
> 1、I package all dependencies into a fat jar, and exception "Unable to find driver for protocol modbus", driver not registed
> 
> 2、 i try
> PlcConnection plcConnection = new ModbusDriver().getConnection(connectionString)
> 
> plcConnection.connect();
>     and exception "Unimplement transport tcp"
> 
> 
> 
> 
> 3、i package the dependencies into multi bundles, and the org.apache.org.plc4x.java.osgi package missing
> 
> What can i use this project in osgi env.?
> 
> Thanks and Regards, Jeff

Re: plc4j in osgi env

Posted by Christofer Dutz <ch...@c-ware.de>.
You could try out the Kar bundles every driver should produce. Not 100% sure the 0.7.0 already had that feature, but the 0.8.0-SNAPSHOT definitely should.

Chris
________________________________
Von: 刘存杰 <lc...@nuaa.edu.cn>
Gesendet: Dienstag, 25. August 2020 06:53
An: dev@plc4x.apache.org <de...@plc4x.apache.org>
Betreff: plc4j in osgi env

Hello all together

I developed a small application and run in OSGi Env. with plc4j modbus driver 0.7.0, I try to do sth list below

1、I package all dependencies into a fat jar, and exception "Unable to find driver for protocol modbus", driver not registed

2、 i try
PlcConnection plcConnection = new ModbusDriver().getConnection(connectionString)

plcConnection.connect();
    and exception "Unimplement transport tcp"




3、i package the dependencies into multi bundles, and the org.apache.org.plc4x.java.osgi package missing

What can i use this project in osgi env.?

Thanks and Regards, Jeff