-
1. Re: Camel-Hibernate Issue with Blueprint
grgrzybek Jun 5, 2017 2:48 AM (in response to sarada.ch)Hello
Answered on SO, but also here for completeness:
Remember one thing. `org.springframework.orm.hibernate4.LocalSessionFactoryBean` is Spring's _factory bean_ which, when used as `<bean>` gives you a kind of indirection - instead of using the class as bean directly, `getObject()` is called and the returned object is your `<bean>`.
Another thing is that Spring automatically calls `afterPropertiesSet()` for all beans (or factory beans) that implement `InitializingBean`.
So instead of:
<bean class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
id="mysessionFactory">
use:
<bean id="mysessionFactory" factory-ref="mysessionFactoryFactory"
factory-method="getObject" init-method="afterPropertiesSet" />
<bean class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
id="mysessionFactoryFactory">
...
regards
Grzegorz Grzybek -
2. Re: Camel-Hibernate Issue with Blueprint
sarada.ch Jun 5, 2017 8:38 PM (in response to grgrzybek)Hi Grzegorz,
I ran into different exception after the above changes:
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to instantiate components
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:686)
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:377)
Caused by: java.lang.NullPointerException
at org.apache.aries.blueprint.container.BeanRecipe.getInitMethod(BeanRecipe.java:619)
Many Thanks,
Sarada
-
3. Re: Camel-Hibernate Issue with Blueprint
grgrzybek Jun 6, 2017 2:05 AM (in response to sarada.ch)I'm sorry - I wrote from top of my head without running the example - `afterPropertiesSet` is a method of LocalSessionFactoryBean, so add init-method="afterPropertiesSet" on:
<bean class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
id="mysessionFactoryFactory" init-method="afterPropertiesSet">
regards
Grzegorz Grzybek
-
4. Re: Camel-Hibernate Issue with Blueprint
sarada.ch Jun 6, 2017 2:25 AM (in response to grgrzybek)Thanks a lot for valuable input.
It worked amazing.
It would be great if camel developers can update the same in the camel-hibernate example for blueprint Apache Camel: Hibernate Example
-
5. Re: Camel-Hibernate Issue with Blueprint
grgrzybek Jun 6, 2017 2:31 AM (in response to sarada.ch)I'm glad it worked
About updating camel example - you can always send PR to https://github.com/camel-extra/camel-extra/tree/master/examples/camel-example-hibernate.
regards
Grzegorz Grzybek