can't run a java code with owlapi - owl-api

i'm new to owlapi and i'm trying to write a sample java code on debian to load an ontology that i already built using protégé. I'm using "owlapi-osgidistribution-4.0.2.jar", but i always get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
at org.semanticweb.owlapi.vocab.OWLFacet.<init>(OWLFacet.java:87)
at org.semanticweb.owlapi.vocab.OWLFacet.<clinit>(OWLFacet.java:60)
at org.semanticweb.owlapi.vocab.OWL2Datatype$Category.<clinit>(OWL2Datatype.java:328)
at org.semanticweb.owlapi.vocab.OWL2Datatype.<clinit>(OWL2Datatype.java:74)
at uk.ac.manchester.cs.owl.owlapi.InternalsNoCache.<clinit>(InternalsNoCache.java:59)
at uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl.<init>(OWLDataFactoryImpl.java:128)
at uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl.<clinit>(OWLDataFactoryImpl.java:74)
at org.semanticweb.owlapi.apibinding.OWLManager.getOWLDataFactory(OWLManager.java:152)
at org.semanticweb.owlapi.apibinding.OWLManager.createOWLOntologyManager(OWLManager.java:113)
at LoadingOntologies.main(LoadingOntologies.java:22)
Caused by: java.lang.ClassNotFoundException: com.google.common.cache.CacheLoader
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)
... 10 more
i tried to use maven for dependency but in vain.
can anyone tell me how to solve this problem please, thanks.

You're missing the guava jars. For OWLAPI 4.0.2, you also need all other jars included in the maven dependencies. If you could not use Maven to build your code, you'll need to make sure all the dependencies are added manually.
Can you describe what you have tried with Maven, and what errors you got?

In my opinion the best way to get all the dependencies is via Maven. Locating JARs manually takes too much time.
<dependencies>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>

Related

Apache Flink - ClassNotFoundException : org.apache.flink.configuration.DescribedEnum

When I run my Apache Flink app via Intellij, I see this error at runtime (at compile compile-time, there are no errors):
Caused by: java.lang.ClassNotFoundException: org.apache.flink.configuration.DescribedEnum
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
This is what I've listed in my pom.xml
<scala.version>2.12.8</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<flink.version>1.13.5</flink.version>
...
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
I I went to the following link for the source: https://flink.apache.org/downloads.html
wget https://archive.apache.org/dist/flink/flink-1.13.5/flink-1.13.5-src.tgz
The application (via Intellij) is unable to locate the DescribedEnum class.
I have tried adding some other dependencies, but I'm not sure which jar this is in.
Any thoughts?
You don't seem to have the basic dependency flink-streaming-java_${scala.binary.version} listed in your POM. See https://nightlies.apache.org/flink/flink-docs-release-1.13/docs/dev/datastream/project-configuration/ for more details.

Flink classloader falis when deploy the Job in cluster

I am observing a very strange behavior in flink job deployment.
When I run the Job in eclipse. It runs the job without any issues.
When I run the same job in Flink cluster it fails. I am using the following command to run the job.
./flink run --class FlinkKafkaExample flink-streaming-confluent-1.0-SNAPSHOT-all.jar --inputTopic1 sample-data-topic1 --inputTopic2 sample-data-topic2 --env example.properties
I am getting the following error.
java.lang.NoClassDefFoundError: org/apache/avro/generic/GenericData$Array
at org.apache.flink.formats.avro.utils.AvroKryoSerializerUtils.addAvroGenericDataArrayRegistration(AvroKryoSerializerUtils.java:64)
at org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer.buildKryoRegistrations(KryoSerializer.java:564)
at org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer.<init>(KryoSerializer.java:132)
at org.apache.flink.api.java.typeutils.GenericTypeInfo.createSerializer(GenericTypeInfo.java:90)
at org.apache.flink.streaming.api.graph.StreamGraph.addOperator(StreamGraph.java:202)
at org.apache.flink.streaming.api.graph.StreamGraph.addSource(StreamGraph.java:170)
at org.apache.flink.streaming.api.graph.StreamGraphGenerator.transformSource(StreamGraphGenerator.java:470)
at org.apache.flink.streaming.api.graph.StreamGraphGenerator.transform(StreamGraphGenerator.java:170)
at org.apache.flink.streaming.api.graph.StreamGraphGenerator.transformOneInputTransform(StreamGraphGenerator.java:527)
at org.apache.flink.streaming.api.graph.StreamGraphGenerator.transform(StreamGraphGenerator.java:166)
at org.apache.flink.streaming.api.graph.StreamGraphGenerator.generateInternal(StreamGraphGenerator.java:132)
at org.apache.flink.streaming.api.graph.StreamGraphGenerator.generate(StreamGraphGenerator.java:124)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:1538)
at org.apache.flink.streaming.api.environment.StreamContextEnvironment.execute(StreamContextEnvironment.java:53)
at FlinkKafkaExample.main(FlinkKafkaExample.java:127)
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.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:528)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:420)
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:404)
at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:781)
at org.apache.flink.client.cli.CliFrontend.runProgram(CliFrontend.java:275)
at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:210)
at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1020)
at org.apache.flink.client.cli.CliFrontend.lambda$main$9(CliFrontend.java:1096)
at org.apache.flink.runtime.security.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30)
at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1096)
Caused by: java.lang.ClassNotFoundException: org.apache.avro.generic.GenericData$Array
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 more
When I check the dependencies required for the Jar its available in the classpath. I have even tried adding the same jar in the lib folder of flink 1.5.0
Dependency its looking for is as shown below:
<!-- https://mvnrepository.com/artifact/org.apache.flink/flink-avro -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-avro</artifactId>
<version>1.5.0</version>
</dependency>

error on using Model model = ModelFactory.createDefaultModel(); [duplicate]

I am getting the error as mentioned below, while running the feed utility. I am trying to load an image "logo.png". The slf4j jar file is also available in the runtime classpath. But still I am getting this error.
Oct 16, 2012 7:34:11 PM com.ibm.commerce.foundation.dataload.FeedRetriever invokeDataLoad
SEVERE: An error occurred while performing data load.
Throwable occurred: com.ibm.commerce.foundation.dataload.exception.DataLoadException:
An error occurred while executing the data load.
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at com.ibm.commerce.foundation.dataload.DataLoaderMain.execute(DataLoaderMain.java:664)
at com.ibm.commerce.content.commands.DataLoadInvoker.execute(DataLoadInvoker.java:101)
at com.ibm.commerce.foundation.dataload.FeedRetriever.invokeDataLoad(FeedRetriever.java:244)
at com.ibm.commerce.foundation.dataload.FeedRetriever.execute(FeedRetriever.java:172)
at com.ibm.commerce.foundation.dataload.FeedRetriever.main(FeedRetriever.java:321)
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at com.ibm.commerce.foundation.dataload.DataLoaderMain.execute(DataLoaderMain.java:488)
... 4 more
Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at org.apache.wink.client.ClientConfig.<clinit>(ClientConfig.java:52)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at com.ibm.commerce.foundation.dataload.feedreader.AtomReader.getFeed(AtomReader.java:104)
at com.ibm.commerce.foundation.dataload.feedreader.AtomReader.getEntries(AtomReader.java:147)
at com.ibm.commerce.foundation.dataload.feedreader.AtomReader.getEntries(AtomReader.java:1)
at com.ibm.commerce.foundation.dataload.feedreader.BaseFeedReader.init(BaseFeedReader.java:252)
at com.ibm.commerce.foundation.dataload.AbstractBusinessObjectLoader.initializeDataReaders(AbstractBusinessObjectLoader.java:1344)
at com.ibm.commerce.foundation.dataload.AbstractBusinessObjectLoader.init(AbstractBusinessObjectLoader.java:369)
at com.ibm.commerce.foundation.dataload.BusinessObjectLoader.init(BusinessObjectLoader.java:65)
at com.ibm.commerce.foundation.dataload.DataLoaderMain.execute(DataLoaderMain.java:431)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.lang.ClassNotFoundException.<init>(ClassNotFoundException.java:76)
at java.net.URLClassLoader.findClass(URLClassLoader.java:396)
at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
... 16 more
Oct 16, 2012 7:34:11 PM com.ibm.commerce.foundation.dataload.FeedRetriever main
SEVERE: An error occurred while performing data load.
Throwable occurred: com.ibm.commerce.foundation.dataload.exception.DataLoadException: An error has occurred. If this problem persists, contact product support.
at com.ibm.commerce.foundation.dataload.FeedRetriever.invokeDataLoad(FeedRetriever.java:247)
at com.ibm.commerce.foundation.dataload.FeedRetriever.execute(FeedRetriever.java:172)
at com.ibm.commerce.foundation.dataload.FeedRetriever.main(FeedRetriever.java:321)
Add a SLF4J implementation (as you only have its API):
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
</dependency>
You have to provide one of the various SLF4J implementation .jar files in the classpath, as well as the interface .jar file. This is documented.
Download slf4j-1.7.5.zip
It holds different jar files.
Go to -> Integration folder after extracting zip and include following jar files
slf4j-api-2.0.99
slf4j-simple-1.6.99
junit-3.8.1
Right click on project properties and follow below steps Project Properties" --> "Deployment Assembly", adding "Java Build Path Entries -> Maven Dependencies
I tried other solutions and the exception didn't go away. So I decompiled the entire jose4j 0.6.5 jar with a Java Decomplier and look at its pom.xml.
I realised it has a specific dependency on slf4j-api, version 1.7.21:
So in my project's pom.xml, I added the exact same dependency, updated my Maven project so that it downloads this jar into my repository and the exception was gone.
However it may bring up another error caused by slf4j itself:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
To overcome this issue, I added the following into my project's pom.xml. So altogether you need to add the following to your pom.xml and my jose4j ran without anymore issues:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
</dependency>
Remember to update your Maven project after amending your pom.xml.
(Right-click Project folder in Eclipse -> Maven -> Update Project..)
I also had the similar problem. I had a maven project and was testing rabbitmq. Firstly it showed me the similar error then I added all the SLF4J dependencies in the maven project and then error changed to "Maven SLF4J: Class path contains multiple SLF4J bindings". Here is the complete list of dependencies from pom.xlm
<dependencies>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
<scope>compile</scope>
</dependency>
</dependencies>
It worked finally.
I was facing a similar issue and below line fixed the issue for me.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
Edit: I realized that I was using spring boot and the version of the dependency was getting pulled from spring-boot-starter-parent.
To be more specific if you are missing the class com.vaadin.external.org.slf4j.LoggerFactory add the below dependency.
<dependency>
<groupId>com.vaadin.external.slf4j</groupId>
<artifactId>vaadin-slf4j-jdk14</artifactId>
<version>1.6.1</version>
</dependency>
If you are missing any other org.slf4j.LoggerFactory, just go to Maven central class name search and search for the exact class name to determine what exact dependency you are missing.
You can use bellow dependency
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
Add the following jars to the class path or lib folder
slf4j-api-1.7.2.jar
slf4j-jdk14-1.7.2.jar
The perfect solution which works undoubtedly is to just add these packages to your app:
https://mvnrepository.com/artifact/org.slf4j/slf4j-api/1.7.2
http://archive.apache.org/dist/logging/log4j/1.2.16/
after adding so you may encounter following WARNING which you can simply ignore!
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
credits:
https://www.javacodegeeks.com/2018/02/fix-exception-thread-main-java-lang-noclassdeffounderror-org-slf4j-loggerfactory-java.html
This error occurs because of referenced jars are not checked in our project's order and export tab.
Choose Project ->ALT+Enter->Java Build Path ->Order and Export->check necessary jar files into your project.
Finally clean your project and run.It will run successfully.
When we use the slf4j api jar, we need any of the logger implementations like log4j. On my system, we have the complete set and it works fine.
1. slf4j-api-1.5.6.jar
2. slf4j-log4j12-1.5.6.jar
3. **log4j-1.2.15.jar**
I believe the answer is outlined on the slf4j web-site (Failed to load class org.slf4j.impl.StaticLoggerBinder)
For a very quick solution I suggest adding no-operation (NOP) logger implementation (slf4j-nop.jar)
For example, if using maven:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j-nop-version}</version>
</dependency>
I have the same issue for zookeeper start up.
# sh /opt/zookeeper-3.4.13-1.hardtop.0.9.1/bin/zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.13-1.hardtop.0.9.1/bin/../conf/zoo.cfg
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.zookeeper.server.quorum.QuorumPeerMain.<clinit>(QuorumPeerMain.java:67)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 1 more
But the class is already there as part of other slf4j jars:
# grep LoggerFactory lib/*jar
Binary file lib/log4j-1.2-api-2.17.1.jar matches
Binary file lib/log4j-slf4j-impl-2.17.1.jar matches
Binary file lib/netty-all-4.1.30.Final.jar matches
make sure your MANIFEST.MF contains the name of the referenced jar in my application was slf4j-api-*. jar.
You need slf4j-api library. For most cases only slf4j-api and slf4j-jkd14 are only required:
Here you can download the version 1.7.2:
slf4j-api-1.7.2.jar
slf4j-jkd14-1.7.2jar
If you need an example to see how these are used, refers to this tutorial:
http://www.ibm.com/developerworks/java/library/j-hangman-app/index.html
All the code for the tutorial is available
get the compatible version of this jar slf4j-jdk14 and add it as a dependency.
this solved the problem for me.
You need slf4j-api library and slf4j-log4j12-1.7.25 jar. Copy this jars in your project-> WEBINF-> lib folder and in tomcat server lib folder to execute successfully.
When you copy dependency from maven repository there is:
<scope>test</scope>
Try to remove it from dependencies in pom.xml like this.
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
This works for me. I hope it would be helpful for someone else.
this worked for me /properties/maven uncheck resolve dependencies from Workspace projects.
First, check the dependency hierarchy than to exclude all slf4j jars from other dependencies and add separate slf4j as dependencies.
If it is not maven project then make sure the jar file is inside the project folder. If it is a maven project then make sure it's in the pom.xml.
use maven it will download all the required jar files for you.
in this case you need the below jar files:
slf4j-log4j12-1.6.1.jar
slf4j-api-1.6.1.jar
These jars will also depend on the cassandra version which you are running.
There are dependencies with cassandra version , jar version and jdk version you use.
You can use : jdk1.6
with : cassandra 1.1.12
and the above jars.
If you are facing java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
Add slf4j-log4j12 jar in the library folder of the project
The LoggerFactory class is msising according to the error message:
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
Apparently, the slf4j.jar file is not getting loaded for some reason.

Component camel-jsonpath gives error after adding to pom file

In a clean Camel project I add the following dependency:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jsonpath</artifactId>
<version>2.16.1</version>
</dependency>
When I run the project I get the below error. If I remove that dependency it works. I have tried this on two different projects and the same happens. Anything else that has to be added to the pom for jsonpath to work? It seems to complain for ASM?
[INFO] Using org.apache.camel.test.blueprint.Main to initiate a CamelContext
[INFO] Starting Camel ...
[mel.test.blueprint.Main.main()] Activator INFO Camel activator starting
[mel.test.blueprint.Main.main()] Activator INFO Camel activator started
[ Blueprint Extender: 1] BlueprintContainerImpl INFO Bundle INT001_GetPostcodeDataFromXXX/0.0.1.SNAPSHOT is waiting for namespace handlers [http://camel.apache.org/schema/blueprint]
EventDispatcher: Error during dispatch.
EventDispatcher: Error during dispatch.
EventDispatcher: Error during dispatch.
EventDispatcher: Error during dispatch.
EventDispatcher: Error during dispatch.
org.osgi.framework.ServiceException: Service factory exception: org/objectweb/asm/commons/AdviceAdapter
at org.apache.felix.connect.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:246)
at org.apache.felix.connect.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:178)
at org.apache.felix.connect.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:323)
at org.apache.felix.connect.PojoSRBundleContext.getService(PojoSRBundleContext.java:162)
at org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl.addingService(NamespaceHandlerRegistryImpl.java:113)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894)
at org.apache.felix.connect.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:852)
at org.apache.felix.connect.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:775)
at org.apache.felix.connect.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:594)
at org.apache.felix.connect.PojoSR$1.serviceChanged(PojoSR.java:78)
at org.apache.felix.connect.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:130)
at org.apache.felix.connect.PojoSRBundleContext.registerService(PojoSRBundleContext.java:101)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:453)
at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:193)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:704)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:379)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/commons/AdviceAdapter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.aries.proxy.impl.interfaces.ProxyClassLoader.createProxyClass(ProxyClassLoader.java:146)
at org.apache.aries.proxy.impl.interfaces.InterfaceProxyGenerator.getProxyInstance(InterfaceProxyGenerator.java:95)
at org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:80)
at org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingInterceptingProxy(AbstractProxyManager.java:75)
at org.apache.aries.proxy.impl.AbstractProxyManager.createInterceptingProxy(AbstractProxyManager.java:53)
at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:569)
at org.apache.felix.connect.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:242)
... 31 more
Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.commons.AdviceAdapter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 49 more
org.osgi.framework.ServiceException: Service factory exception: org/objectweb/asm/commons/AdviceAdapter
at org.apache.felix.connect.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:246)
at org.apache.felix.connect.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:178)
at org.apache.felix.connect.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:323)
at org.apache.felix.connect.PojoSRBundleContext.getService(PojoSRBundleContext.java:162)
at org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl.addingService(NamespaceHandlerRegistryImpl.java:113)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894)
at org.apache.felix.connect.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:852)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/commons/AdviceAdapter
Edit:
After adding:
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>5.0.3</version>
<scope>runtime</scope>
</dependency>
It worked but doubt this is the correct way. The camel-component should get all the dependent jars.
I posted this on the Camel nabble forum and indeed it seems you need to add the asm dependency to get it to work.
http://camel.465427.n5.nabble.com/Error-with-Camel-component-camel-jsonpath-td5777201.html
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>5.0.3</version>
<scope>runtime</scope>
</dependency>
the pom.xml are about compile-time dependencies. You have a runtime error about a missing dependency (org.objectweb.asm). You should add it to your container.
In your stack traces : a new service is registered in a blueprint context. this service is then injected in another blueprint context. for this service, the blueprint container want to wrap it in a new proxy, and to create this kind of proxy, aries blueprint need org.objectweb.asm. i don't think this error is directly related to camel-jsonpath.
In my case, back when asm-commons with version 5.0.3 was used, I was still getting some error. As an altetrnative to previous answer, asm-all artifact can be used instead, since it includes other dependencies that in my scenario were breaking otherwise.
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-all</artifactId>
<scope>runtime</scope>
</dependency>
However, regarding deployment, it seems quite impossible to integrate the project using this dependency to Fabric8 (no errors on console log and containers do not start), so not sure if there is a better alternative with a sort of camel-jsonpath feature.
Hope it helps someone.

java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.ChartFactory

i have one problem since 2 days and I don't understand what happened. I have a page that catching an exception on a new server. In fact, we passed from a jdk 1.6 server to a jdk 1.7 server. On the jdk 1.6 everything was working good, but with the new server the generation of graphs with JFreeChart fail with the following error :
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.ChartFactory at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:294) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xxx.LogFilter.doFilter(LogFilter.java:48) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.xxx.filters.EncodingFilter.doFilter(EncodingFilter.java:32) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563) at org.ow2.jonas.web.tomcat6.CheckOpenResourcesValve.invoke(CheckOpenResourcesValve.java:73) at org.ow2.jonas.web.tomcat6.tx.TransactionValve.invoke(TransactionValve.java:90) at org.ow2.jonas.web.tomcat6.ResetAuthenticationValve.invoke(ResetAuthenticationValve.java:88) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.ChartFactory at com.xxx.VisitorHelper.createTotalChart(VisitorHelper.java:147) at
I can't reproduce the bug on my local environment. I saw on other topics that the jvm option"-Djava.awt.headless=true" resolve the problem but it's not my case...
Moreover, I can see the jfreechart-1.0.12.jar file on the WEB-INF repository of my ear which is declare on the pom.xml like this :
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.12</version>
</dependency>
I can only see a difference between the jdk-s on the two servers.
Could be a compatibility problem. The groupId of jfree has changed since 2011. Try using the current jfreechart version:
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
If the jar is really in your classpath, the problem maybe it is caused by a bug in your IDE. Clear the cache would resolve it.
The path change according your IDE.
This could help
How to clear the Cache in NetBeans
Finally I resolved my problem. It was missing a lib on my server, I added it doing "yum install cups-libs".
Now my code is working well :)

Resources