| <!DOCTYPE html> |
| |
| |
| <!-- |
| | Generated by Apache Maven Doxia Site Renderer 2.0.0 from src/site/xdoc/howto/migrate-from-2_1-howto.xml at 10 Sep 2025 |
| | Rendered using Apache Maven Fluido Skin 2.1.0 |
| --> |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> |
| <head> |
| <meta charset="UTF-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| <meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" /> |
| <title>Migrating from 2.1 to 2.2 – Apache Turbine</title> |
| <link rel="stylesheet" href="../css/apache-maven-fluido-2.1.0.min.css" /> |
| <link rel="stylesheet" href="../css/site.css" /> |
| <link rel="stylesheet" href="../css/print.css" media="print" /> |
| <script src="../js/apache-maven-fluido-2.1.0.min.js"></script> |
| <link rel="icon" type="image/png" sizes="48x48" href="https://apache.org/favicons/favicon.ico"> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <style>.github-fork-ribbon:before { background-color: orange; }</style> |
| </head> |
| <body> |
| <a class="github-fork-ribbon right-top" href="https://github.com/apache/turbine-build" data-ribbon="Fork me on GitHub">Fork me on GitHub</a> |
| <div class="container-fluid container-fluid-top"> |
| <header> |
| <div id="banner"> |
| <div class="pull-left"><div id="bannerLeft"><h1><a href="https://turbine.apache.org/"><img src="https://www.apache.org/img/feather_glyph_notm.png" style="width: 50px;" /> The Apache Turbine project</a></h1></div></div> |
| <div class="pull-right"><div id="bannerRight"><h1><a href="https://turbine.apache.org/"><img src="https://turbine.apache.org/images/logo.gif" alt="Apache Turbine" /></a></h1></div></div> |
| <div class="clear"><hr/></div> |
| </div> |
| |
| <div id="breadcrumbs"> |
| <ul class="breadcrumb"> |
| <li id="publishDate">Last Published: 01 Apr 2025<span class="divider">|</span> |
| </li> |
| <li id="projectVersion">Version: 7.1-SNAPSHOT</li> |
| <li class="pull-right"><span class="divider">|</span> |
| <a href="https://turbine.apache.org/fulcrum/">Fulcrum</a></li> |
| <li class="pull-right"><span class="divider">|</span> |
| <a href="https://turbine.apache.org/">Turbine</a></li> |
| <li class="pull-right"><a href="https://www.apache.org">Apache</a></li> |
| </ul> |
| </div> |
| </header> |
| <div class="row-fluid"> |
| <header id="leftColumn" class="span2"> |
| <nav class="well sidebar-nav"> |
| <ul class="nav nav-list"> |
| <li class="nav-header">General Information</li> |
| <li><a href="../index.html">Overview</a></li> |
| <li><a href="../features.html">Features</a></li> |
| <li><a href="../fsd.html">Specification</a></li> |
| <li><a href="../getting-started.html">Getting Started</a></li> |
| <li><a href="../how-to-build.html">Howto Build Turbine</a></li> |
| <li><a href="../changes-report.html">Changes</a></li> |
| <li class="nav-header">Documentation</li> |
| <li><a href="../services/index.html"><span class="icon-chevron-right"></span>Services</a></li> |
| <li><a href="../howto/index.html"><span class="icon-chevron-down"></span>Howtos</a> |
| <ul class="nav nav-list"> |
| <li><a href="../howto/action-event-howto.html">Action Events Howto</a></li> |
| <li><a href="../howto/annotations.html">Annotations Howto</a></li> |
| <li><a href="../howto/configuration-howto.html">Configuration Howto</a></li> |
| <li><a href="../howto/extend-user-howto.html">Extend User Howto</a></li> |
| <li><a href="../howto/hibernate-howto.html">Hibernate OM Howto</a></li> |
| <li><a href="../howto/intake-howto.html">Intake Howto</a></li> |
| <li><a href="../howto/jsp-howto.html">JSP Howto</a></li> |
| <li class="active"><a>Migrating from 2.1 to 2.2</a></li> |
| <li><a href="../howto/migrate-from-2_2-howto.html">Migrating from 2.2 to 2.3</a></li> |
| <li><a href="../howto/migrate-from-2_3-howto.html">Migrating from 2.3 to 4.0</a></li> |
| <li><a href="../howto/migrate-from-4_0-howto.html">Migrating from 4.0 to 5.0</a></li> |
| <li><a href="../howto/pullmodel-howto.html">Pull Model Howto</a></li> |
| <li><a href="../howto/python-howto.html">Python Howto</a></li> |
| <li><a href="../howto/security-howto.html">Security Howto</a></li> |
| <li><a href="../howto/services-howto.html">Services Howto</a></li> |
| <li><a href="../howto/url-mapper-howto.html">URL Mapper Howto</a></li> |
| <li><a href="../howto/url-rewriting-howto.html">URL Rewriting Howto</a></li> |
| <li><a href="../howto/context-howto.html">Velocity Context Howto</a></li> |
| <li><a href="../howto/velocity-site-howto.html">Velocity Site Howto</a></li> |
| <li><a href="../howto/velocityonlylayout-howto.html">VelocityOnlyLayout Howto</a></li> |
| </ul></li> |
| <li><a href="https://cwiki.apache.org/confluence/display/TURBINE">Wiki</a></li> |
| <li><a href="../apidocs/index.html">JavaDocs</a></li> |
| <li class="nav-header">Development</li> |
| <li><a href="../proposals.html">Proposals</a></li> |
| <li><a href="../how-to-help.html">How To Help</a></li> |
| <li><a href="../todo.html">Todo</a></li> |
| <li class="nav-header">Project Documentation</li> |
| <li><a href="../project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li> |
| <li><a href="../project-reports.html"><span class="icon-chevron-right"></span>Project Reports</a></li> |
| <li class="nav-header">Apache</li> |
| <li><a href="https://www.apache.org/">Apache Website</a></li> |
| <li><a href="https://www.apache.org/licenses/">License</a></li> |
| <li><a href="https://www.apache.org/foundation/how-it-works.html">How the ASF works</a></li> |
| <li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li><a href="https://www.apache.org/security/">Security</a></li> |
| </ul> |
| </nav> |
| <div class="well sidebar-nav"> |
| <form id="search-form" action="https://www.google.com/search" method="get" > |
| <input value="http://turbine.apache.org/turbine/turbine-7-0" name="sitesearch" type="hidden" /> |
| <input class="search-query" name="q" id="query" type="text" placeholder="Search with Google..." /> |
| </form> |
| <div id="poweredBy"> |
| <div class="clear"></div> |
| <div class="clear"></div> |
| <a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="../images/logos/maven-feather.png" /></a> |
| </div> |
| </div> |
| </header> |
| <main id="bodyColumn" class="span10"> |
| |
| |
| |
| |
| <section><a id="Important_note"></a> |
| <h1>Important note</h1> |
| |
| <p> |
| The information in this HOWTO pertains to Turbine 2.2. Please refer |
| to the <a href="migrate-from-2_2-howto.html">Migrating from |
| 2.2 to 2.3</a> page for information on migating to Turbine 2.3. |
| </p> |
| </section> |
| |
| <section><a id="Introduction"></a> |
| <h1>Introduction</h1> |
| |
| <p> |
| This document describes the basic steps needed to migrate an |
| application written for Turbine 2.1 to Turbine 2.2 using the |
| decoupled Torque. |
| </p> |
| |
| <p> |
| You may find that migrating to 2.2 is not all that difficult. |
| Of course, this depends quite a bit on how much of Turbine your |
| application actually uses. You may find migrating to 2.2 to be |
| quite a chore, but it is well worth the effort. Most of the |
| pain in figuring out this migration process has been documented |
| in the mailing list archives, but is summarized here for your |
| convenience. |
| </p> |
| </section> |
| |
| <section><a id="Cleanup"></a> |
| <h1>Cleanup</h1> |
| |
| <p> |
| Start off with deleting all of the objects that Torque generated |
| for you. I am talking about om.map.* and om.Base*. You will be |
| able to regenerate them later during the migration process. |
| </p> |
| </section> |
| |
| <section><a id="Build_and_Properties_Files"></a> |
| <h1>Build and Properties Files</h1> |
| |
| <p> |
| The structure of the build files used by Turbine has changed |
| quite a bit with the 2.2 release. The easiest way of obtaining |
| a reference set of property (and build files) is to install |
| version 2.2 of the TDK and generate the demo application. |
| </p> |
| |
| <p> |
| From the demo application you should: |
| </p> |
| <ul> |
| |
| <li>Merge <code>tdk-2.2/webapps/newapp/WEB-INF/conf/build.properties</code> |
| with your existing properties file.</li> |
| |
| <li>Copy <code>build-torque.xml</code> from the demo application |
| to your build directory.</li> |
| |
| <li>Copy <code>project-build.xml</code> from the demo application |
| to your build directory.</li> |
| |
| <li>Merge <code>build.xml</code> from the demo application |
| to your existing build file (if you have only ever used the |
| default build file supplied with the tdk then I assume you |
| can just replace your file with the new one).</li> |
| |
| <li>Copy <code>WEB-INF/conf/TurbineResources.template</code> and |
| <code>WEB-INF/conf/Torque.template</code>) to your application |
| and apply changes as needed (it is up to you as to how much you |
| hard code into your application template and how much you allow |
| to be processed into the resulting properties files by way of |
| <code>build.properties</code> or the other property files).</li> |
| </ul> |
| |
| |
| <p> |
| See the Torque |
| <a href="http://db.apache.org/torque/properties-reference.html" class="externalLink"> |
| Properties Reference</a> for full details of the available properties. |
| </p> |
| </section> |
| |
| <section><a id="Libraries"></a> |
| <h1>Libraries</h1> |
| |
| <p> |
| Turbine and Torque use updated versions of a number of |
| libraries (jar files). Take a look at the WEB-INF/lib directory |
| of the TDK sample application to see which libraries have been |
| updated and replace the files in the lib directory of your |
| application as needed. |
| </p> |
| |
| <p> |
| Note that if you have applied local changes to Turbine itself |
| then you should ensure that your changes have made it into the |
| Turbine 2.2 and Torque 3.0 releases. If any of your changes |
| have not made it then you will need to port these changes forward |
| and build your own versions of the Turbine and Torque jar files |
| (while you are there you may as well create patches and submit |
| them to the relevant modules in Scarab so that they can be |
| included in future releases). |
| </p> |
| |
| <p> |
| By default Torque will utilize a set of Velocity templates that |
| you need to extract from the Torque jar file (see the |
| <code>torque.templatePath</code> property). Unless you have a |
| need to alter these templates you may prefer to use these directly |
| from the jar file. To do this you need to set the |
| <code>torque.useClasspath</code> property to <code>true</code> in |
| <code>build.peoperties</code>. In any case, you should either |
| replace or delete the old versions of these templates from your |
| existing project. |
| </p> |
| </section> |
| |
| <section><a id="Import_Statements"></a> |
| <h1>Import Statements</h1> |
| |
| <p> |
| Many of your import statements will need to be changed. This is |
| due to the decoupled version of Torque. This will take care of |
| most of the changes due to refactoring. There will still be a |
| few cases (discussed later) where the methods have been changed and/or |
| moved to different classes. |
| </p> |
| |
| <p> |
| <a href="http://db.apache.org/torque/changes.html#Torque%203.0-b3" class="externalLink"> |
| [Here]</a> is list of the most common import changes. |
| </p> |
| </section> |
| |
| <section><a id="Transactions_and_obtaining_database_connections"></a> |
| <h1>Transactions and obtaining database connections</h1> |
| |
| <p> |
| org.apache.turbine.util.db.DBConnection is gone. The replacement |
| is java.sql.Connection. This was a wrapper class from the |
| Connection object. It was returned when you asked for a database |
| connection. The new version of Torque will simply return a |
| Connection object. |
| </p> |
| |
| <p> |
| org.apache.turbine.services.db.TurbineDB is gone. The replacement |
| is org.apache.torque.Torque. This was mainly used to obtain |
| database connections and the name of the default database. All |
| of this functionality is in the new class. |
| </p> |
| |
| <p> |
| Below is an example of how you might have been obtaining database |
| connections in version 2.1. |
| </p> |
| |
| |
| <pre class="prettyprint"><code> |
| |
| DBConnection dbConn = null; |
| try |
| { |
| dbConn = TurbineDB.getConnection(); |
| // Do something with the connection here... |
| } |
| catch (Exception e) |
| { |
| // Either from obtaining the connection or from your application code. |
| } |
| finally |
| { |
| try |
| { |
| TurbineDB.releaseConnection(dbConn); |
| } |
| catch (Exception e) |
| { |
| // Error releasing database connection back to pool. |
| } |
| } |
| |
| </code></pre> |
| |
| <p> |
| Using the new version of Torque this would be rewritten as follows. |
| </p> |
| |
| <pre class="prettyprint"><code> |
| |
| Connection conn = null; |
| try |
| { |
| conn = Torque.getConnection(); |
| // Do something with the connection here... |
| } |
| catch (TorqueException ex) |
| { |
| // Either from obtaining the connection or from your application code. |
| Log.error(ex); |
| } |
| finally |
| { |
| Torque.closeConnection(conn); |
| } |
| |
| </code></pre> |
| |
| <p> |
| Support for transactions has been moved from org.apache.turbine.om.BasePeer |
| into org.apache.torque.util.Transaction. The method names have changed |
| slightly as well. Here is an example of using transactions in 2.1. |
| </p> |
| |
| <pre class="prettyprint"><code> |
| |
| DBConnection dbConn = null; |
| try |
| { |
| dbConn = BasePeer.beginTrasaction(TurbineDB.getDefaultDB?()); |
| someObject.save(dbConn); |
| someOtherObject.save(dbConn); |
| BasePeer.commitTransaction(dbConn); |
| } |
| catch (Exception e) |
| { |
| // Either from obtaining the connection or from your application code. |
| BasePeer?.rollbackTransaction(dbConn); |
| } |
| |
| </code></pre> |
| |
| <p> |
| This would now be written as shown below. |
| </p> |
| |
| <pre class="prettyprint"><code> |
| |
| Connection conn = null; |
| try |
| { |
| conn = Transaction.begin(Torque.getDefaultDB()); |
| someObject.save(conn); |
| someOtherObject.save(conn); |
| Transaction.commit(conn); |
| } |
| catch (TorqueException ex) |
| { |
| try |
| { |
| Transaction.rollback(conn); |
| } |
| catch (TorqueException ex2) |
| { |
| Log.error(ex2); |
| } |
| Log.error(ex); |
| } |
| |
| </code></pre> |
| </section> |
| |
| <section><a id="Vector_becomes_List"></a> |
| <h1>Vector becomes List</h1> |
| |
| <p> |
| Methods generated by Torque that previously had a return type of |
| <code>Vector</code> now have a return type of <code>List</code>. |
| If you have not already been doing so you should switch to |
| retrieving the results of these methods into variables declared |
| as <code>List</code>. While you are at it you might like to |
| update any of your own code to use <code>ArrayList</code> in |
| preference to <code>Vector</code>. |
| </p> |
| </section> |
| |
| <section><a id="Exception_becomes_TorqueException"></a> |
| <h1>Exception becomes TorqueException</h1> |
| |
| <p> |
| Methods generated by Torque now throw <code>TorqueException</code> |
| rather than <code>Exception</code>. You might like to update |
| your code to match. |
| </p> |
| |
| <p> |
| Note that the exception thrown by <code>save()</code> methods is |
| determined by the Torque property <code>torque.saveException</code> |
| which defaults to <code>Exception</code>. |
| </p> |
| </section> |
| |
| <section><a id="Extending_Turbine_User"></a> |
| <h1>Extending Turbine User</h1> |
| |
| <p> |
| See |
| <a href="http://turbine.apache.org/turbine-2/howto/extend-user-howto.html" class="externalLink"> |
| Extending Turbine User How-To</a> for this information. |
| </p> |
| </section> |
| |
| <section><a id="Changes_to_the_OM_classes"></a> |
| <h1>Changes to the OM classes</h1> |
| |
| <p> |
| Read over the Torque Schema Reference to find out what to change |
| in your project-schema.xml file. The main changes are the |
| deprecation of sequence and autoIncrement idMethods and the |
| addition of the javaType attribute to column elements |
| (Torque can now work with object types). |
| </p> |
| |
| <p> |
| If you used inheritance, you will run need to specify |
| abstract="true" for the tables which have abstract base |
| classes. When you do this, you will need to implement the |
| copy() method in your subclasses. An example is provided below. |
| </p> |
| |
| <pre class="prettyprint"><code> |
| |
| public <base class> copy() throws TorqueException |
| { |
| return copyInto(new <sub class>()); |
| } |
| |
| </code></pre> |
| |
| <p> |
| Atributes defined as primary keys are no longer generated |
| as NumberKey objects. They are now Integer or int (depending |
| on the javaType specified in project-schema.xml). |
| </p> |
| |
| <p> |
| If you have a turbine-schema.xml file in your WEB-INF/conf |
| directory, the project-om ant task will generate all of the |
| Turbine*, BaseTurbine*, and map.Turbine* objects for you. |
| These will not be used by Turbine. They will only confuse |
| you. The best thing to do for this is to rename your |
| turbine-schema.xml file to something like turbine-schema.nogenerate. |
| </p> |
| </section> |
| |
| <section><a id="XML-RPC_service"></a> |
| <h1>XML-RPC service</h1> |
| |
| <p> |
| My TurbineResources.properties did not have settings to |
| configure the secure options. This caused initialization |
| of the service to fail. To fix this, I simply obtained all |
| of the configuration settings from the TurbineResources.properties |
| included with the source version. |
| </p> |
| |
| <p> |
| The service does not listen on the loopback interface by default |
| any longer. There were no other changes that are required to get |
| this service up and running under T2.2. |
| </p> |
| </section> |
| |
| <section><a id="Other_services"></a> |
| <h1>Other services</h1> |
| |
| <p> |
| Intake, Security, and Scheduler all work without a problem |
| after migrating to T2.2. |
| </p> |
| </section> |
| |
| <section><a id="Maven"></a> |
| <h1>Maven</h1> |
| |
| <p> |
| You may like to consider using |
| <a href="http://maven.apache.org/maven-1.x/" class="externalLink">Maven</a> to |
| build your project. The document |
| <a href="http://wiki.apache.org/turbine/TDK/Maven" class="externalLink"> |
| Starting your project and database with TDK2.2 and Maven</a> |
| provides some information that can be adapted for this purpose |
| (jump down to the "Moving The Sample" heading for the |
| documentation relevant to an existing project). |
| </p> |
| </section> |
| |
| <section><a id="Updates_to_this_document"></a> |
| <h1>Updates to this document</h1> |
| |
| <p> |
| This document is by no means complete or totally accurate. We welcome |
| suggestions as to how it might be improved, particularly if you have |
| just completed migrating an application by following this howto. |
| </p> |
| </section> |
| |
| |
| </main> |
| </div> |
| </div> |
| <hr/> |
| <footer> |
| <div class="container-fluid"> |
| <div class="row-fluid"> |
| <p>© 2000–2025 |
| <a href="https://www.apache.org/">The Apache Software Foundation</a> |
| </p> |
| </div> |
| </div> |
| </footer> |
| </body> |
| </html> |