0
votes

symbolic name ram

Exception in thread "main" org.osgi.framework.BundleException: Unresolved constraint in bundle ram [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (osgi.wiring.package=android.dalvik) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) at org.apache.felix.framework.Felix.startBundle(Felix.java:1868) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931) at test9.Shulkam_Demo.main(Shulkam_Demo.java:35)

My code is ..

import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;

public class Shulkam_Demo {

public static void main(String[] args) throws Exception{
    // TODO Auto-generated method stub

    FrameworkFactory frameworkFactory =    ServiceLoader.load(FrameworkFactory.class).iterator().next();
    Map<String, String> config = new HashMap<String, String>();
    //TODO: add some config properties
    Framework framework = frameworkFactory.newFramework(config);
    framework.start();
    //System.out.println(framework.getSymbolicName());

    //framework.start();

   //System.out.println( "bundle id" +framework.getBundleId());
    BundleContext bc = framework.getBundleContext();

    Bundle b = bc.installBundle("file:C:\\Documents and Settings\\Rishika Inc   Lab\\Desktop\\delete12\\shulkam_accounts-0.0.1-SNAPSHOT.jar");

    System.out.println("symbolic name "+b.getSymbolicName());
    b.start();
    System.out.println("frame work started");

    framework.waitForStop(0);

    System.out.println("shut dow");

}  

and build.xml is

<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>shulkam_accounts</groupId>
<artifactId>shulkam_accounts</artifactId>
<packaging>bundle</packaging>

<version>0.0.1-SNAPSHOT</version>
<properties>

<springdm.version>1.1.2</springdm.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</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>
    <Export-Package>*</Export-Package>
    <Embed-Dependency>*</Embed-Dependency>
    <Embed-Transitive>true</Embed-Transitive>
    <Bundle-SymbolicName>ram</Bundle-SymbolicName>
    <Import-package>
    com.mysql.jdbc;version="5.1.15",
 org.osgi.framework;version="1.3.0",
!osgi.wiring.package,
!android.dalvik



 </Import-package>
<Bundle-Activator>shulkam_accounts.MyActivator</Bundle-Activator>


    </instructions>
    </configuration>
  </plugin>
  </plugins>
 </build>
 <dependencies>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.15</version>
</dependency>
<!-- Spring DM -->


    <dependency>
      <groupId>org.springframework.osgi</groupId>
      <artifactId>spring-osgi-io</artifactId>
      <version>${springdm.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.osgi</groupId>
      <artifactId>spring-osgi-core</artifactId>
      <version>${springdm.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.osgi</groupId>
      <artifactId>spring-osgi-extender</artifactId>
      <version>${springdm.version}</version>
      <scope>provided</scope>
    </dependency>

  <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.framework</artifactId>
        <version>4.0.2</version>
         <scope>provided</scope>
    </dependency>
    <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>


</dependencies>
</project>

any help appreciatable...

2

2 Answers

0
votes

I think the

<Export-Package>*</Export-Package>

is the cause. Use

<Export-Package></Export-Package> 

unless you actually export something.

0
votes

You have a problem of missing dependency:

missing requirement [1.0] osgi.wiring.package (osgi.wiring.package=android.dalvik)

and you have specified that you don't want to take it in your import-package:

<Import-package>
com.mysql.jdbc;version="5.1.15",
org.osgi.framework;version="1.3.0",
!osgi.wiring.package,
!android.dalvik

to get it, you should have it in your Import-Package.