java.lang.ClassNotFoundException error
rogelio_sevilla1 Jul 22, 2011 6:59 PMGood day to everyone:
I've already made this question on the camel forum but i think this is the right place to ask because of its nature (more fuse than camel).
I have 2 osgi bundles installed on fuse esb 4.4, bundle #1 has a camel route and a simple pojo, bundle #2 has a simple pojo that takes the camel route on bundle #1 and instantiates it.
The deployment of the bundle #1 works pretty well, this is the route i have:
getContext().setHandleFault(true);
errorHandler(deadLetterChannel("file:data/log/capalerts")
.maximumRedeliveries(2)
.asyncDelayedRedelivery()
.redeliveryDelay(3000)
.useOriginalMessage()
.logStackTrace(true)
.logRetryStackTrace(true)
.retryAttemptedLogLevel(LoggingLevel.ERROR));
from("quartz://fetchUrl?cron=00/1+*?")
.bean(MyPojo.class,"getHtmlCode")
.wireTap("seda:auditorfeed")
.bean(MyPojo.class.class,"gettUrls")
.wireTap("seda:urlauditor")
.split(body(String.class).tokenize("\n"))
.to("seda:finaldest");
As you can see, i'm using a class called MyPojo.class inside my route. this class is also deployed with the camel route on the same package inside bundle #1, by the way, every package on this bundle is exported through the pom file.
After deploying it, i try to deploy bundle #2 which have a class with only 1 method:
public void init(){
MyRoute myroute = new MyRoute();
BundleContext bundleContext = Activator.getBundleContext();
CamelContextFactory camelContextFactory = new CamelContextFactory();
camelContextFactory.setBundleContext(bundleContext);
DefaultCamelContext defaultContext = camelContextFactory.createContext();
defaultContext.addRoutes(miruta);
defaultContext.start();
}
The moment i install and try to start the bundle #2, i get this exception:
ERROR | rint Extender: 1 | BlueprintContainerImpl | 10 - org.apache.aries.blueprint - 0.3.1 | Unable to start blueprint container for bundle my_routes_factory
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to intialize bean MyRoutesFactory
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:638)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:724)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:640)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:331)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)[10:org.apache.aries.blueprint:0.3.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_25]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_25]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_25]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_25]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_25]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route5 at: >>> Bean[com.mycompany.my_main_route.MyPojo.class] <<< in route: Route[[From[quartz://fetchUrl?cron=00/1**+?]] -> [Bean[... because of java.lang.ClassNotFoundException: com.mycompany.my_main_route.MyPojo.class
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:818)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:708)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1650)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1439)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1338)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1316)
at com.my_company.my_route_factory.MyRouteFactory.init(MyRouteFactory.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_25]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_25]
at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:226)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:824)[10:org.apache.aries.blueprint:0.3.1]
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:636)[10:org.apache.aries.blueprint:0.3.1]
... 15 more
Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassNotFoundException: com.mycompany.my_main_route.MiPojo
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1139)
at org.apache.camel.model.BeanDefinition.createProcessor(BeanDefinition.java:164)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:433)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:815)
... 31 more
Caused by: java.lang.ClassNotFoundException: com.flytecomm.noaa_atom_feed_consumer.AtomFeedMessageConversorBean
at org.apache.camel.impl.DefaultClassResolver.resolveMandatoryClass(DefaultClassResolver.java:52)
at org.apache.camel.model.BeanDefinition.createProcessor(BeanDefinition.java:162)
... 34 more
According to this, camel cannot find the class com.mycompany.my_main_route.MyPojo.class , but i really don't understand why, because i'm already exporting it. If i execute command osgi:header on the bundle that instantiates the camel route, this is the result:
Manifest-Version = 1.0
Bnd-LastModified = 1311372596591
Tool = Bnd-1.15.0
Built-By = rogeliosevilla1
Build-Jdk = 1.6.0_26
Created-By = Apache Maven Bundle Plugin
Bundle-Name = My Route Factory
Bundle-SymbolicName = my_route_factory
Bundle-Version = 1.0.0.SNAPSHOT
Bundle-ManifestVersion = 2
Import-Package =
com.mycompany.my_main_route,
org.apache.camel;version="[2.7,3)",
org.apache.camel.builder;version="[2.7,3)",
org.apache.camel.impl;version="[2.7,3)",
org.apache.camel.osgi;version="[2.7,3)",
After that,executing the command
packages:exports | grep mycompany
y get this:
246 com.mycompany.my_main_route; version=0.0.0
247 com.mycompany.my_saver_bundle; version=0.0.0
248 com.mycompany.my_route_factory; version=0.0.0
As you can see it is stated on my bundle that the package should be imported, also, according th the packages:exports command, the package is exported.. but still, i keep getting the same error :-S , i'm honestly lost in here.
Any advice would be really appreciated.
Thanks a lot in advance.