title: OSGI Unresolved requirement: Import-Package: com.pi4j.io.gpio
body: <p>I want to write an <strong>OSGI Bundle</strong> (Eclipse SmartHome Binding) for the GPIO's of a Raspberry Pi.<br>
  For the GPIO's i need to include the Pi4J libraries. I added them into a lib folder in my project folder and added the pi4j-core.jar to my Build Path. </p>
  
  <p>This is my code:</p>
  
  <pre><code>/**
   * Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
   * which accompanies this distribution, and is available at
   * http://www.eclipse.org/legal/epl-v10.html
   */
  package org.openhab.binding.statusgpio.handler;
  
  import static org.openhab.binding.statusgpio.StatusGPIOBindingConstants.*;
  
  import java.util.concurrent.ScheduledFuture;
  import java.util.concurrent.TimeUnit;
  
  import org.eclipse.smarthome.core.library.types.StringType;
  import org.eclipse.smarthome.core.thing.ChannelUID;
  import org.eclipse.smarthome.core.thing.Thing;
  import org.eclipse.smarthome.core.thing.binding.BaseThingHandler;
  import org.eclipse.smarthome.core.types.Command;
  //import org.slf4j.Logger;
  //import org.slf4j.LoggerFactory;
  
  import com.pi4j.io.gpio.GpioController;
  import com.pi4j.io.gpio.GpioFactory;
  import com.pi4j.io.gpio.GpioPinDigitalInput;
  import com.pi4j.io.gpio.PinPullResistance;
  import com.pi4j.io.gpio.RaspiPin;
  import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
  import com.pi4j.io.gpio.event.GpioPinListenerDigital;
  
  /**
   * The {@link StatusGPIOHandler} is responsible for handling commands, which are
   * sent to one of the channels.
   * 
   * @author Arjuna W. - Initial contribution
   */
  public class StatusGPIOHandler extends BaseThingHandler {
  
      ScheduledFuture&lt;?&gt; refreshJob;
  
      public StatusGPIOHandler(Thing thing) {
          super(thing);
      }
  
      @Override
      public void initialize() {
          // TODO Auto-generated method stub
          super.initialize();
  
          startAutomaticRefresh();
      }
  
      @Override
      public void handleCommand(ChannelUID channelUID, Command command) {
          // TODO Auto-generated method stub
  
          // do nothing ;)
      }
  
      private void startAutomaticRefresh() {
  
          final GpioController gpio = GpioFactory.getInstance();
  
          // provision gpio pin #02 as an input pin with its internal pull down
          // resistor enabled
          final GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(
                  RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN);
  
          // create and register gpio pin listener
          myButton.addListener(new GpioPinListenerDigital() {
              @Override
              public void handleGpioPinDigitalStateChangeEvent(
                      GpioPinDigitalStateChangeEvent event) {
                  // display pin state on console
                  updateState(new ChannelUID(getThing().getUID(), CHANNEL_LOADING_STATE), new StringType(event.getState().toString()));
  
              }
  
          });
  
              try {
                  for (;;) {
                  Thread.sleep(1000);
                  }
  
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
      }   
  
  }
  </code></pre>
  
  <p>The Class has no problem to find the Pi4J imports and export to a jar is also no problem. Only if I run it directly in the Eclipse OpenHab_runtime I geht the Error:</p>
  
  <p>!<a href="http://i.stack.imgur.com/dTUrD.jpg" rel="nofollow">Validation:
  The following Problems were detected:
  org.openhab.binding.statusgpio
  Missing Constraint: Import-Package: com.pi4j.io.gpio; version="0.0.0"</a></p>
  
  <p>When I start the OSGI Bundle on my Raspberry Pi (and on my Win PC) I get the message:</p>
  
  <blockquote>
    <p>start 92 </p>
    
    <p>gogo: BundleException: Could not resolve module: org.openhab.binding.statusgpio [92]<br>
    Unresolved requirement: Import-Package: com.pi4j.io.gpio</p>
  </blockquote>
  
  <p>I think I have to do something more with the Bundle to let OSGI find the Pi4J Libs???</p>
  
  <p>Thanks for Help.</p>