I am implementing persistence with Castor JDO and need to integrate this
with Struts frame work. I am new to both castor and struts and sorry for
one's time if it is a basic question.

I get the following error.
org.exolab.castor.jdo.PersistenceException: jdo.dbClosedTxRolledback
        at org.exolab.castor.jdo.engine.DatabaseImpl.close(DatabaseImpl.java:248)
        at com.teamxtend.lms.http.actions.LogonAction.perform(LogonAction.java:100)
        at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.ja
va:1787)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)

the code for LogonAction

 jdo =
(JDO)this.getServlet().getServletContext().getAttribute(Constant.JDO_KEY);
        try {
            db = jdo.getDatabase();
            db.begin();
            OQLQuery userOql = db.getOQLQuery( "SELECT u FROM
com.teamxtend.lms.om.User u WHERE Email = $1" );
            userOql.bind( user.getUsername() );
            QueryResults results = userOql.execute();

            // log query
            getServlet().log("Executing query.");

            if ( ! results.hasMore() ) {
                User myuser = (User) results.next();
                session.setAttribute(Constant.USER_KEY,myuser);
            }
            //db.commit();
            db.rollback();
            db.close();
        } catch ( Exception e ) {
            e.printStackTrace();

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

The corresponding web.xml in struts configuration is

<context-param>
    <param-name>lmsBusinessFactory</param-name>
    <param-value>com.teamxtend.lms.http.BusinessFactory</param-value>
  </context-param>
  <!-- Initialisation servlet -->
  <servlet>
    <servlet-name>Initialise</servlet-name>
    <servlet-class>com.teamxtend.lms.http.LmsInitialisation</servlet-class>
    <init-param>
      <param-name>lms-config-file</param-name>
      <param-value>/WEB-INF/lms.xml</param-value>
    </init-param>
    <init-param>
      <param-name>xml-binding-mapping</param-name>
      <param-value>/WEB-INF/mapping.xml</param-value>
    </init-param>
    <init-param>
      <param-name>xml-database-file</param-name>
      <param-value>/WEB-INF/database.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
--------------------------------------------------------
Lms Initialization.java
public void init() throws ServletException {

        String lmsConfigFile =
getServletConfig().getInitParameter("lms-config-file");

        // details the Castor Xml binding configuration
        String xmlBindingMapping =
getServletConfig().getInitParameter("xml-binding-mapping");

        // details the Castor Database configuration
        String xmlDatabaseFile =
getServletConfig().getInitParameter("xml-database-file");

        // ensure init parameters (as detailed in the web.xml) are present
        if (lmsConfigFile == null)
           throw new ServletException("No 'lms-config-file' Init Parameter
supplied in web.xml");
        if (xmlBindingMapping == null)
           throw new ServletException("No 'xml-binding-mapping' Init
Parameter supplied in web.xml");
        if (xmlDatabaseFile == null)
           throw new ServletException("No 'xml-database-file' Init Parameter
supplied in web.xml");

        // all Servlet Init Parameters present...

        // retrieve Context Parameters
        String lmsBusinessFactory = (String)
getServletContext().getInitParameter("lmsBusinessFactory");

        // ensure Context Parameters are present and valid

        // ensure the Business Factory parameter is present
        if (lmsBusinessFactory == null)
            throw new ServletException("No 'lmsBusinessFactory' Context
Parameter supplied in web.xml");

        // all Context Parameters present and valid...

        try {
            // configure Xml Binding mapping
            Mapping mapping = new Mapping();
            JDO jdo = new JDO();

mapping.loadMapping(getServletContext().getResource(xmlBindingMapping));

jdo.setConfiguration(getServletContext().getResource(xmlDatabaseFile).toStri
ng());
            jdo.setDatabaseName( "lms" );

            // place Castor JDO into the web-app context
            this.getServletContext().setAttribute(Constant.JDO_KEY,jdo);

            // output the retrieved values for the Init and Context
Parameters
            // leave in for essential debugging :)
            log("Init parameter: config-file: " + lmsConfigFile);
            log("Init parameter: xml-binding-mapping: " +
xmlBindingMapping);
            log("Init parameter: xml-database-file: " + xmlDatabaseFile);
            log("Context parameter: lmsBusinessFactory: " +
lmsBusinessFactory);
            log("Initialisation complete [ok]");

        } catch (Exception e) {
            log("LMS has failed to start up correctly ...");
            log("Exception: " + e.toString());
            throw new ServletException(e);
        }
    }

In the mailing list, I found a similar query, to implement
db.rollback().Thats not working for me.


Thanks in advance

Vishy


Professional Services,
Xtend Corporation
Columbia, SC
Phone:803-732-3080 x 217

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to