Hi Charles
Done, I added the comments for the ContextClassLoader setting codes.
Please feel free to apply patch if you find any thing wrong.
Cheers,
Willem
Charles Moulliard wrote:
> Yes. But I need after that to create a patch because I don't have WRITE
> access to SVN now.
>
> Otherwise, we have added this code in the class QuickFixInitiator &
> QuickFixAcceptor
> :
> ClassLoader ccl =
> Thread.currentThread().getContextClassLoader();
> try {
>
> Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
>
> acceptor = new SocketAcceptor(application, storeFactory,
> settings, logFactory,
> new DefaultMessageFactory());
>
> acceptor.start();
> } finally {
> Thread.currentThread().setContextClassLoader(ccl);
> }
>
> to solution the classloading issue raised by the class
> quickfix.DefaultMessageFactory
>
> s...@root:osgi> Exception in thread "SpringOsgiExtenderThread-34"
> java.lang.NoClassDefFoundError: quickfix/fix41/MessageFactory
> at
> quickfix.DefaultMessageFactory.<init>(DefaultMessageFactory.java:30)
> at
> org.apache.camel.component.quickfix.QuickfixAcceptor$QuickfixAcceptorEndpoint.start(QuickfixAcceptor.java:62)
> at
> org.apache.camel.component.quickfix.QuickfixEndpoint.start(QuickfixEndpoint.java:179)
>
> see here : http://www.eclipsezone.com/eclipse/forums/t61831.html and here
> for more info
> http://mail-archives.apache.org/mod_mbox/felix-users/200803.mbox/%[email protected]%3e
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Thu, May 7, 2009 at 10:32 AM, Willem Jiang <[email protected]>wrote:
>
>> Hi Charles,
>>
>> Just a quick question for your change of camel-quickfix?
>> Can you add some comments on
>> "Thread.currentThread().setContextClassLoader added in quickFixAcceptor
>> and Initiator"
>>
>> Willem
>>
>> Charles Moulliard wrote:
>>> Hi Willem,
>>>
>>> I haven't deploy mina and it works in my OSGI environment. I will deploy
>> the
>>> mina-core as you propose and see the result.
>>>
>>> BTW, the current code is not yet ready to be used. Modifications must be
>>> done concerning logging strategy, .... and probably about how we can
>> receive
>>> FIX messages. Why, the current quickfix package is able to connect to a
>> FIX
>>> server and exchange messages but the messages received are converted into
>>> quickfix.FIX40 java classes. *I prefer that the user can choose the
>>> dataformat he would like to use (by default can be String (= FIX
>> content),
>>> quickfix.FIX4x, BindyDataFormat, ....)*. How it is another question
>> because
>>> I'm quite sure that we need to modify quickfix package. I have tried to
>>> contact quickfix team but it is for moment "---------". As quickfix is
>> also
>>> used by third parties companies providing billable support including
>>> resources of the project !
>>>
>>> Regards,
>>>
>>> Charles Moulliard
>>> Senior Enterprise Architect
>>> Apache Camel Committer
>>>
>>> *****************************
>>> blog : http://cmoulliard.blogspot.com
>>>
>>>
>>> On Wed, May 6, 2009 at 6:04 PM, Willem Jiang <[email protected]>
>> wrote:
>>>> Hi Charles
>>>>
>>>> After changed the pom.xml to make camel-quickfix component as bundle, I
>>>> managed to load it in Pax-Exam.
>>>> BTW, you need to wrap the quickfix and mina-core jars.
>>>>
>>>>
>>>>
>> wrappedBundle(mavenBundle().groupId("org.quickfixj").artifactId("quickfixj-all").version("1.4.0")),
>>>>
>>>>
>> wrappedBundle(mavenBundle().groupId("org.apache.mina").artifactId("mina-core").version("1.1.7")),
>>>>
>>>> Willem
>>>>
>>>>
>>>> Charles Moulliard wrote:
>>>>> Hi,
>>>>>
>>>>> I will first check the code in order to be able to run it in Camel with
>>>>> quickfix/j (it seems that there is a classloading issue inside
>>>> quickfix/j,
>>>>> ...) and deploy it in OSGI server.
>>>>> After, I will check why there is an issue with the XML file, ....
>>>>>
>>>>> Regards
>>>>>
>>>>> Charles Moulliard
>>>>> Senior Enterprise Architect
>>>>> Apache Camel Committer
>>>>>
>>>>> *****************************
>>>>> blog : http://cmoulliard.blogspot.com
>>>>>
>>>>>
>>>>> On Wed, May 6, 2009 at 6:51 AM, Willem Jiang <[email protected]>
>>>> wrote:
>>>>>> Yes, declare the component in the spring configuration file just a
>> walk
>>>>>> around solution.
>>>>>>
>>>>>> I can dig the code of quickfix resource loading later today.
>>>>>>
>>>>>> Willem
>>>>>>
>>>>>> Claus Ibsen wrote:
>>>>>>> On Tue, May 5, 2009 at 5:15 PM, Charles Moulliard <
>>>> [email protected]>
>>>>>> wrote:
>>>>>>>> With the following config, it works :
>>>>>>>>
>>>>>>>> <bean id="quickfix-server"
>>>>>>>> class="org.apache.camel.quickfix.QuickfixAcceptor"/>
>>>>>>>> <bean id="quickfix-client"
>>>>>>>> class="org.apache.camel.quickfix.QuickfixInitiator"/>
>>>>>>>>
>>>>>>>>
>>>>>>>> <camel:camelContext trace="true" xmlns="
>>>>>>>> http://camel.apache.org/schema/osgi">
>>>>>>>> <camel:route>
>>>>>>>> <camel:from
>>>>>> uri="quickfix-server:META-INF/examples/server.cfg"/>
>>>>>>>> <camel:to
>>>>>> uri="quickfix-client:META-INF/examples/client.cfg"/>
>>>>>>>> </camel:route>
>>>>>>>> </camel:camelContext>
>>>>>>>>
>>>>>>>> Any idea why we have to declare the beans ?
>>>>>>> No but its your job to dig into the code base :)
>>>>>>>
>>>>>>> I assume the code that reads the resources from the URI has a flaw.
>>>>>>> I can help with this later. The important part is to make sure the
>>>>>>> camel-quickfix component works, has the features we want and is
>>>>>>> properly tested etc.
>>>>>>>
>>>>>>> Then later we can fix the minor issues with resource loading.
>>>>>>> It should support loading in classpath, file, and OSGi :)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Charles Moulliard
>>>>>>>> Senior Enterprise Architect
>>>>>>>> Apache Camel Committer
>>>>>>>>
>>>>>>>> *****************************
>>>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, May 5, 2009 at 5:12 PM, Charles Moulliard <
>>>> [email protected]
>>>>>>> wrote:
>>>>>>>>> I have modified the spring xml file like you propose :
>>>>>>>>>
>>>>>>>>> <camel:camelContext trace="true" xmlns="
>>>>>>>>> http://camel.apache.org/schema/osgi">
>>>>>>>>> <camel:route>
>>>>>>>>> <camel:from uri="quickfix-server:examples/server.cfg"/>
>>>>>>>>> <camel:to uri="quickfix-client:examples/client.cfg"/>
>>>>>>>>> </camel:route>
>>>>>>>>> </camel:camelContext>
>>>>>>>>>
>>>>>>>>> and now we have the error :
>>>>>>>>>
>>>>>>>>> s...@root:osgi> Exception in thread "SpringOsgiExtenderThread-63"
>>>>>>>>> org.apache.camel.ResolveEndpointFailedException: Failed to resolve
>>>>>> endpoint:
>>>>>>>>> quickfix-server:examples/ser
>>>>>>>>> ver.cfg due to: java.io.FileNotFoundException: class path resource
>>>>>>>>> [examples/server.cfg] cannot be opened because it does not exist
>>>>>>>>>
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:378)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:52)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:133)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:103)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:109)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:78)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:302)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:121)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:481)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:777)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:759)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>>>>>>>> at
>>>>>>>>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:50)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:95)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:114)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationC
>>>>>>>>> ontextExecutor.java:136)
>>>>>>>>> at java.lang.Thread.run(Thread.java:619)
>>>>>>>>> *Caused by: java.io.FileNotFoundException: class path resource
>>>>>>>>> [examples/server.cfg] cannot be opened because it does not exist*
>>>>>>>>> at
>>>>>>>>>
>> org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:143)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.quickfix.QuickfixEndpoint.start(QuickfixEndpoint.java:167)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:510)
>>>>>>>>> at
>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:372)
>>>>>>>>> ... 27 more
>>>>>>>>>
>>>>>>>>> I will change the path and retest
>>>>>>>>>
>>>>>>>>> Charles Moulliard
>>>>>>>>> Senior Enterprise Architect
>>>>>>>>> Apache Camel Committer
>>>>>>>>>
>>>>>>>>> *****************************
>>>>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, May 5, 2009 at 5:08 PM, Willem Jiang <
>> [email protected]
>>>>>>> wrote:
>>>>>>>>>> Hi Charles,
>>>>>>>>>>
>>>>>>>>>> I just checked the code with the stack trace, and found this issue
>>>> may
>>>>>>>>>> caused by the java.lang.NullPointerException.
>>>>>>>>>>
>>>>>>>>>> Here is the code snippet of the OsgiComponentResolver.
>>>>>>>>>> try {
>>>>>>>>>> type = getComponent(name);
>>>>>>>>>> } catch (Throwable e) {
>>>>>>>>>> throw new IllegalArgumentException("Invalid URI, no
>>>>>>>>>> Component registered for schema : " + name, e);
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> The getComponent() method just search the bundle entry for the
>>>>>> component.
>>>>>>>>>> I have no idea why the NPE will be thrown from this getComponent()
>>>>>> method.
>>>>>>>>>> Willem
>>>>>>>>>>
>>>>>>>>>> Charles Moulliard wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I'm currently working on the new camel-quickfix component
>> provided
>>>> by
>>>>>>>>>> Anton
>>>>>>>>>>> Arhipov.
>>>>>>>>>>>
>>>>>>>>>>> I have created a camel spring xml file to use it :
>>>>>>>>>>>
>>>>>>>>>>> <camel:camelContext trace="true" xmlns="
>>>>>>>>>>> http://camel.apache.org/schema/osgi">
>>>>>>>>>>> <camel:route>
>>>>>>>>>>> <camel:from
>> uri="quickfix-server:examples/server.cfg"/>
>>>>>>>>>>> <camel:to uri="quickfix-client:examples/client.cfg"/>
>>>>>>>>>>> </camel:route>
>>>>>>>>>>> </camel:camelContext>
>>>>>>>>>>>
>>>>>>>>>>> but when the component is launched, I receive the following error
>> :
>>>>>>>>>>> 16:25:20,625 | ERROR | xtenderThread-53 | ContextLoaderListener
>>>>>>>>>> |
>>>>>>>>>>> BundleApplicationContextListener 50 | Application context
>> refresh
>>>>>>>>>> failed
>>>>>>>>>>> (OsgiBundleXmlApplicationContext(bundle=reportincident.quickfix,
>>>>>>>>>>> config=osgibundle:/META-INF/spring/*.xml))
>>>>>>>>>>> org.apache.camel.ResolveEndpointFailedException: *Failed to
>> resolve
>>>>>>>>>>> endpoint: quickfix-server:examples/server.cfg* due to:
>>>>>>>>>>> org.apache.camel.RuntimeCamelException: Could not auto create
>>>>>> component:
>>>>>>>>>>> quickfix-server
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:378)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:52)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:133)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:103)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:109)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:78)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:302)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:121)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:481)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:777)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:759)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.maybeDoStart(SpringCamelContext.java:165)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:160)
>>>>>>>>>>> at
>>>>>>>>>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:50)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:95)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:114)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
>>>>>>>>>>> at java.lang.Thread.run(Thread.java:619)
>>>>>>>>>>> Caused by: org.apache.camel.RuntimeCamelException: Could not auto
>>>>>> create
>>>>>>>>>>> component: quickfix-server
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:211)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:354)
>>>>>>>>>>> ... 27 more
>>>>>>>>>>> Caused by: java.lang.IllegalArgumentException: *Invalid URI, no
>>>>>>>>>> Component
>>>>>>>>>>> registered for scheme : quickfix-server*
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.osgi.OsgiComponentResolver.resolveComponent(OsgiComponentResolver.java:66)
>>>>>>>>>>> at
>>>>>>>>>>>
>> org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:201)
>>>>>>>>>>> ... 28 more
>>>>>>>>>>> Caused by: java.lang.NullPointerException
>>>>>>>>>>> When looking in the code provided, I see that Anton has created
>>>> under
>>>>>>>>>> the
>>>>>>>>>>> directory META-INF/services, the following files :
>>>>>>>>>>>
>>>>>>>>>>> org\apache\camel\component\quickfix-server
>>>>>>>>>>>
>>>>>>>>>>> class=org.apache.camel.quickfix.QuickfixAcceptor
>>>>>>>>>>>
>>>>>>>>>>> org\apache\camel\component\quickfix-client
>>>>>>>>>>>
>>>>>>>>>>> class=org.apache.camel.quickfix.QuickfixInitiator
>>>>>>>>>>>
>>>>>>>>>>> Is it enough to register new camel endpoints ?
>>>>>>>>>>>
>>>>>>>>>>> Regards,
>>>>>>>>>>>
>>>>>>>>>>> Charles Moulliard
>>>>>>>>>>> Senior Enterprise Architect
>>>>>>>>>>> Apache Camel Committer
>>>>>>>>>>>
>>>>>>>>>>> *****************************
>>>>>>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>>>>>>
>>
>