karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Barthel (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (KARAF-2420) blueprint deployer: redeploy untouched blueprint xml in deploy folder after restart
Date Wed, 31 Jul 2013 08:41:49 GMT

    [ https://issues.apache.org/jira/browse/KARAF-2420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13725028#comment-13725028
] 

Uwe Barthel edited comment on KARAF-2420 at 7/31/13 8:40 AM:
-------------------------------------------------------------

The {{blueprint.xml}} of my {{consumer}} bundle looks similar to the following XML:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
  xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
    http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
    http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
    http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd"
>
  <reference id="configurationAdminService" interface="org.osgi.service.cm.ConfigurationAdmin"
availability="mandatory" />
  <reference id="dataSourceService" interface="javax.sql.DataSource" availability="mandatory"
    filter="(osgi.jndi.service.name=jdbc/hsqlds)" activation="eager" />

  <bean id="myConsumerService" class="my.consumer.impl.SimpleConsumer" init-method="activate"
    destroy-method="deactivate" activation="eager" depends-on="dataSourceService"
  >
    <cm:managed-properties persistent-id="my.consumer.api.ConsumerIF"
      update-strategy="component-managed" update-method="updateConfiguration" />
    <!-- set reference via set[name] on class -->
    <property name="bundle" ref="blueprintBundle" />
    <property name="configurationAdmin" ref="configurationAdminService" />
    <property name="datasource" ref="dataSourceService" />
  </bean>

  <service auto-export="disabled" interface="my.consumer.api.ConsumerIF" ref="myConsumerService"
    depends-on="dataSourceService" />

</blueprint>
{code}

Please correct me if I am thinking wrong.
The configured dependence is very strong.

I think the error occurs in the following situation:

The {{Datasource}} service reference dependence of the {{consumer}} bundle is resolved and
the bundle is in state: STARTING.
Now the {{Datasource}} service bundle will be redeployed and maybe inform the {{consumer}}
bundle about the dependency change.
But in state: STARTING the {{consumer}} bundle can't react and lookup the {{Datasource} via
JNDI.

@Achim:
Do I understand you correctly, that the JNDI lookup should wait until the DataSource service
is accessible via JNDI again?

The following Exception was thrown:
{code}
Caused by: javax.naming.NameNotFoundException: osgi:service/javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/hsqlds)"
	at org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:110)
	at org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:141)
	at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
	at javax.naming.InitialContext.lookup(InitialContext.java:411)
{code}
                
      was (Author: barthel):
    The {{blueprint.xml}} of my {{consumer}} bundle looks similar to the following XML:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
  xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
    http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
    http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
    http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd"
>
  <reference id="configurationAdminService" interface="org.osgi.service.cm.ConfigurationAdmin"
availability="mandatory" />
  <reference id="dataSourceService" interface="${datasource.interface.name}" availability="mandatory"
    filter="(osgi.jndi.service.name=jdbc/hsqlds)" activation="eager" />

  <bean id="myConsumerService" class="my.consumer.impl.SimpleConsumer" init-method="activate"
    destroy-method="deactivate" activation="eager" depends-on="dataSourceService"
  >
    <cm:managed-properties persistent-id="my.consumer.api.ConsumerIF"
      update-strategy="component-managed" update-method="updateConfiguration" />
    <!-- set reference via set[name] on class -->
    <property name="bundle" ref="blueprintBundle" />
    <property name="configurationAdmin" ref="configurationAdminService" />
    <property name="datasource" ref="dataSourceService" />
  </bean>

  <service auto-export="disabled" interface="my.consumer.api.ConsumerIF" ref="myConsumerService"
    depends-on="dataSourceService" />

</blueprint>
{code}

Please correct me if I am thinking wrong.
The configured dependence is very strong.

I think the error occurs in the following situation:

The {{Datasource}} service reference dependence of the {{consumer}} bundle is resolved and
the bundle is in state: STARTING.
Now the {{Datasource}} service bundle will be redeployed and maybe inform the {{consumer}}
bundle about the dependency change.
But in state: STARTING the {{consumer}} bundle can't react and lookup the {{Datasource} via
JNDI.

@Achim:
Do I understand you correctly, that the JNDI lookup should wait until the DataSource service
is accessible via JNDI again?

The following Exception was thrown:
{code}
Caused by: javax.naming.NameNotFoundException: osgi:service/javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/hsqlds)"
	at org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:110)
	at org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:141)
	at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
	at javax.naming.InitialContext.lookup(InitialContext.java:411)
{code}
                  
> blueprint deployer: redeploy untouched blueprint xml in deploy folder after restart
> -----------------------------------------------------------------------------------
>
>                 Key: KARAF-2420
>                 URL: https://issues.apache.org/jira/browse/KARAF-2420
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-core
>    Affects Versions: 2.2.8, 2.2.11
>         Environment: Karaf 2.2.11
> JNDI feature installed
> HSQLDB 2.3.0
>            Reporter: Uwe Barthel
>             Fix For: 2.2.12
>
>         Attachments: datasource.xml
>
>
> *Preparation*
> 1) Start clean Karaf instance
> 2) Install Aries JNDI and HSQLDB via:
> {code}
> karaf@root> bundle:install -s mvn:org.hsqldb/hsqldb
> karaf@root> feature:install jndi
> {code}
> 3) Copy attached blueprint {{Datasource}} service description into {{deploy/}} folder
and check if the blueprint deployer creates a bundle ({{datasource.xml}} bundle).
> 4) Deploy a blueprint service bundle use {{Datasource}} internally via JNDI lookup via
KAR file ({{consumer}} bundle)
> 5) Stop Karaf instance
> 6) Start Karaf
> *Problem*
> If a blueprint service bundle is installed depending on the {{Datasource}} service. This
bundle may or may not start depending of the {{Datasource}} service state. It's a timing issue
and difficult to reproduce with a simple test case.
> The {{datasource.xml}} bundle will start up and Aries JNDI setup the InitialContext and
exports the {{javax.sql.Datasource}} service.
> _FINE_
> The dependency for the {{Datasource}} service (incl. filter on the datasource name {{(osgi.jndi.service.name=jdbc/hsqlds)}})
is resolvable and the {{consumer}} bundle is starting up.
> Within the {{#activate(...)}} method of the service implementation (created and exported
via blueprint service on {{consumer}} bundle) the code is trying to get the {{Datasource}}
reference via JNDI lookup.
> _*BUT*_
> +At the same time+ the {{fileinstall}} get two file references from {{deploy/}} folder.
It is the KAR file (contains the blueprint {{consumer}} bundle) and the KAR deployer don't
redeploying it if timestamp of the file was not changed. The other file is the {{datasource.xml}}
file. The blueprint deployer *redeploy* this file.
> It seems that the {{Datasource}} service reference for the {{consumer}} bundle was resolved
*before* redeploying the {{datasource.xml}} but the JNDI lookup starts after deregistering
the {{Datasource}} service from JNDI during the redeploy of the {{datasource.xml}}.
> The start of the {{consumer}} bundle failed.
> I tried the configuration {{org.apache.aries.blueprint.synchronous=true}} but it doesn't
help either.
> *temp. Solution*
> 1) Stop Karaf
> 2) Remove blueprint xml file from {{deploy/}}
> 3) Start Karaf
> *possible Solution*
> a) Create {{.timestamp}} file for blueprint service xml files and don't redeploy the
xml if these files wasn't touch. Like the KAR deployer does.
> b) Use bundle version with file specific content like the modification timestamp (_0.0.0.20130731071830100_)
instead of the default bundle version (_0.0.0_) and check version number before reinstall
the generated bundle.
> c) ???

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message