The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

nemewsys (1) [Avatar] Offline
#1
Hello,

I was trying the examples of the book. I made ant and everything seems to have compiled correctly, but now I'm getting this:


D:abcchapter04paint-example>java -jar launcher.jar bundles
Error starting framework: org.osgi.framework.BundleException: Unresolved constra
int in bundle org.foo.shape.circle [1]: Unable to resolve 1.0: missing requireme
nt [1.0] package; (package=javax.swing)
org.osgi.framework.BundleException: Unresolved constraint in bundle org.foo.shap
e.circle [1]: Unable to resolve 1.0: missing requirement [1.0] package; (package
=javax.swing)
at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3409)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1719)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:922)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:909)
at launcher.Main.main(Main.java:92)

D:abcchapter04paint-example>

I have the latest JDK (jdk-7u45-windows-i586.exe). What am I missing?

Thanks!
pavitx (5) [Avatar] Offline
#2
Re: Error with javax.swing
Also happens with JDK 7 update 45, when launching the app in chapter 2 (see page 53 at the top).
The problem seems to be that the system class path delegation (described in page 56 in the grey sidebar) is not working. The solution is to create a bundle with rt.jar which contains the javax.swing package and this add this bundle to the wanted application. An interesting exercise to do.
The book is from 2011 so some things will not work in Nov 13 or February 14...
pavitx (5) [Avatar] Offline
#3
Re: Error with javax.swing
Even better than my previous answer:
just download the last version of the book's source code using the instructions at https://code.google.com/p/osgi-in-action/source/checkout
Everything should work with Java 7 (well, issues are reported for chapter 6....)
At least now chapter 2 works for me (p. 53) whereas it did not before.
ronsmits (2) [Avatar] Offline
#4
Re: Error with javax.swing
It works perfectly with java8, but it does not work with java 8
stuart.mcculloch (29) [Avatar] Offline
#5
Re: Error with javax.swing
I've updated the example launcher to include a new profile for Java8:

https://code.google.com/p/osgi-in-action/source/detail?r=38

which should solve the problem.