groovy console in osgi - groovy

I managed to embed the standard groovy console to Felix and expose a number of variables (i.e. BundleContext, etc).
However, on "first" start up of my blueprint bundle, I got this error:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_24]
... ... ...
at groovy.util.FactoryBuilderSupport.callAutoRegisterMethods(FactoryBuilderSupport.java:202)[groovy-all-1.7.8.jar:1.7.8]
... 42 more
Caused by: java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl
at sun.misc.Unsafe.defineClass(Native Method)[:1.6.0_24]
... ... ...
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_24]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_24]
... ... ...
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)[groovy-all-1.7.8.jar:1.7.8]
at groovy.swing.SwingBuilder.registerActionButtonWidgets(SwingBuilder.groovy:94)[groovy-all-1.7.8.jar:1.7.8]
... 47 more
Caused by: java.lang.ClassNotFoundException: *** Package 'sun.reflect' is not imported by bundle groovy-all [18], nor is there any bundle that exports package 'sun.reflect'. However, the class 'sun.reflect.ConstructorAccessorImpl' is available from the system class loader. There are two fixes: 1) Add package 'sun.reflect' to the 'org.osgi.framework.system.packages.extra' property and modify bundle groovy-all [18] to import this package; this causes the system bundle to export class path packages. 2) Add package 'sun.reflect' to the 'org.osgi.framework.bootdelegation' property; a library or VM bug can cause classes to be loaded by the wrong class loader. The first approach is preferable for preserving modularity. ***
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1782)[org.apache.felix.framework-3.0.9.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
at org.codehaus.groovy.runtime.callsite.CallSiteClassLoader.loadClass(CallSiteClassLoader.java:51)[groovy-all-1.7.8.jar:1.7.8]
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_24]
at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.loadClass(ClassLoaderForClassArtifacts.java:58)[groovy-all-1.7.8.jar:1.7.8]
... 65 more
Caused by: java.lang.ClassNotFoundException: sun.reflect.ConstructorAccessorImpl not found by groovy-all [18]
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)[org.apache.felix.framework-3.0.9.jar:]
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)[org.apache.felix.framework-3.0.9.jar:]
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)[org.apache.felix.framework-3.0.9.jar:]
... 69 more
With the exception thrown, my bundle is now active. However, the console do not show. If I stop and start the bundle again, the error no longer shows and i'm able to see and use my swing groovy console.
The stack trace indicates the following options to fix this problem:
Add package 'sun.reflect' to the
'org.osgi.framework.system.packages.extra'
property and modify bundle
groovy-all [18] to import this
package; this causes the system
bundle to export class path
packages.
Add package 'sun.reflect' to the
'org.osgi.framework.bootdelegation'
property; a library or VM bug can
cause classes to be loaded by the
wrong class loader. The first
approach is preferable for
preserving modularity. *
I am quite certain that with option 2, the error will go away.
However, my question is...if sun.reflect is not imported, why does the groovy console show after i restart the bundle? Appreciate advice from anyone with such experience.

Option 1 is the correct solution to the problem. Your bundle depends on package sun.reflect, so you should make that explicit in the Import-Package statement.
I have no idea why the console might show after restarting. It may do its own internal "fail-over" in the event it can't load the sun.reflect package. I wouldn't worry too much about this aspect, just get it to work by adding the import.

Related

The specified procedure could not be found: for jcuda 9.2

I am attempting to load the dll for the JCudaDriver which I extracted with the jar.exe tool.
System.loadLibrary("JCudaDriver-0.9.2-windows-x86_64")
That driver is definitely in my java.libary.path because if I remove it manually, I get a not-found type error instead. Now I receive the following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: myPath.JCudaDriver-0.9.2-windows-x86_64.dll.dll: The specified procedure could not be found
My understanding is that this specified procedure is located in some missing dependency on another dll or there is a version clash. I used the windows utility function on the command line as dumpbin /dependents xx.dll to find the dependent dlls. They are as follows.
Dump of file JCudaDriver-0.9.2-windows-x86_64.dll
Image has the following dependencies:
nvcuda.dll
ADVAPI32.dll
KERNEL32.dll
I can load the nvcuda.dll without error but the latter two are a problem.
fun main(args: Array<String>) {
//System.loadLibrary("nvcuda")
System.loadLibrary("ADVAPI32")
//System.loadLibrary("KERNEL32")
}
This is the error when trying to load ADVAPI32.dll
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\aaa_eric\code\lib\dlls_x64\advapi32.dll: %1 is not a valid Win32 application
After some effort by the supporter of JCuda, Marco13 who left a comment above, the problem was identified as having updated the graphics driver after having installed Cuda. That changed some of the dlls. The fix was to remove and reinstall Cuda.
I'll reference here the forum link where we iterated to the solution.

What could be causing this runtime Lexer error in ANTLR4 4.7.1?

I am trying to update to ANTLR4 4.7.1 from 4.5. Aside from environment, the only change has been to update ANTLRInputStream and ANTLRFileStream references to CharStreams. Yet the code that worked in 4.5 now throws an error.
After the updates, I get a NoSuchMethod error when I try to run a test.
$ /usr/bin/java -cp $classpath org.antlr.v4.gui.TestRig com.greg.gumji_parser.Gumji2001 source_text -tokens -tree gumji/test_debug4.v
Exception in thread "main" java.lang.NoSuchMethodError: org.antlr.v4.runtime.atn.RuleTransition.<init>(Lorg/antlr/v4/runtime/atn/RuleStartState;IILorg/antlr/v4/runtime/atn/ATNState;)V
at org.antlr.v4.runtime.atn.ATNDeserializer.edgeFactory(ATNDeserializer.java:715)
at org.antlr.v4.runtime.atn.ATNDeserializer.deserialize(ATNDeserializer.java:332)
at com.greg.gumji_parser.Gumji2001Lexer.<clinit>(Gumji2001Lexer.java:3485)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.antlr.v4.gui.TestRig.process(TestRig.java:144)
at org.antlr.v4.gui.TestRig.main(TestRig.java:119)
$ echo $classpath
/home/greg/.m2/repository/com/greg/gumji2001-parser/1.0-SNAPSHOT/*:/usr/local/share/java/*:/home/greg/.m2/repository/org/antlr/antlr4/4.7.1/antlr4-4.7.1.jar:/home/greg/.m2/repository/org/antlr/antlr4-runtime/4.7.1/antlr4-runtime-4.7.1.jar
Has the ATN become too large? I would appreciate any advice on how to approach debugging this.
Answered by Mark Rotteveel in comments above:
The fact you're using wildcards for your imports may lead to importing
unintended dependencies (eg from /usr/local/share/java, or maybe
from that snapshot folder); it those paths contain older antlr
versions, you may actually be using an older versions of the runtime
than you think you're using, or worse: a combination of new and old!

Duplicate definition for symbol

I'm trying to compile a package (git-annex) under OpenBSD and I'm hitting some weird issues.
I keep getting
Loading package gnuidn-0.2.1 ...
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
c_isascii
whilst processing object file
/usr/local/lib/libidn.a
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
This was brought up here, here and here but it didn't help me at all. I have checked to see if I have different versions of different packages (which I don't, according to ~/.cabal/lib and 'ghc-pkg list') and I have even tried recompiling libidn without the c_isascii symbol, which only resulted in the same error but about a different symbol (stringprep_utf8_to_unichar).
So right now I have no idea what to do. Any ideas?
EDIT: Added 'ghc-pkg list' to the sources I've checked for conflicting packages.

Haskell Plugins and cabal sandbox

So, I'm trying to use the Plugins package to dynamically load a haskell function from a source file. The source file depends on a package foo with module Foo.Bar. I'm running my project in a Cabal sandbox, where I have foo installed. Both my main program, and the module I'm loading with plugins, depend on foo. I always get one of the following two errors:
When I have foo installed in ~/.cabal, I get the error:
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
aizmvszmaizmlibzm0zi1_FooziBar_zdfTypeableBazzuds2_closure
whilst processing object file
/home/joey/.cabal/lib/foo-0.1/ghc-7.6.3/HSfoo-0.1.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
When I don't have it installed in ~/.cabal, I get a standard "module not found" error. And when I don't have it installed in my sandbox, I get the same module not found error trying to compile my main program code.
The plugins documentation is scarce at best. Any thoughts on how to solve this?
I got this working by using System.Plugins.Make to actually do the compliation, instead of relying on pre-existing object files. Not a complete solution, doesn't explain the problem, but it works for me for now.

Javafx error on Ubuntu while using netbeans

When trying to run a basic javafx application on ubuntu linux, I am seeing the following error. The error appears while using either the commandline or netbeans to run the application.
Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: /home/venkat/.m2/repository/com/oracle/javafx/javafx/2.1.0-beta/i386/libglass.so
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:277)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:90)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:163)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /home/venkat/.m2/repository/com/oracle/javafx/javafx/2.1.0-beta/i386/libglass.so
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1828)
at java.lang.Runtime.load0(Runtime.java:792)
at java.lang.System.load(System.java:1059)
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:143)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:56)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:31)
at com.sun.glass.ui.Application$1.run(Application.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:73)
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:85)
at com.sun.glass.ui.gtk.GtkPlatformFactory.<clinit>(GtkPlatformFactory.java:23)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:20)
at com.sun.glass.ui.Application.Run(Application.java:108)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:267)
... 5 more
This exception is caused because maven is unable to find the native libraries on the classpath.
Netbeans
You can solve the problem by adding JVM argument inside the run profile.
-Djava.library.path=/home/venkat/Programs/javafx/2.1.0-beta/rt/lib/i386/
Image
Command line
If you face the same problem while trying to run the app on the commandline, the following exports should fix it.
export JAVAFX_HOME=/home/venkat/Programs/javafx/2.1.0-beta
export CLASSPATH=\$JAVAFX_HOME/rt/lib/jfxrt.jar
export LD_LIBRARY_PATH=/home/venkat/Programs/javafx/2.1.0-beta/rt/lib/i386/
The first two env variables above fix a classpath problem which is seen when javafx runtime cannot be found.

Resources