Hi Krzysztof. Thanks for your reply. I actually managed to solve the problem. The issue was that I didn't know that you can write osgi:start xxx, and then get an error message if something is wrong. Additionally I didn't know that you can just press ctrl-c (on Mac at least), and then servicemix goes back to working normally (I guess you could say that the current process within Servicemix shuts down/stops).
I found out that the actual problem was that I hadn't made all my dependencies osgi bundles (I packed all my dependencies into my jar file). This made Servicemix behave oddly. What I did was installing each dependency directly in servicemix instead, and then package my osgi bundle without dependencies. When reading about this issues, it seems like it's the preferred way of packaging osgi bunbdles - by installing dependencies directly in Servicemix, you make sure they can be used across osgi bundles. I'm using Maven, and it seems that you can use that for translating your dependencies into osgi bundles and you can even export your dependencies to Servicemix (well, essentially it's Karaf, but I guess you get where I'm going). I have been using Felix for this part, and an odd thing here is that it seems like the wrapper functionality is being deprecated. Can anyone tell me why this is the case, and how you would do the conversion from regular jar dependency to a osgi dependency in the future (automatically of course). A few notes. You can translate a regular jar dependency to an osgi bundle from within Servicemix by writing this line (example): osgi:install wrap:http://repo1.maven.org/maven2/org/json/json/20140107/json-20140107.jar The "wrap:" part does all the magic for you (you could also use mvn or file for that matter, in stead of http). I have also been working on creating an other Apache Camel route, I wanted to deploy in servicemix, where I needed to do a Microsoft SQL connection. That seemed to be an issue. I tried to install a sqljdbc4 jar directly into Servicemix, using the wrap command above. It seemed to work, but when I deployed my Camel route I got an error saying that the sqljdbc4 jar wasn't found (ClassNotFoundException). I found this blog post, that said something about the problem: http://freemanfang.blogspot.dk/2012/03/how-to-use-jdbc- driver-in-osgi.html. The important part is this: /However, if a bundle(let's say it bundle A) using some code like classForName(jdbc_driver_classname) to init a jdbc driver class, this is a big issue in OSGi world, as if BundleA not import package for jdbc_driver_classname, you'll see the problem. Unfortunately BundleA actually can't know about package name for jdbc_driver_classname beforehand, as the jdbc_driver_classname generally is passed in through configuration during runtime, it can't be determined during build time, so you can't add correct package import when you generate bundle A./ To be honest I didn't understand what the guys was trying to say :-) What I got out of that was that it seems like you need the jdbc driver to be available at compile time, and therefore you need to have the jdbc driver embedded in your osgi bundle. Below is my resulting Maven 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>affaldsTomninger</groupId> <artifactId>affaldsTomninger</artifactId> <packaging>bundle</packaging> <version>1.0</version> <dependencies> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.osgi.core</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>sqljdbc4</artifactId> <version>4.0</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20140107</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <version>2.12.3</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-http4</artifactId> <version>2.12.3</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-xmljson</artifactId> <version>2.12.3</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> <scope>test</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> <scope>test</scope> </dependency> </dependencies> <build> <defaultGoal>install</defaultGoal> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Embed-Dependency>sqljdbc4</Embed-Dependency> <_exportcontents>*</_exportcontents> <Export-Package>myroutepack</Export-Package> <Import-Package>*</Import-Package> <Bundle-Activator>osgirelated.RouteOSGIActivator</Bundle-Activator> </instructions> </configuration> </plugin> </plugins> </build> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> </project> All in all, this worked for me. I hope this will help others in similar situations as well. Regards Lasse Vestergaard -- View this message in context: http://servicemix.396122.n5.nabble.com/Debugging-osgi-bundle-with-Servicemix-tp5720458p5720563.html Sent from the ServiceMix - User mailing list archive at Nabble.com.
