Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compat1x: missing imports #133

Closed
maggu2810 opened this issue Feb 16, 2015 · 6 comments
Closed

compat1x: missing imports #133

maggu2810 opened this issue Feb 16, 2015 · 6 comments

Comments

@maggu2810
Copy link

org.openhab.core.compat1x.internal.CompatibilityActivator calls in the stop function the method playStream of "org.openhab.io.multimedia.actions.Audio" with a null object.
This will throw a "UnsupportedAudioFileException" (javax.sound.sampled.UnsupportedAudioFileException).
The Import-Package is missing the javax.sound stuff completely.

The Audio class is using imports of javax.sound

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Port;
import javax.sound.sampled.UnsupportedAudioFileException;

So IMHO this have to be added to the MANIFEST.MF.

2015-02-16 13:27:50,025 | DEBUG | nsole user karaf | compat1x                         | 84 - org.openhab.core.compat1x - 2.0.0.201502121641 | BundleEvent STOPPING - org.openhab.core.compat1x
2015-02-16 13:27:50,028 | ERROR | nsole user karaf | Felix                            |  -  -  | Error stopping bundle.
java.lang.NoClassDefFoundError: javax/sound/sampled/UnsupportedAudioFileException
        at org.openhab.core.compat1x.internal.CompatibilityActivator.stop(CompatibilityActivator.java:57)
        at org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:667)[org.apache.felix.framework-4.4.1.jar:]
        at org.apache.felix.framework.Felix.stopBundle(Felix.java:2538)[org.apache.felix.framework-4.4.1.jar:]
        at org.apache.felix.framework.BundleImpl.stop(BundleImpl.java:1012)[org.apache.felix.framework-4.4.1.jar:]
        at org.apache.karaf.bundle.command.Stop.executeOnBundle(Stop.java:38)[21:org.apache.karaf.bundle.core:4.0.0.M1]
        at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:64)[21:org.apache.karaf.bundle.core:4.0.0.M1]
        at org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:54)[21:org.apache.karaf.bundle.core:4.0.0.M1]
        at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:72)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:61)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:81)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:266)[41:org.apache.karaf.shell.core:4.0.0.M1]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_25]
Caused by: java.lang.ClassNotFoundException: javax.sound.sampled.UnsupportedAudioFileException not found by org.openhab.core.compat1x [84]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)[org.apache.felix.framework-4.4.1.jar:]
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)[org.apache.felix.framework-4.4.1.jar:]
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)[org.apache.felix.framework-4.4.1.jar:]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_25]
        ... 18 more

Should I create a PR?

@maggu2810
Copy link
Author

Should the imports marked be optional?

@kaikreuzer
Copy link
Member

Do you understand why it throws this exception at all? All it should do is to close any playing stream.
Maybe the exception can be caught within the playStream method?
But yes, in general, if the jl library required javax.sound, these imports must be there. If we catch exceptions inside the Audio class, these imports can be imho made optional.

@maggu2810
Copy link
Author

A breakpoint at org.openhab.core.compat1x.internal.CompatibilityActivator.stop(CompatibilityActivator.java:57) is catched, but that one on the playStream method not.
So I do not know (ATM) why the loadClass function of the ClassLoader is called with string argument "javax.sound.sampled.UnsupportedAudioFileException" if the exception is still not thrown.
Perhaps this is done by loading static stuff of the Audio class.

@maggu2810
Copy link
Author

Also get this one:

2015-02-18 17:21:18,069 | ERROR | FelixStartLevel  | ReflectionTypeFactory            | 112 - org.eclipse.xtext.common.types - 2.6.2.v201407030533 | Incomplete methods for org.openhab.io.multimedia.actions.Audio: java.lang.NoClassDefFoundError: javax/sound/sampled/UnsupportedAudioFileException
2015-02-18 17:21:18,071 | ERROR | FelixStartLevel  | ReflectionTypeFactory            | 112 - org.eclipse.xtext.common.types - 2.6.2.v201407030533 | Incomplete constructors for org.openhab.io.multimedia.actions.Audio: java.lang.NoClassDefFoundError: javax/sound/sampled/UnsupportedAudioFileException
2015-02-18 17:21:18,071 | ERROR | FelixStartLevel  | ReflectionTypeFactory            | 112 - org.eclipse.xtext.common.types - 2.6.2.v201407030533 | Incomplete fields for org.openhab.io.multimedia.actions.Audio: java.lang.NoClassDefFoundError: javax/sound/sampled/UnsupportedAudioFileException

Will create a PR that adds javax.sound to the Import-Package, soon.

@kaikreuzer
Copy link
Member

Thanks. Does the import already solve this issue?

@maggu2810
Copy link
Author

Yes.

Flole998 pushed a commit to Flole998/openhab-addons that referenced this issue Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants