You must initializate session attribute.

2012/9/14 pirzada rashid <pirzada.ras...@gmail.com>

> Hi,
>
> I am using struts2-fullhibernatecore-plugin-2.2.2-GA in a demo strut2
> project with Hibernate. I tried my best but can not make it work. I am
> using all the latest jars.
>
> *Am I missing something?*
>
> Please help
>
> *ERROR LOG*
>
> 2012-09-14 02:06:50 - [  INFO -
> SessionTransactionInjectorInterceptor:41 ] --> Full Hibernate Plugin
> Validation could not detect Hibernate Validator 3.x
> 2012-09-14 02:06:50 - [  INFO -
> SessionTransactionInjectorInterceptor:46 ] --> Full Hibernate Plugin
> Validation using Hibernate Validator 4.x
>
> *Library in my project*
>
> [image: enter image description here]
>
> *When I access page than get error*
>
> java.lang.NullPointerException
>
>     com.myapp.dao.CustomerDAOImpl.listCustomer(CustomerDAOImpl.java:26)
>     com.myapp.web.CustomerAction.listCustomer(CustomerAction.java:47)
>     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     java.lang.reflect.Method.invoke(Method.java:597)
>
> com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)......
>
> *My CustomerDAOImpl.java*
>
> package com.myapp.dao;
>
> import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
> import
> com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
> import com.myapp.model.Customer;
> import org.hibernate.Session;
> import org.hibernate.Transaction;
>
> import java.util.List;
>
> public class CustomerDAOImpl implements CustomerDAO {
>
>     @SessionTarget
>     Session session;
>
>     @TransactionTarget
>     Transaction transaction;
>
>     //add the customer
>     public void addCustomer(Customer customer) {
>         session.save(customer);
>     }
>
>     //return all the customers in list
>     public List<Customer> listCustomer() {
>         return session.createQuery("from Customer").list();
>     }
> }
>
> *EDITED ************
>
>  @SessionTarget
>         Session session;
>
>         @TransactionTarget
>         Transaction transaction;
>
> Problem is in the above code when Session and Transaction is injected. I am
> wondering that this might be problem of
> struts2-fullhibernatecore-plugin-2.2.2-GA not supporting
>
> hibernate-release-4.1.6.Final
> hibernate-validator-4.3.0.Final
>
> because plugin site
> http://code.google.com/p/full-hibernate-plugin-for-struts2/ mentioned that
> only supported versions are
>
> *This plugin is compatible with Hibernate Validator 3.1.0 and 4.0.2 (since
> 2.2 version)*.
>
> *Is that the problem. Have anyone used this plugin with above mentioned
> versions?*
>
> *One more question: Can we use this plugin in the production environment?*
>

Reply via email to