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.

jesperdj (1) [Avatar] Offline
#1
I am using Ubuntu 11.10 (64-bit) with Oracle JDK 1.7.0 update 3.

When I try to run the example from chapter 3, I get an error about a missing dependency that has to do with Swing:

-> install file:../paint-example/bundles/paint-3.0.jar
Bundle: 2
-> install file:../paint-example/bundles/shape-3.0.jar
Bundle: 3
-> start 2
org.osgi.framework.BundleException: Unresolved constraint in bundle org.foo.paint [2]: Unable to resolve 2.0: missing requirement [2.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 org.foo.shell.StartCommand.exec(StartCommand.java:10)
at org.foo.shell.ExecuteCommand.exec(ExecuteCommand.java:24)
at org.foo.shell.HistoryDecorator.exec(HistoryDecorator.java:1smilie
at org.foo.shell.Shell.run(Shell.java:39)
at java.lang.Thread.run(Thread.java:722)
at org.foo.shell.TelnetBinding$StoppableShellThread.run(TelnetBinding.java:126)
Unable to execute: start 2

When I try it with Oracle JDK 1.6.0 update 31 it works normally.

Is this a known problem? Can this be easily fixed to work with Java 7?
franferri (1) [Avatar] Offline
#2
Re: Chapter 3 example does not work with Java 7
Same to me, Windows 7

java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode, sharing)

Any idea what happens?
stuart.mcculloch (29) [Avatar] Offline
#3
Re: Chapter 3 example does not work with Java 7
The Felix launcher bundled with the original examples did not contain a profile for Java7. The latest code adds a Java7 profile via customized launcher properties:

http://code.google.com/p/osgi-in-action/source/detail?r=37
http://code.google.com/p/osgi-in-action/issues/detail?id=4

Alternatively you could also update the Felix launcher jar, but this is a simpler fix.