Any chance you could show us the whole spring XML file? Am wondering
if its something to do with namespaces?
On 18/03/2008, cmoulliard <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I try from one of my java class to inject an HibernateDAOImplementation
> defined as a bean in the CamelContext file. Unfortunately, I receive a null
> pointer exception at the following line :
>
> orderDAO = (OrderDAOHibernateImpl)this.beanFactory.getBean("orderDAO");
>
> the beanFactory object is null
>
> import org.springframework.beans.BeansException;
> import org.springframework.beans.factory.BeanFactory;
> import org.springframework.beans.factory.BeanFactoryAware;
> import org.springframework.dao.DataIntegrityViolationException;
>
> import com.xpectis.dao.OrderDAO;
> import com.xpectis.dao.OrderDAOHibernateImpl;
> import com.xpectis.model.Order;
>
> public class SaveOrder implements BeanFactoryAware {
>
> private BeanFactory beanFactory;
> private OrderDAO orderDAO;
>
> public SaveOrder() {
> }
>
> public void save(Order order) {
>
>
> orderDAO =
> (OrderDAOHibernateImpl)this.beanFactory.getBean("orderDAO");
>
> try {
> this.orderDAO.addOrder(order);
> System.out.println("Order saved : " +
> order.toString());
> } catch (DataIntegrityViolationException de) {
> System.out.println("Could not save product, duplicate
> product id");
> } catch (Exception e) {
> System.out.println("Could not save product " +
> e.toString());
> }
> }
>
> public void setBeanFactory(BeanFactory beanFactory) {
> this.beanFactory = beanFactory;
> }
>
> public OrderDAO getOrderDAO() {
> return orderDAO;
> }
>
> public void setOrderDAO(OrderDAO orderDAO) {
> this.orderDAO = orderDAO;
> }
>
> }
>
> Here is the camelcontext file where my bean is declared.
>
> <!-- Catalog DAO Definition: Hibernate implementation -->
> <bean id="orderDAO"
> class="com.xpectis.dao.OrderDAOHibernateImpl">
> <property name="sessionFactory">
> <ref bean="sessionFactory" />
> </property>
> </bean>
>
>
> When this code runs in Spring context, it works. So, where is the issue with
> Camel ??
>
> Regards,
>
> Charles
>
>
> --
> View this message in context:
> http://www.nabble.com/BeanFactoryAware-%28Spring%29-tp16122107s22882p16122107.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com