Unresolved constraint in bundle, missing requirement osgi.wiring.package
Asked Answered
L

2

7

I am having a project using OSGi-(felix), SpringDM, hibernate, maven. when I installed bundle, it is ok, the output when I run bundle id is:

LastModified         1384619994484
Headers              [Manifest-Version=1.0, Bundle-Vendor=NguyenVinhLinh, Bnd-LastModified=1384619954778, Tool=Bnd-2.1.0.20130426-122213, Bundle-Name=DrugManager, Built-By=nguyenvinhlinh, Import-Package=org.hibernate,org.hibernate.classic,org.hibernate.criterion,org.springframework.beans.factory;version="[2.5,3)",org.springframework.core.io;version="[2.5,3)",org.springframework.transaction.annotation;version="[2.5,3)", Bundle-SymbolicName=DrugManagerDAO, Export-Package=drug,drugGroup,model;version="1.0.0", Bundle-Version=1.0.0, Build-Jdk=1.7.0_45, Created-By=Apache Maven Bundle Plugin, Bundle-ManifestVersion=2]
BundleContext        null
Revisions            [169.0]
BundleId             169
SymbolicName         DrugManagerDAO
RegisteredServices   null
ServicesInUse        null
Version              1.0.0
Location             file:/home/nguyenvinhlinh/Projects/felix-framework-4.2.1/bundle/DrugManager-1.0.jar
State                2
Bundle                 169|Installed  |    1|DrugManagerDAO (1.0.0)

This is what I see, when I start this bundle:

org.osgi.framework.BundleException: Unresolved constraint in bundle DrugManagerDAO [169]: Unable to resolve 169.0: missing requirement [169.0] osgi.wiring.package; (osgi.wiring.package=org.hibernate)

This is my beans.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
   http://www.springframework.org/schema/osgi
   ">

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingDirectoryLocations" ref="mappingProvider"/>
        <property name="hibernateProperties" ref="propertiesProvider"/>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/WOLOLO"/>

        <property name="username" value="root"/>
        <property name="password" value="123456"/>
    </bean>
    <bean id="mappingProvider" class="hibernate.config.HibernateMappingProvider"/>
    <bean id="propertiesProvider" class="hibernate.config.HibernatePropertiesProvider"/>

    <bean id="drugDao" class="drug.HibernateDrugDao">
        <property name="clazz" value="model.Drug"/>
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
     <bean id="drugGroupDao" class="drugGroup.HibernateDrugGroupDao">
        <property name="clazz" value="model.DrugGroup"/>
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    <osgi:service ref="drugDao" interface="drug.DrugDao"/>
    <osgi:service ref="drugGroupDao" interface="drugGroup.DrugGroupDao"/>
</beans>

This is my pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>DrugManager</groupId>
    <artifactId>DrugManager</artifactId>
    <version>1.0</version>
    <packaging>bundle</packaging>


    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.8.0.10</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>20030825.184428</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>20030825.183949</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.2.6.ga</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.27</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.4.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>DrugManagerDAO</Bundle-SymbolicName>
                        <Bundle-Vendor>NguyenVinhLinh</Bundle-Vendor>
                        <Export-Package>"drug,drugGroup,model"</Export-Package>
                        <Import-Package>org.hibernate</Import-Package> <!-- this line I try to insert into to fix requirement, but it does'nt work-->
                    </instructions>
                </configuration>

            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>java.net</id>
            <url>http://download.java.net/maven/2/</url>
        </repository>
    </repositories>


</project>

In addition, there is an completed error of bundle in felix.

g! ERROR: Bundle DrugManagerDAO [190] Error starting file:DrugManager-1.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle DrugManagerDAO [190]: Unable to resolve 190.0: missing requirement [190.0] osgi.wiring.package; (osgi.wiring.package=org.hibernate))
org.osgi.framework.BundleException: Unresolved constraint in bundle DrugManagerDAO [190]: Unable to resolve 190.0: missing requirement [190.0] osgi.wiring.package; (osgi.wiring.package=org.hibernate)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
    at java.lang.Thread.run(Thread.java:744)
Lanoralanose answered 16/11, 2013 at 8:2 Comment(0)
R
5

Do you have this bundle installed in your container (Felix) as well?

     <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.2.6.ga</version>
    </dependency>

If not install it and then see what happens when you start your bundle.

Raynata answered 16/11, 2013 at 11:51 Comment(8)
I am now using felix-framework-4.2.1. According to your reply, I should add : hibernate-3.2.6.ga.jar hibernate-core-3.5.6-Final.jar In directory: felix-framework-4.2.1/bundle. Is that what you mean? @RaynataLanoralanose
Yes, The way you installed your bundle you should install the hibernate bundle the same way in the same container; so when you list the bundles running you see both of them. This will register the services that the hibernate bundle provides and your service will pick it up.Raynata
Do you have a command, like 'headers' available in your container? I use this in Apache Karaf and I've seen the exact error you are experiencing when I don't have something that I'm dependent on in the container. What happens is that headers will show the imports and exports and highlight, in red, the one (usually only one) that I'm missing.Raynata
those bundles you told me to add to, when I used command "lb" for list bundle: I got something like 'code' 225|Active | 1|file:/home/nguyenvinhlinh/Projects/felix-framework-4.2.1/bundle/hibernate-3.2.6.ga.jar (0.0.0) 'code' Seemingly, those bundle are very weird to run in Felix context. Because when I see information of "RegisteredService" and "ServiceInUse", these are all null.Lanoralanose
Thank You Tony! I understand Felix now. I can do it :D Now, I am downloading dependent bundlesLanoralanose
:-) Outstanding. With regard to org.hibernate.annotations.common. I'd suspect that this is a transient dependency. Meaning you've just installed the one bundle but it needs annotations. I'll take a close look at exactly what your trying by downloading those bundles and see if I can shed some more light on it.Raynata
DO you have free time, I need one who has experience about felix, Could I send you my projects? My felix cannot make connectivity between service and consumer. If you can, my email is [email protected]Lanoralanose
Sure I emailed you this morning.Raynata
M
5

For missing requirement [Bundle-number] osgi.wiring.package, I added it as export-package in pom.xml, as mentioned below:

<Export-Package>
package for which error is thrown
</Export-Package>

and it worked. So if it throws the above error even after declaring it as dependency, export-package may help

Mure answered 28/4, 2014 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.