Hi all,
I have some troubles running spring on GAE for a particular configuration.
When I run this config on my local machine I have logs in the console that
indicate that it works. When I deploy it on GAE I have a null pointer
exception because PersistenceManagerFactory is null which is not the case on
local. (logs are in the doPost method)

Has someone already tried to use Spring MethodInvokingFactoryBean ?

Here it the code, thanks for any help
Loïc



applicationContext.xml :

  <context:component-scan base-package="com.mypackage.jdo"/>

  <context:spring-configured/>

  <context:annotation-config />



  <bean class=
"org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
/>


  <bean class=
"org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"
/>



  <bean id="pmf" class=
"org.springframework.beans.factory.config.MethodInvokingFactoryBean">

    <property name="staticMethod">

     <value>javax.jdo.JDOHelper.getPersistenceManagerFactory</value>

    </property>

    <property name="arguments">

        <value>transactions-optional</value>

    </property>

  </bean>


  <bean id="persistenceManager"

    class="com.mypackage.jdo.PersistenceContextManager">

    <constructor-arg>

      <ref bean="pmf"/>

    </constructor-arg>

  </bean>


 where com.mypackage.jdo.PersistenceContextManager is:


import javax.jdo.PersistenceManager;

import javax.jdo.PersistenceManagerFactory;


public class PersistenceContextManager {

protected PersistenceManager pm;

public PersistenceManager getPm() {

return pm;

}

public PersistenceContextManager() {

super();

}

public PersistenceContextManager(PersistenceManagerFactory pmf) {

pm = pmf.getPersistenceManager();

}

}


then in a servlet I have:


@Resource(name="persistenceManager")

private PersistenceContextManager pmf;

        public void init(ServletConfig config) throws ServletException {

super.init(config);

ServletContext servletContext = config.getServletContext();

WebApplicationContext webApplicationContext = WebApplicationContextUtils

.getWebApplicationContext(servletContext);


 AutowireCapableBeanFactory autowireCapableBeanFactory =
webApplicationContext

.getAutowireCapableBeanFactory();


 autowireCapableBeanFactory.configureBean(this, "persistenceManager");

}


     public void doPost(HttpServletRequest req, HttpServletResponse res)

throws ServletException {

        ...

        ...

     if (pmf != null) {

log.warning("pmf not null");

     }

     else {

log.warning("pmf is null");

     }

     PersistenceManager pm = pmf.getPm();

     Transaction tx = pm.currentTransaction();


      try {

       tx.begin();

       pm.makePersistent(myObjectToPersist);

       tx.commit();

     }

     finally {

       if (tx.isActive())

       {

  tx.rollback();

     }

          ...

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to