Exception while creating the image using JAI library in shell script - linux

When I work with JAI from the Eclipse (all the classes specified) it works very fine, but when I bundle everything in a jar and make a shell script file from that and try to run that script I have a problem with javax.media.jai.OperationRegistry looking for a initialization file.
Has anyone else seen this problem?
Exception:
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at javax.media.jai.TiledImage.<init>(TiledImage.java:259)
at javax.media.jai.TiledImage.<init>(TiledImage.java:222)
at org.syntec.ivb.img.SingleShot.<init>(SingleShot.java:75)
at org.syntec.ivb.jni.GetCapture.<init>(GetCapture.java:21)
at org.syntec.ivb.application.SampleWindow$4.actionPerformed(SampleWindow.java:178)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6288)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2045)
at java.awt.Component.dispatchEventImpl(Component.java:4649)
at java.awt.Container.dispatchEventImpl(Container.java:2103)
at java.awt.Component.dispatchEvent(Component.java:4475)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
at java.awt.Container.dispatchEventImpl(Container.java:2089)
at java.awt.Window.dispatchEventImpl(Window.java:2587)
at java.awt.Component.dispatchEvent(Component.java:4475)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:675)
at java.awt.EventQueue.access$300(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:634)
at java.awt.EventQueue$2.run(EventQueue.java:632)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
at java.awt.EventQueue$3.run(EventQueue.java:648)
at java.awt.EventQueue$3.run(EventQueue.java:646)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:645)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: java.lang.RuntimeException: Registry initialization file not found.
at javax.media.jai.OperationRegistry.initializeRegistry(OperationRegistry.java:365)
at javax.media.jai.JAI.<clinit>(JAI.java:566)
... 41 more

Related

groovysh is giving java.lang.reflect.InvocationTargetException

Groovy version:
Groovy Version: 3.0.0-rc-3 JVM: 1.8.0_221 Vendor: Oracle Corporation OS: Linux
on running command : groovysh
Error output:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:124)
Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-64-3695606470401720252.so: /tmp/libjansi-64-3695606470401720252.so: failed to map segment from shared object: Operation not permitted]
at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:42)
at org.fusesource.jansi.AnsiConsole.wrapOutputStream(AnsiConsole.java:48)
at org.fusesource.jansi.AnsiConsole.<clinit>(AnsiConsole.java:38)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.lambda$createCallStaticSite$2(CallSiteArray.java:65)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:63)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:156)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at org.apache.groovy.groovysh.Main.installAnsi(Main.groovy:249)
at org.apache.groovy.groovysh.Main.setTerminalType(Main.groovy:235)
at org.apache.groovy.groovysh.Main.main(Main.groovy:120)
... 6 more
As far as I know this kind of issue comes not from Groovy itself, but from your user not having write rights to /tmp. For example if your tmp is mounted readonly.
Background: Jansi requires native libraries, that are part of the jar. Java cannot load them form the jar and requires them to be put "somewhere", which is usually /tmp. Since it seems your tmp cannot be written you get the "Operation not permitted".

Apache Zeppelin: How to manage dependencies for groovy interpreter

I've use Apache Zeppelin 0.8.1.
I want user Groovy interpreter. And use #Grape dep menagement:
%groovy
#Grapes([
#Grab('com.github.twosigma.beakerx:beaker-kernel-groovy:0.9.0')
])
import com.twosigma.beakerx.widget.IntSlider
But got error:
java.lang.RuntimeException: Failed to parse groovy script: java.lang.NoClassDefFoundError: org/apache/ivy/Ivy
at org.apache.zeppelin.groovy.GroovyInterpreter.getGroovyScript(GroovyInterpreter.java:140)
Reasonable. By official documentation of Dependency Management for Interpreter I've provide artifact dep: org.apache.ivy:ivy:2.5.0-rc1:
In repositories I have enabled Central (http://repo1.maven.org/maven2/) which have that artifact:
But on interpreter restarting and notebook reload I just got error: Error setting properties for interpreter 'groovy.groovy': Cannot fetch dependencies for org.apache.ivy:ivy:2.5.0-rc1:
I have tried (as experiment, not long-term solution) enter into zeppelin docker container and download http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.5.0-rc1/ivy-2.5.0-rc1.jar into /zeppelin/interpreter/groovy, restart interpreter, reload nootebook and it looks like groovy try resolve deps - i see progress-bar for second, but then again got error:
java.lang.RuntimeException: Failed to parse groovy script: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during conversion: Error grabbing Grapes -- [unresolved dependency: com.github.twosigma.beakerx#beaker-kernel-groovy;0.9.0: not found] java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: com.github.twosigma.beakerx#beaker-kernel-groovy;0.9.0: not found] 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:423) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83) at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247) at groovy.grape.GrapeIvy.getDependencies(GrapeIvy.groovy:426) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:573) at groovy.grape.GrapeIvy$resolve$1.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:190) at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:540) at groovy.grape.GrapeIvy$resolve$0.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182) at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:258) at groovy.grape.Grape.grab(Grape.java:167) at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:378) at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:321) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.parse(GroovyShell.java:700) at groovy.lang.GroovyShell.parse(GroovyShell.java:736) at org.apache.zeppelin.groovy.GroovyInterpreter.getGroovyScript(GroovyInterpreter.java:133) at org.apache.zeppelin.groovy.GroovyInterpreter.interpret(GroovyInterpreter.java:155) at org.apache.zeppelin.interpreter.LazyOpenInterpreter.interpret(LazyOpenInterpreter.java:103) at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:632) at org.apache.zeppelin.scheduler.Job.run(Job.java:188) at org.apache.zeppelin.scheduler.ParallelScheduler$JobRunner.run(ParallelScheduler.java:162) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 1 error at org.apache.zeppelin.groovy.GroovyInterpreter.getGroovyScript(GroovyInterpreter.java:140)
It looks like groovy does not see repository configurations and try resolve dependencies only locally.
What I should setup to change that?
groovy in zeppelin not designed to support #Grab
your artifact is present in a specific repository
http://maven.imagej.net/content/repositories/public/
check this artifact search engine:
https://mvnrepository.com/artifact/com.github.twosigma.beakerx/beaker-kernel-groovy/0.9.0
so, just add a new repo to zeppelin
UPD:
for org.apache.ivy:ivy:2.5.0-rc1 there are a lot of dependencies downloaded
and one of them fails. Here is what I see in console:
Error while downloading repos for interpreter group : groovy,
go to interpreter setting page click on edit and save it again
to make this interpreter work properly:
Cannot fetch dependencies for org.apache.ivy:ivy:2.5.0-rc1
...
Caused by: org.sonatype.aether.resolution.DependencyResolutionException:
Could not find artifact com.jcraft:jsch.agentproxy:jar:0.0.9 in central
(http://repo1.maven.org/maven2/)
...
(IHMO it's a bug of zeppelin)
but to make it work set
artifact= org.apache.ivy:ivy:2.4.0
exclude= com.jcraft:jsch.agentproxy

Getting this error when I try to run jar file that I created : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Appender

I am getting an exception when I try to run the jar file that I created for my java application. I am using log4j for logging purpose and I created a custom log that records per cron job transactions.
Then I have written a shell script where I call the jar file. I have put the properties file outside the jar file.
I am running the jar file through a shell script. The command I use is
java -jar app.jar $1
The java application has 2 properties files
1) app.properties
2) sublog4j.properties
The sublog4j properties file has data like this:
log4j.appender.log=package.CustomFileAppender
log4j.appender.log.File=/serverpath/error.log
I have a gut feeling that I am getting error because of package.CustomFileAppender. It is a java file in app.jar but I don't know how to create a custom appender and use it in the external properties file.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Appender
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
at java.lang.Class.getMethod0(Class.java:2856)
at java.lang.Class.getMethod(Class.java:1668)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
I was getting this error because I was not building the jar file correctly. So what I did is I created an executable jar file and also copied source code when I created the jar. This is how the issue got resolved.

bento start command fails with NoClassDefFoundError DNSCheckingTool

I was trying out the tutorial in https://github.com/kijiproject/kiji-schema/blob/master/kiji-schema-cassandra/cassandra_tutorial.md
but got stuck at the place where we start the bento box. 'bento start'
It gives the following error:
cygpath: cannot create short name of c:\276273\WorkingFolder\Cassandra\cassandra
-bento\kiji-bento-ebi\cluster\lib\hbase-0.94.6-cdh4.3.0\logs
Running bento-cluster port configuration utility.
bento: line 620: /cygdrive/c/jdk1.6.0/bin/java: Argument list too long
Exception in thread "main" java.lang.NoClassDefFoundError: org/kiji/bento/tools/
DNSCheckingTool
Caused by: java.lang.ClassNotFoundException: org.kiji.bento.tools.DNSCheckingToo
l
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.kiji.bento.tools.DNSCheckingTool. Program wi
ll exit.
Local DNS check failed. Please resolve and try again.
Can you please help?
please see https://jira.kiji.org/browse/CLUSTER-39, comment invoke set mutate_classpath variable with hbase_cp.

java.lang.NoClassDefFoundError org.eclipse.jetty.server.Connector on Jetty

I have a java web app that uses Jetty embedded and when I try to run in a linux environment I have the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Connector
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at br.com.teste.install.Launcher.work(Launcher.java:23)
at br.com.teste.install.Install.main(Install.java:14)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.Connector
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 4 more
When I run exactly the same app in a windows environment this works without any error.
I have no ideia for what happen this.
Thanks for any help.

Resources