why I am getting java.lang.ClassNotFoundException:com.google.api.client.json.JsonFactory when running on OSGi framework - osgi

I am new to OSGi and I made a method which will call the Google translate API. When I called that method in a main it is working fine. And also I used Eclipse for coding and exported the project into a jar file from Eclipse and installed it on the apache felix framework. When I start the bundle I get the following exceptions,
I added all the external jar files to build path also.
org.osgi.framework.BundleException: Activator start error in bundle EnglishToSinhalaServicePublisher [58].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2452)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.gogo.command.Basic.start(Basic.java:739)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:139)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
at englishtosinhalaservicepublisher.Activator.start(Activator.java:46)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:698)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2402)
... 19 more
Caused by: java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory not found by EnglishToSinhalaServicePublisher [58]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1597)
at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 22 more
java.lang.NoClassDefFoundError: com/google/api/client/json/JsonFactory
g!

Related

Eclipse Plugin java.lang.NoClassDefFoundError

Hello I have problem with my plugin application with Java 8.
I am getting this output:
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.osgi.internal.messages.Msg
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.WebStartMain.basicRun(WebStartMain.java:79)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.WebStartMain.main(WebStartMain.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Required OSGI plugin is attached. I see this class in package but My application can't see It in runtime. I have tried to manipulate with MANIFEST of my project but without success. Do You have any ideas What could be the reason of this error?
Probably important info is that Application is launching via Eclipse Neon 3 but when I am trying to run It via commandline javaws It fails.

start up tomcat error in My Eclipse Blue 2014

I am trying to configure Tomcat 7 in My Eclipse Blue ans run it alone. I am getting the error in console as:
java.lang.NoClassDefFoundError: org/apache/tomcat/util/digester/Rule
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:220)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:406)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.digester.Rule
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
How can I resolve this error?

JBoss Wildfly ClassLoader Issue

I am suffering from a weird problem. When I deploy my application in wildfly it runs perfectly. After a while, I start getting exceptions of type
interface xxxxxxxxx is not visible from class loader.
The staketrace is as follow:
Error Message: java.lang.IllegalArgumentException: interface oracle.ucp.jdbc.ConnectionWithTimeToLiveTimeout is not visible from class loader
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Unknown Source)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Unknown Source)
at java.lang.reflect.WeakCache$Factory.get(Unknown Source)
at java.lang.reflect.WeakCache.get(Unknown Source)
at java.lang.reflect.Proxy.getProxyClass0(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at oracle.ucp.jdbc.proxy.ConnectionProxyFactory.createConnectionProxy(ConnectionProxyFactory.java:79)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1046)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)
at com.spider.addon.DBPoolManager.borrowConnection(DBPoolManager.java:79)
at com.spider.addon.DBManager.execute(DBManager.java:55)
at com.spider.beans.OCGWServices.finalize(OCGWServices.java:55)
at java.lang.System$2.invokeFinalize(Unknown Source)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
java.lang.IllegalArgumentException: interface oracle.ucp.jdbc.ConnectionWithTimeToLiveTimeout is not visible from class loader
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Unknown Source)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Unknown Source)
at java.lang.reflect.WeakCache$Factory.get(Unknown Source)
at java.lang.reflect.WeakCache.get(Unknown Source)
at java.lang.reflect.Proxy.getProxyClass0(Unknown Source)
at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
at oracle.ucp.jdbc.proxy.ConnectionProxyFactory.createConnectionProxy(ConnectionProxyFactory.java:79)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1046)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)
at com.spider.addon.DBPoolManager.borrowConnection(DBPoolManager.java:79)
at com.spider.addon.DBManager.execute(DBManager.java:55)
at com.spider.beans.OCGWServices.finalize(OCGWServices.java:55)
at java.lang.System$2.invokeFinalize(Unknown Source)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
If the problem is in the JDBC driver, include it as a module in wildfly.
Usually i lost jdbc-4 driver loaded in wildfly as a deployment.
Now I put the jdbc driver as a module in wildfly, so the dependencies are shared in all the ear/war that include this dependency.
try this link

Runnable JAR file error: Unsupported major.minor version 51.0

I made an application in Java (version 7) with Eclipse (Indigo) when I exported my application interface on a Runnable JAR file on my computer and tried it worked fine, then I tried on another computer and I get this problem
Exception in thread "main" java.lang.UnsupportedClassVersionError: cliente/Princ
ipal : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:56)
I saw other post that this can be because the other computer have an older version of Java than mine, can somebody confirm this please?.
Yes, that is the error when you try to run Java bytecode with an older version that the version you build it with.
You will find more information in this question.

Signing jar created with onejar-maven-plugin throwing stackoverflow exception

I have a jar which is created using onejar-maven-plugin, which is meant to listen to jms messages from tibco and process accordingly. It works fine but when I sign this jar using jarsigner and try to run it, it throws the exception below:
org.apache.commons.logging.LogConfigurationException: java.lang.StackOverflowError (Caused by java.lang.StackOverflowError)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:538)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:160)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:89)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.adobe.jobcloud.envoy.client.PushToPrereleaseWorker.main(PushToPrereleaseWorker.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.StackOverflowError
at com.simontuffs.onejar.OneJarFile.getJarEntry(OneJarFile.java:43)
at java.util.jar.JarFile.getManEntry(Unknown Source)
at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
at java.util.jar.JarFile.getManifest(Unknown Source)
at java.util.jar.JarFile.maybeInstantiateVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at com.simontuffs.onejar.OneJarFile.getJarEntry(OneJarFile.java:50)
at java.util.jar.JarFile.getManEntry(Unknown Source)
at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
at java.util.jar.JarFile.getManifest(Unknown Source)
at java.util.jar.JarFile.maybeInstantiateVerifier(Unknown Source)
at java.util.jar.JarFile.getInputStream(Unknown Source)
at com.simontuffs.onejar.OneJarFile.getJarEntry(OneJarFile.java:50)
at java.util.jar.JarFile.getManEntry(Unknown Source)
at java.util.jar.JarFile.getManifestFromReference(Unknown Source)
at java.util.jar.JarFile.getManifest(Unknown Source)
Also if I use maven-jarsigner-plugin to sign it, the result is exactly same. I'm clueless and stuck up with this issue.
Any help will be appreciated.
Have you tried to increase the -Xss JVM option? To 4096k at first, then lower it until it fails again.
Working with ciphers generally maybe need more than default stack size.
For the maven jarsigner plugin you can edit .mavenrc file in your linux home directory and add these lines:
#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/java-6-sun-i586 #(or another)
export M2_HOME=/usr/local/lib/apache-maven/apache-maven-3.0.4
export MAVEN_OPTS="-Xss4096k -XX:MaxPermSize=128m -Xmx384m"
I don't know how to do this under windows, but there must be similar solution (here?)

Resources