> 2009/5/21 Matej Pončák <[email protected]>
>
>
>>> 2009/5/21 Matej Pončák <[email protected]>
>>>
>>>
>>>
>>>> Hi.
>>>>
>>>> I try to use Felix OSGi with GUI.
>>>> I have a problem with:
>>>> org.osgi.framework.BundleException: Unresolved constraint in bundle 5:
>>>> package; (&(package=org.jdesktop.application)(version>=0.0.0))
>>>>
>>>> My bundle is number 5.
>>>>
>>>> -> ps
>>>> START LEVEL 1
>>>> ID State Level Name
>>>> [ 0] [Active ] [ 0] System Bundle (1.8.0)
>>>> [ 1] [Active ] [ 1] Apache Felix Shell Service (1.2.0)
>>>> [ 2] [Active ] [ 1] Apache Felix Shell TUI (1.2.0)
>>>> [ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.4.0)
>>>> [ 5] [Installed ] [ 1] MIM module (0.0.7)
>>>> -> update 5
>>>> -> start 5
>>>> org.osgi.framework.BundleException: Unresolved constraint in bundle 5:
>>>> package; (&(package=org.jdesktop.application)(version>=0.0.0))
>>>> -> exports 5
>>>> [5] exports:
>>>> ------------
>>>> Nothing
>>>> -> imports 5
>>>> [5] imports:
>>>> ------------
>>>> Nothing
>>>> -> headers 5
>>>>
>>>> MIM module (5)
>>>> --------------
>>>> Main-Class = mis.MISApp
>>>> Bundle-Activator = mis.MISApp
>>>> Bundle-Description = My description
>>>> Export-Package = mis.service
>>>> Bundle-Version = 0.0.7
>>>> Created-By = 10.0-b23 (Sun Microsystems Inc.)
>>>> Manifest-Version = 1.0
>>>> Bundle-Vendor = test
>>>> Bundle-Name = MIM module
>>>> Ant-Version = Apache Ant 1.7.0
>>>> Class-Path = lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar
>>>> lib/felix.jar
>>>> Import-Package = org.osgi.framework,org.jdesktop.application
>>>> X-COMMENT = Main-Class will be added automatically by build
>>>> ->
>>>>
>>>>
>>>> I seted this option in my config:
>>>> # To append packages to the default set of exported system packages,
>>>> # set this value.
>>>> org.osgi.framework.system.packages.extra=org.jdesktop.application.*
>>>>
>>>>
>>>>
>>> can you try this instead:
>>>
>>>
>>>
>>>
>> org.osgi.framework.system.packages.extra=org.jdesktop.application,org.jdesktop.application.*
>>
>>> because according to the OSGi spec, a package wildcard of:
>>>
>>> org.foo.*
>>>
>>> will only match against sub-packages of org.foo and _not_ org.foo itself
>>>
>>> just for reference, in case you think the solution to this would be to
>>>
>> use:
>>
>>> org.foo*
>>>
>>> this isn't a valid package wildcard as the "*" has to be on it's own or
>>> after a "."
>>>
>>> ( if you think this is all confusing I agree, but that's the spec'd
>>> behaviour... )
>>>
>>>
>> I tried change
>> org.osgi.framework.system.packages.extra=org.jdesktop.application.*
>>
>> to
>>
>>
>> org.osgi.framework.system.packages.extra=org.jdesktop.application,org.jdesktop.application.*
>>
>>
>>
>> Here is my output:
>>
>> -> ps
>> START LEVEL 1
>> ID State Level Name
>> [ 0] [Active ] [ 0] System Bundle (1.8.0)
>> [ 1] [Active ] [ 1] Apache Felix Shell Service (1.2.0)
>> [ 2] [Active ] [ 1] Apache Felix Shell TUI (1.2.0)
>> [ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.4.0)
>> [ 5] [Resolved ] [ 1] MIM module (0.0.7)
>> -> update 5
>> -> ps
>> START LEVEL 1
>> ID State Level Name
>> [ 0] [Active ] [ 0] System Bundle (1.8.0)
>> [ 1] [Active ] [ 1] Apache Felix Shell Service (1.2.0)
>> [ 2] [Active ] [ 1] Apache Felix Shell TUI (1.2.0)
>> [ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.4.0)
>> [ 5] [Installed ] [ 1] MIM module (0.0.7)
>> -> start 5
>> org.osgi.framework.BundleException: Activator start error in bundle [5].
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1506)
>> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:779)
>> at
>>
>> org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:105)
>> at
>>
>> org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:291)
>> at
>>
>> org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:177)
>> at java.lang.Thread.run(Thread.java:636)
>> Caused by: java.lang.NoClassDefFoundError:
>> org/jdesktop/application/SingleFrameApplication
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:637)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1556)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:562)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1446)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(ModuleImpl.java:481)
>> at
>> org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3344)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1453)
>> ... 5 more
>> Caused by: java.lang.ClassNotFoundException:
>> org.jdesktop.application.SingleFrameApplication
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
>> at
>>
>> org.apache.felix.framework.ExtensionManager$ExtensionManagerModule.getClassByDelegation(ExtensionManager.java:653)
>> at
>> org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:108)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl.searchImports(ModuleImpl.java:1184)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:557)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
>> at
>>
>> org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1446)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
>> ... 15 more
>> java.lang.NoClassDefFoundError:
>> org/jdesktop/application/SingleFrameApplication
>> -> headers 5
>>
>> MIM module (5)
>> --------------
>> Main-Class = mis.MISApp
>> Bundle-Activator = mis.MISApp
>> Bundle-Description = My description
>> Export-Package = mis.service
>> Bundle-Version = 0.0.7
>> Created-By = 10.0-b23 (Sun Microsystems Inc.)
>> Manifest-Version = 1.0
>> Bundle-Vendor = test
>> Bundle-Name = MIM module
>> Ant-Version = Apache Ant 1.7.0
>> Class-Path = lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar
>> lib/felix.jar
>> Import-Package = org.osgi.framework,org.jdesktop.application
>> X-COMMENT = Main-Class will be added automatically by build
>> -> exports 5
>> [5] exports:
>> ------------
>> mis.service; version=0.0.0
>> -> imports 5
>> [5] imports:
>> ------------
>> org.osgi.framework; version=1.4.0 -> org.apache.felix.framework [0]
>> org.jdesktop.application; version=0.0.0 -> org.apache.felix.framework [0]
>> ->
>>
>>
>
> OK, so you now have your client bundle wired to the system bundle for
> "org.jdesktop.application"
> - presumably you've put the JDesktop jars on the same classpath that you use
> to launch Felix?
>
> such as:
>
> java -classpath bin/felix.jar:<jdesktop-jars> org.apache.felix.main.Main
>
> the jars need to be on the launching classpath so the Felix system bundle
> can delegate to them
>
>
I tried launch it with command:
java -classpath bin/felix.jar:../MIS/dist/lib/appframework-1.0.3.jar
org.apache.felix.main.Main
and .....
I think its better:
ma...@rompilio:~/NetBeansProjects/Felix$ java -classpath
bin/felix.jar:../MIS/dist/lib/appframework-1.0.3.jar
org.apache.felix.main.Main
Welcome to Felix.
=================
org.osgi.framework.BundleException: R3 imports cannot contain directives.
at
org.apache.felix.framework.util.manifestparser.ManifestParser.checkAndNormalizeR3(ManifestParser.java:613)
at
org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:259)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.<init>(ModuleImpl.java:155)
at
org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:970)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2123)
at org.apache.felix.framework.Felix.init(Felix.java:581)
at org.apache.felix.framework.Felix.start(Felix.java:672)
at org.apache.felix.main.Main.main(Main.java:213)
org.osgi.framework.BundleException: R3 imports cannot contain directives.
at
org.apache.felix.framework.util.manifestparser.ManifestParser.checkAndNormalizeR3(ManifestParser.java:613)
at
org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:259)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.<init>(ModuleImpl.java:155)
at
org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:970)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2123)
at org.apache.felix.framework.Felix.init(Felix.java:581)
at org.apache.felix.framework.Felix.start(Felix.java:672)
at org.apache.felix.main.Main.main(Main.java:213)
ERROR: Unable to re-install
file:/home/matej/NetBeansProjects/MIS/dist/MIS.jar
(org.osgi.framework.BundleException: R3 imports cannot contain directives.)
org.osgi.framework.BundleException: R3 imports cannot contain directives.
at
org.apache.felix.framework.util.manifestparser.ManifestParser.checkAndNormalizeR3(ManifestParser.java:613)
at
org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:259)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.<init>(ModuleImpl.java:155)
at
org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:970)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2123)
at org.apache.felix.framework.Felix.init(Felix.java:581)
at org.apache.felix.framework.Felix.start(Felix.java:672)
at org.apache.felix.main.Main.main(Main.java:213)
->
->
->
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.8.0)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.2.0)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.2.0)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.4.0)
[ 5] [Active ] [ 1] MIM module (0.0.7)
-> services 5
MIM module (5) provides:
------------------------
Language = English
objectClass = mis.service.MimService
service.id = 26
->
Although there is some Errors, it seems to my service is running.
I can run my jar file with command "java -jar MIS.jar" successfuly.
I expected that felix.jar doesn't change my enviroment settings
(classpath). So, do I have to set all my env. (classpath) settings to
java command? I expected that Felix appends their own settings, but not
overwrite.
Thanks a lot for yours help.
Can you please help me with actual error?
(org.osgi.framework.BundleException: R3 imports cannot contain directives.)
Matej
>
>> Any another ideas?
>>
>> Matej
>>
>>
>>> And my Java file is:
>>>
>>>
>>>> <filecontent>
>>>> /*
>>>> * MISApp.java
>>>> */
>>>>
>>>> package mis;
>>>>
>>>> import org.jdesktop.application.Application;
>>>> import org.jdesktop.application.SingleFrameApplication;
>>>> import org.osgi.framework.BundleActivator;
>>>> import org.osgi.framework.BundleContext;
>>>> import org.osgi.framework.ServiceListener;
>>>> import org.osgi.framework.ServiceEvent;
>>>> import java.util.Properties;
>>>> import mis.service.MimService;
>>>>
>>>>
>>>>
>>>> /**
>>>> * The main class of the application.
>>>> */
>>>> public class MISApp extends SingleFrameApplication implements
>>>> BundleActivator {
>>>>
>>>> public void start(BundleContext context)
>>>> {
>>>> Properties props = new Properties();
>>>> props.put("Language", "English");
>>>> context.registerService(
>>>> MimService.class.getName(), new MimServiceImpl(), props);
>>>> }
>>>>
>>>>
>>>> public void stop(BundleContext context)
>>>> {
>>>> context=null;
>>>> // NOTE: The service is automatically unregistered.
>>>> }
>>>>
>>>>
>>>> private static class MimServiceImpl implements MimService
>>>> {
>>>> // The set of words contained in the dictionary.
>>>> String[] m_dictionary =
>>>> { "welcome", "to", "the", "osgi", "tutorial" };
>>>>
>>>> /**
>>>> * Implements DictionaryService.checkWord(). Determines
>>>> * if the passed in word is contained in the dictionary.
>>>> * @param word the word to be checked.
>>>> * @return true if the word is in the dictionary,
>>>> * false otherwise.
>>>> **/
>>>> public void setMenuItem(String word)
>>>> {
>>>> word = word.toLowerCase();
>>>>
>>>> System.out.println("Prislo taketo slovo:" + word);
>>>> /* // This is very inefficient
>>>> for (int i = 0; i < m_dictionary.length; i++)
>>>> {
>>>> if (m_dictionary[i].equals(word))
>>>> {
>>>> return true;
>>>> }
>>>> }
>>>> return false;
>>>> */
>>>> }
>>>> }
>>>>
>>>>
>>>>
>>>> /**
>>>> * At startup create and show the main frame of the application.
>>>> */
>>>> @Override protected void startup() {
>>>> show(new MISView(this));
>>>> }
>>>>
>>>> /**
>>>> * This method is to initialize the specified window by injecting
>>>> resources.
>>>> * Windows shown in our application come fully initialized from the
>>>>
>> GUI
>>
>>>> * builder, so this additional configuration is not needed.
>>>> */
>>>> @Override protected void configureWindow(java.awt.Window root) {
>>>> }
>>>>
>>>> /**
>>>> * A convenient static getter for the application instance.
>>>> * @return the instance of MISApp
>>>> */
>>>> public static MISApp getApplication() {
>>>> return Application.getInstance(MISApp.class);
>>>> }
>>>>
>>>> /**
>>>> * Main method launching the application.
>>>> */
>>>> public static void main(String[] args) {
>>>> launch(MISApp.class, args);
>>>> }
>>>> }
>>>>
>>>> </filecontent>
>>>>
>>>>
>>>> When I want to run my application with command
>>>> java -jar MIS.jar
>>>> it works fine.
>>>>
>>>> But when I try to run it in Felix prompt it doesn't run.
>>>>
>>>> I tried to search in mail-archive, but it didn't help.
>>>>
>>>> Thanks for all suggestions.
>>>>
>>>> Matej
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]