Java 7 platform independent Base64? - java

I am trying to make an app that will work on multiple platforms including android. The problem I'm having is that my sun.misc.BASE64Decoder works on the app running on the computer:
BASE64Decoder decoder = new BASE64Decoder();
byte[] data = decoder.decodeBuffer(is);
It's not working on an android device:
E/AndroidRuntime(18172): java.lang.NoClassDefFoundError: Failed resolution of: Lsun/misc/BASE64Decoder;
E/AndroidRuntime(18172): at com.company.app.backend.SomeClass$1.run(SomeClass.java:55)
E/AndroidRuntime(18172): at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime(18172): Caused by: java.lang.ClassNotFoundException: Didn't find class "sun.misc.BASE64Decoder" on path: DexPathList[[zip file "/data/app/com.company.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.company.app-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(18172): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(18172): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(18172): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(18172): ... 2 more
E/AndroidRuntime(18172): Suppressed: java.lang.ClassNotFoundException: sun.misc.BASE64Decoder
E/AndroidRuntime(18172): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(18172): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(18172): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(18172): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(18172): ... 3 more
E/AndroidRuntime(18172): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Unfortunately I can not use Java 8's java.util.Base64 because I can't use Java 8. Also I can not use android.util.Base64 since it will not work outside of android.
I will appreciate any help.

If you can use third party libraries, you can use commons-codec.
If not, you can find plenty of pure Java implementations online. Even the Wikipedia article has a code sample. Just add it to your own utility class.

Related

how to fix java.lang.NoClassDefFoundError crash

My app is live on play store. Its not crashing in all devices but I can see this crash in a few device only. Please help me to fix this issue.
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/android/gms/auth/api/phone/SmsRetriever; at
com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at
com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at
com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at
com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:627)
at
com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at
com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at
com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at
android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at
android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at
android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:148) at
android.app.ActivityThread.main(ActivityThread.java:5417) at
java.lang.reflect.Method.invoke(Native Method) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused
by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.auth.api.phone.SmsRetriever" on path:
DexPathList[[zip file
"/data/app/gharkadabba.gharkadabba-1/base.apk"],nativeLibraryDirectories=[/data/app/gharkadabba.gharkadabba-1/lib/x86,
/vendor/lib, /system/lib]] at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at
java.lang.ClassLoader.loadClass(ClassLoader.java:469) at
com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250) 
at
com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188) 
at
com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372) 
at
com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:627) 
at
com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57) 
at
com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189) 
at
com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176) 
at
android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297) 
at
android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46) 
at
android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116) 
at android.os.Handler.dispatchMessage(Handler.java:102)  at
android.os.Looper.loop(Looper.java:148)  at
android.app.ActivityThread.main(ActivityThread.java:5417)  at
java.lang.reflect.Method.invoke(Native Method)  at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException:
com.google.android.gms.auth.api.phone.SmsRetriever at
java.lang.Class.classForName(Native Method) at
java.lang.BootClassLoader.findClass(ClassLoader.java:781) at
java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at
java.lang.ClassLoader.loadClass(ClassLoader.java:504)
Caused by: java.lang.NoClassDefFoundError: Class not found using
the boot class loader; no stack trace available
I can see Moto G (3rd & 4th Gen), One Plus one device having crash.
I added below line to ProGuard file.
-ignorewarnings
-keep class * { public private *; }
SMS Retriever API is available in Google Play Services v10.2 and is used to auto-verify the OTP SMS.
https://developers.google.com/identity/sms-retriever/
This API will not be available in the devices that do not have Google Play Services installed - like Amazon Fire devices or the devices in the Chinese region.
If you are using this API, you have to check whether Play services are installed in the device before accessing this API.
Looking at your exception, it seems this API has been used by some Facebook kit.

Android + jfreeSVG: inheritance issues

I'm developing and Android App with Android Studio. This app makes use of an all-java library module. I've included jfreesvg by adding compile 'org.jfree:jfreesvg:3.1' to the dependencies of said java library module.
Within that java library, I am trying the given example from the main doc for SVGGraphics2D:
SVGGraphics2D g2 = new SVGGraphics2D(300, 200);
g2.setPaint(Color.black);
g2.draw(new Rectangle(10, 10, 280, 180));
String svgElement = g2.getSVGElement();
However, I get two compile errors in Android Studio, the first being in the second line:
setPaint(java.awt.Paint) in SVGGraphics2D cannot be applied to (java.awt.Color)
Also, in the next line, the following error with, I suppose the same cause, occurrs: draw(java.awt.Paint) in SVGGraphics2D cannot be applied to (java.awt.Color)
My question now is: Even though java.awt.Paint is an Interface and java.awt.Color is an implementation of that interface, why do I get that error (and the same for java.awt.Shape and java.awt.Rectangle)?
For the sake of completion: If I do run the app, which I'm confused about that it works, I get the following Exception:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: [package].app, PID: 19596
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jfree/graphics2d/svg/SVGGraphics2D;
at [package].[some.package].someMethod(Unknown)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:67)
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:62)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:811) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jfree.graphics2d.svg.SVGGraphics2D" on path: DexPathList[[zip file "/data/app/[package].app-2.apk"],nativeLibraryDirectories=[/data/app-lib/[package].app-2, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at [package].[some.package].someMethod(Unknown) 
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:67) 
at [package].app.MainActivity$SomeTask.doInBackground(MainActivity.java:62) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:811) 
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Graphics2D;
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:222)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
at dalvik.system.DexPathList.findClass(DexPathList.java:322)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 11 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.Graphics2D" on path: DexPathList[[zip file "/data/app/[package].app-2.apk"],nativeLibraryDirectories=[/data/app-lib/[package].app-2, /system/lib, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: java.awt.Graphics2D
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class "Ljava/awt/Graphics2D;" not found
... 21 more
Suppressed: java.lang.ClassNotFoundException: org.jfree.graphics2d.svg.SVGGraphics2D
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class "Lorg/jfree/graphics2d/svg/SVGGraphics2D;" not found
... 14 more
(I edited the stack trace for better readability.)
The java.awt.* package is not available in Android. So the library that you are trying to use cannot be used directly in your Android app. At least not without further work.
You would need to implement those classes yourself, or source them from somewhere else, such as from the Apache Harmony project.

Gerrit - plugin gerrit-owners-autoassign-1.1 install issue

I am having the following Stacktrace:
[2015-10-15 19:29:09,264] WARN
com.google.gerrit.server.plugins.PluginLoader : Cannot load plugin
gerrit-owners-autoassign-1.1
com.google.common.util.concurrent.ExecutionError:
com.google.common.util.concurrent.ExecutionError:
java.lang.NoClassDefFoundError:
com/google/gerrit/extensions/events/GitReferenceUpdatedListener$Update
at
com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
at com.google.common.cache.LocalCache.get(LocalCache.java:3937) at
com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941) at
com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at
com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830)
at
com.google.inject.internal.FailableCache.get(FailableCache.java:48)
at
com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
at
com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:136)
at
com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:533)
at
com.google.inject.internal.AbstractBindingProcessor$Processor$1.run(AbstractBindingProcessor.java:160)
at
com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:44)
at
com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:123)
at
com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at
com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:226)
at
com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:233)
at
com.google.gerrit.server.plugins.ServerPlugin.startPlugin(ServerPlugin.java:190)
at
com.google.gerrit.server.plugins.ServerPlugin.start(ServerPlugin.java:170)
at
com.google.gerrit.server.plugins.PluginLoader.runPlugin(PluginLoader.java:461)
at
com.google.gerrit.server.plugins.PluginLoader.rescan(PluginLoader.java:390)
at
com.google.gerrit.server.plugins.PluginLoader.start(PluginLoader.java:295)
at
com.google.gerrit.lifecycle.LifecycleManager.start(LifecycleManager.java:74)
at com.google.gerrit.pgm.Daemon.start(Daemon.java:293) at
com.google.gerrit.pgm.Daemon.run(Daemon.java:205) at
com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:166)
at
com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:93)
at
com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:50)
at Main.main(Main.java:25) Caused by:
com.google.common.util.concurrent.ExecutionError:
java.lang.NoClassDefFoundError:
com/google/gerrit/extensions/events/GitReferenceUpdatedListener$Update
at
com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
at com.google.common.cache.LocalCache.get(LocalCache.java:3937) at
com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941) at
com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at
com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830)
at
com.google.inject.internal.FailableCache.get(FailableCache.java:48)
at
com.google.inject.internal.MembersInjectorStore.get(MembersInjectorStore.java:68)
at
com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:74)
at
com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
at
com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
at
com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
at
com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
at
com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at
com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
at
com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at
com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
... 31 more Caused by: java.lang.NoClassDefFoundError:
com/google/gerrit/extensions/events/GitReferenceUpdatedListener$Update
at java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Class.java:2615) at
java.lang.Class.getDeclaredMethods(Class.java:1860) at
com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:688)
at
com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:380)
at
com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:93)
at
com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:37)
at
com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:45)
at
com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:42)
at
com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
at
com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at
com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
at
com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at
com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
... 46 more Caused by: java.lang.ClassNotFoundException:
com.google.gerrit.extensions.events.GitReferenceUpdatedListener$Update
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
java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 60 more
I am not really sure what I should look into to fix it.
This looks like a mismatch between the API version that the plugin was built against, and the API version of the Gerrit server.
java.lang.NoClassDefFoundError: com/google/gerrit/extensions/events/GitReferenceUpdatedListener$Update
The GitReferenceUpdatedListener.Update class was removed from the API in Gerrit version 2.8.
To fix this you should first check which version of Gerrit your server is running, and then make sure you've built the plugin against the API with the corresponding version.
I followed the instruction and ended up compiling the plugin with both changes submitted in here: https://github.com/vadims/gerrit-owners/issues/6 (look for the 2 forked repo) and it did work.
It was painful but the plugin does an awesome job so worth the effort!

Tomcat can't start the app because it can't find JSONRPC2ParseException class

I have application in /var/lib/tomcat7/webapps/code I have init.java file that use json-rpc-2.0
I compile it using:
export CLASSPATH=$CLASSPATH:/path/jsonrpc2-base-1.35.jar:/path/json-smart-1.2.jar
javac init.java
it compile but when I run the app (not the servlet) I got error 404 from Tomcat and in catalina.out file there is exception:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngin
e[Catalina].StandardHost[localhost].StandardContext[/code]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig
.java:1673)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: com/thetransactioncompany/jsonrpc2/JSONRPC2ParseException
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2387)
at java.lang.Class.getDeclaredFields(Class.java:1796)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Caused by: java.lang.ClassNotFoundException: com.thetransactioncompany.jsonrpc2.JSONRPC2ParseException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more
with caused by not found com/thetransactioncompany/jsonrpc2/JSONRPC2ParseException which is in jar file.
What's happening here? How can I fix it to make it work?
This is usually the jar files are not available for Tomcat.
The best way to solve this is place the json-rpc-2.0 jar files into your Tomcat's lib folder
Update
As specified by A4L user , you can also put the jar in your web applications WEB-INF/lib as well.

Can not debug java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions

I am trying to make an applet for uploading files to openstack swift using jclouds.
And I am facing the NoClassDefFoundError, following is the stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions
at org.nnsoft.guice.rocoto.configuration.ConfigurationModule.configure(ConfigurationModule.java:64)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.spi.Elements.getElements(Elements.java:92)
at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:52)
at org.nnsoft.guice.rocoto.Rocoto.expandVariables(Rocoto.java:47)
at org.jclouds.config.BindPropertiesToExpandedValues.configure(BindPropertiesToExpandedValues.java:47)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at org.jclouds.ContextBuilder.expandProperties(ContextBuilder.java:385)
at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:320)
at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:620)
at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:600)
at com.cdac.appletclass.Test.main(Test.java:56)
Caused by: java.lang.ClassNotFoundException: com.google.inject.internal.util.$Preconditions
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 21 more
I googled for com/google/inject/internal/util/$Preconditions, and came to know that it is part of guice-3.0.jar.
But guice-3.0.jar is already there in my project.
How to debug then? any help..???
I suggest printing out what's on your classpath from within your app (see this answer). That way you'll know exactly what classpath your app is using, if there's anything missing or any collisions.
Problem is solved now.
It was a mistake between guice 3.0 and guice-3.0.0, because both are having the same maven artifact-id but group-id was different.
Open the property of your project and add a dependency library.

Categories