[
https://issues.apache.org/activemq/browse/SM-858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38645
]
Guillaume Nodet commented on SM-858:
------------------------------------
Here is a workaround:
{code:lang=java}
public void setContext(ComponentContext context) {
this.context = context;
try {
Field field = context.getClass().getDeclaredField("context");
field.setAccessible(true);
Object smxContext = field.get(context);
field = smxContext.getClass().getDeclaredField("container");
field.setAccessible(true);
JBIContainer container = (JBIContainer) field.get(smxContext);
...
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
{code}
> Unable to access a JBIContainer using the supplied component context in
> various endpoints (i.e. JSR181)
> -------------------------------------------------------------------------------------------------------
>
> Key: SM-858
> URL: https://issues.apache.org/activemq/browse/SM-858
> Project: ServiceMix
> Issue Type: Bug
> Components: servicemix-core, servicemix-http, servicemix-jsr181
> Affects Versions: 3.1
> Reporter: jmdev
>
> Following the instructions at
> http://incubator.apache.org/servicemix/how-can-i-access-the-jbicontainer-from-inside-a-component-.html
>
> a developer should be able to access the JBIContainer from within a JSR181
> POJO. However, there is a ClassCastException due to the fact that the
> ComponentContext returned is of type EndpointComponentContext. In turn, an
> EndpointComponentContext does not provide access to it's internal context of
> type ComponentContext, which allows the developer to get a reference to the
> JBIContainer.
> Temporary fix can be found here:
> http://www.nabble.com/Error-Accessing-JBI-Container-from-JSR181-Component---Is-it-Possible--tf3281290s12049.html#a9132255
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.