camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dudgeon <tdudgeon...@gmail.com>
Subject Re: Using Box component
Date Mon, 23 Jan 2017 16:22:16 GMT
OK, made some progress, but still hitting problems.

The only way I could get it to work is to manually set the 
BoxConfiguration when creating the CamelContext.

BoxConfiguration configuration =new BoxConfiguration();
configuration.setClientId("xxx");
configuration.setClientSecret("xxx");
configuration.setUserName("xxx");
configuration.setUserPassword("xxx");
DefaultCamelContext context =new DefaultCamelContext(registry);
BoxComponent box = (BoxComponent)context.getComponent("box");
box.setConfiguration(configuration);

(and BTW the docs say the property for the BoxConfiguration is called 
boxConfig, but the bean property seems to be configuration, thought I 
coudn't get it to work that way)

With that is seems to fire up OK and I think I'm getting past the OAuth 
authentication process (because if I use a bad password it fails).

But when I cause a Box event to fire (e.g. by uploading a file) this 
happens:

[Camel (camel-1) thread #1 - CamelBox] WARN 
org.apache.camel.component.box.BoxConsumer - Caused by: 
[org.apache.camel.RuntimeCamelException - 
com.box.restclientv2.exceptions.BoxRestException: Failed to parse response.]
org.apache.camel.RuntimeCamelException: 
com.box.restclientv2.exceptions.BoxRestException: Failed to parse response.
     at 
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1763)
     at 
org.apache.camel.component.box.BoxConsumer.onException(BoxConsumer.java:83)
     at 
org.apache.camel.component.box.internal.LongPollingEventsManager$1.run(LongPollingEventsManager.java:212)
     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: com.box.restclientv2.exceptions.BoxRestException: Failed to 
parse response.
     at 
com.box.restclientv2.responseparsers.DefaultBoxJSONResponseParser.parse(DefaultBoxJSONResponseParser.java:77)
     at 
com.box.restclientv2.responses.DefaultBoxResponse.parseResponse(DefaultBoxResponse.java:54)
     at 
com.box.boxjavalibv2.resourcemanagers.AbstractBoxResourceManager.getResponseAndParse(AbstractBoxResourceManager.java:121)
     at 
com.box.boxjavalibv2.resourcemanagers.AbstractBoxResourceManager.getResponseAndParseAndTryCast(AbstractBoxResourceManager.java:108)
     at 
com.box.boxjavalibv2.resourcemanagers.BoxEventsManagerImpl.getEvents(BoxEventsManagerImpl.java:54)
     at 
org.apache.camel.component.box.internal.LongPollingEventsManager$1.run(LongPollingEventsManager.java:176)
     ... 7 more
Caused by: com.box.boxjavalibv2.exceptions.BoxJSONException: 
com.fasterxml.jackson.databind.JsonMappingException: Class 
com.box.boxjavalibv2.dao.BoxUserBase not subtype of [simple type, class 
com.box.boxjavalibv2.dao.BoxUser]
  at [Source: org.apache.http.conn.EofSensorInputStream@7383fa41; line: 
1, column: 21] (through reference chain: 
com.box.boxjavalibv2.dao.BoxEventCollection["entries"]->java.util.ArrayList[0])
     at 
com.box.boxjavalibv2.jsonparsing.BoxJSONParser.parseIntoBoxObject(BoxJSONParser.java:105)
     at 
com.box.restclientv2.responseparsers.DefaultBoxJSONResponseParser.parseInputStream(DefaultBoxJSONResponseParser.java:94)
     at 
com.box.restclientv2.responseparsers.DefaultBoxJSONResponseParser.parse(DefaultBoxJSONResponseParser.java:73)
     ... 12 more
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Class 
com.box.boxjavalibv2.dao.BoxUserBase not subtype of [simple type, class 
com.box.boxjavalibv2.dao.BoxUser]
  at [Source: org.apache.http.conn.EofSensorInputStream@7383fa41; line: 
1, column: 21] (through reference chain: 
com.box.boxjavalibv2.dao.BoxEventCollection["entries"]->java.util.ArrayList[0])
     at 
com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:296)
     at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269)
     at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
     at 
com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
     at 
com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:443)
     at 
com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:188)
     at 
com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:112)
     at 
com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:97)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1088)
     at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:279)
     at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
     at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
     at 
com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:499)
     at 
com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:101)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
     at 
com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3761)
     at 
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2090)
     at 
com.box.boxjavalibv2.jsonparsing.BoxJSONParser.parseIntoBoxObject(BoxJSONParser.java:99)
     ... 14 more
Caused by: java.lang.IllegalArgumentException: Class 
com.box.boxjavalibv2.dao.BoxUserBase not subtype of [simple type, class 
com.box.boxjavalibv2.dao.BoxUser]
     at 
com.fasterxml.jackson.databind.type.TypeFactory.constructSpecializedType(TypeFactory.java:359)
     at 
com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder.buildTypeDeserializer(StdTypeResolverBuilder.java:118)
     at 
com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findTypeDeserializer(BasicDeserializerFactory.java:1359)
     at 
com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findPropertyTypeDeserializer(BasicDeserializerFactory.java:1494)
     at 
com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.resolveMemberAndTypeAnnotations(BasicDeserializerFactory.java:1843)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.constructSettableProperty(BeanDeserializerFactory.java:728)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:516)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:226)
     at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:141)
     at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:406)
     at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
     at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
     ... 31 more
[Camel (camel-1) thread #1 - CamelBox] INFO 
org.apache.camel.component.box.internal.LongPollingEventsManager - 
Stopped event polling thread for {login:tdudgeon.ml@gmail.com, 
client_id:b2qg97dks2bgrfnyjgrb48n3rdsmsdzd}


I don't fully understand this but looks like Jackson is barfing at the 
JSON returned, so there might be a library mismatch issue here?

Tim


On 23/01/2017 12:30, Claus Ibsen wrote:
> You can configure a box configuration on the component level with your
> login details.
>
> On Mon, Jan 23, 2017 at 11:54 AM, Tim Dudgeon <tdudgeon.ml@gmail.com> wrote:
>> Is there a workaround that can be used with the current code?
>>
>>
>> On 22/01/2017 17:11, Claus Ibsen wrote:
>>> Hi
>>>
>>> Can you log a ticket as its a bug. The code is not so good with the
>>> shared client stuff.
>>>
>>> On Sun, Jan 22, 2017 at 5:56 PM, Tim Dudgeon <tdudgeon.ml@gmail.com>
>>> wrote:
>>>> mmm, from this docs this is what is says about boxConfig:
>>>>
>>>> "Custom Box SDK configuration, not required normally"
>>>>
>>>> Tim
>>>>
>>>>
>>>>
>>>> On 22/01/2017 13:41, souciance wrote:
>>>>> Not sure but from the look of BoxComponent.java at line 83 it seems you
>>>>> are
>>>>> missing the parameter boxConfig.
>>>>>
>>>>> On Sun, Jan 22, 2017 at 1:56 PM, Tim Dudgeon [via Camel] <
>>>>> ml-node+s465427n5792922h45@n5.nabble.com> wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I'm having difficulty getting started with the Box component (using
>>>>>> Camel 2.18.1).
>>>>>> I'm using a route definition like this:
>>>>>>
>>>>>>
>>>>>>
>>>>>> from("box://poll-events/poll?userName={{box_username}}&userPassword={{box_
>>>>>> userpassword}}&clientId={{box_client_id}}&clientSecret={{
>>>>>> box_client_secret}}&streamPosition=-1&streamType=all&limit=100")
>>>>>> ...;
>>>>>>
>>>>>> Other than the parameters in the route definition there's nothing
else
>>>>>> Box related configured.
>>>>>>
>>>>>> The parameters seem to be getting incorporated correctly, but the
route
>>>>>> fails to start because of:
>>>>>>
>>>>>> Exception in thread "main"
>>>>>> org.apache.camel.FailedToCreateRouteException: Failed to create route
>>>>>> route4: Route(route4)[[From[box://poll-events/poll?userName={{box_us...
>>>>>> because of Failed to resolve endpoint:
>>>>>> box://poll-events/poll?clientId=xxx&clientSecret=xxx&
>>>>>>
>>>>>>
>>>>>> limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)
>>>>>>
>>>>>> due to: Cannot auto create component: box
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)
>>>>>>
>>>>>>         at
>>>>>> org.apache.camel.impl.DefaultCamelContext.access$
>>>>>> 000(DefaultCamelContext.java:182)
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)
>>>>>>
>>>>>>         at
>>>>>> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)
>>>>>>
>>>>>>         at com.im.ext.xchem.filedrop.Main.main(Main.java:28)
>>>>>> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed
to
>>>>>> resolve endpoint:
>>>>>> box://poll-events/poll?clientId=xxx&clientSecret=xxx&
>>>>>>
>>>>>>
>>>>>> limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)
>>>>>>
>>>>>> due to: Cannot auto create component: box
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:622)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1051)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
>>>>>>
>>>>>>         ... 11 more
>>>>>> Caused by: org.apache.camel.RuntimeCamelException: Cannot auto create
>>>>>> component: box
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:436)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.lambda$getComponent$16(DefaultCamelContext.java:411)
>>>>>>
>>>>>>         at
>>>>>> org.apache.camel.impl.DefaultCamelContext$$Lambda$4/2033968586
>>>>>> <(203)%20396-8586>.apply(Unknown
>>>>>> Source)
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:411)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:402)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:592)
>>>>>>
>>>>>>         ... 19 more
>>>>>> Caused by: java.lang.IllegalArgumentException: Unable to connect,
Box
>>>>>> component configuration is missing
>>>>>>         at
>>>>>>
>>>>>> org.apache.camel.component.box.BoxComponent.doStart(BoxComponent.java:83)
>>>>>>         at
>>>>>> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3371)
>>>>>>
>>>>>>         at
>>>>>>
>>>>>>
>>>>>> org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:431)
>>>>>>
>>>>>>         ... 25 more
>>>>>>
>>>>>> Can anyone spot what is wrong here?
>>>>>> Are there any examples anywhere to look at?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Tim
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------
>>>>>> If you reply to this email, your message will be added to the
>>>>>> discussion
>>>>>> below:
>>>>>> http://camel.465427.n5.nabble.com/Using-Box-component-tp5792922.html
>>>>>> To start a new topic under Camel - Users, email
>>>>>> ml-node+s465427n465428h31@n5.nabble.com
>>>>>> To unsubscribe from Camel - Users, click here
>>>>>>
>>>>>>
>>>>>> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
>>>>>> .
>>>>>> NAML
>>>>>>
>>>>>>
>>>>>> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>>
>>>>> http://camel.465427.n5.nabble.com/Using-Box-component-tp5792922p5792923.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>
>
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message