Hi,

I finally tracked down an issue that I was having in a Stripes 1.5.4 
BETA, Stripersist, Spring, JPA, Hibernate, etc... application:

We essentially have a Services layer that sits in front of the Dao layer 
and as such are following the following example:
http://www.stripesframework.org/display/stripes/Stripes+Spring+JPA

Furthermore, as ALL beans in Spring default to being Singletons it is 
important that the Service initialize itself when it (the Singleton) 
gets created otherwise we end up with multiple users of the Singleton 
trying to initialize it / adding synchronized blocks et al... which is 
UGLY to say the least....

So we have the following code excerpt:

@Service
public class ModalityServiceImpl implements ModalityService {

    @Autowired
    private ModalityDao modalityDaoImpl;

    public ModalityServiceImpl() {
        this.initService();
    }

    private void initAfter() {
        List<Modality> modalityList = this.modalityDaoImpl.findAll();    
// ** NPE ** - this.modalityDaoImpl ** IS NULL **
        this.modalityCache = new ModalityCache();
        this.modalityCache.init(modalityList);
    }

However, the above results in a NullPointerException at the line marked 
with ** NPE ** because this.modalityDaoImpl is NULL which clearly 
indicates that Spring has not completed the Autowiring and we are trying 
to invoke a method on.  A similar scenario occurs even if we didn't 
Autowire the DAO and simply had the following for the attribute:

    private ModalityDao modalityDaoImpl = new ModalityDaoImpl();

In this latter case there is Stripersist except when trying to lookup 
the persistence unit with a NULL entityFactories hashtable.

I guess what I need is a WAY to perform POST initialization on this 
Spring managed Service object.  If I was dealing with an ActionBean then 
an @AFTER on a particular life cycle event I imagine would do the trick 
but this is not an Action Bean.

Any ideas anyone???  Perhaps using the SpringIntereceptorSupport class????

Thanks,

--Nikolaos

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to