Multithread safe servlets
This posts explains the multithreading safety problem and explains how it can be prevented. I’m writing about it because recently I’ve fixed a bug in Openbravo ERP related with issue, and I would like to remind developers about this problem to take it into account.
The way Tomcat manages servlets is creating one instance of the object and having multiple threads invoking methods on that instance, each of these threads is serving each of the multiple simultaneous request. Thus a single servlet instance can be used at the same time by different users.
All this must be kept in mind when developing servlets in order to prevent dirty global properties readings. Let me explain through a little example, let’s define a servlet:
public class Test extends HttpServlet {
private String st;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
st = readStringFromSomewhereElse();
//... do other stuff here
System.out.println(st);
}
}
In this case there could be two users accessing the doPost method simultaneously using the same instance of Test class, the first one could set the st as “A” and before printing its value the second one could set it as “B”, the the first one would print “B” instead of “A” as it would expect. In this case this property would have a static behavior.
So this pattern should be avoided when developing servlets, this is, there should not be global properties modified in the doPost method (or in any other one called from it). Generally, this can be easily solved using variables inside the doPost method instead of global properties. In fact, global properties should be initialized just once in the init method and not modified afterwards.
Posted in Openbravo Tagged: Java
Openbravo ERP: 2.50alpha-r8 available
Data migration, watch out!
Usually, nor sales responsibles neither consultants give data migration task the importance they should during the sales process, but they consume a really hugh amount of not planned time.
Migration tasks include: extracting, transformating and loading which are also known as ETL tasks.
As we all agree, the effort required to migrate the data of a small enterprise who manages all their activity using spreadsheets is not the same as a large company with a previous ERP system that wants to keep all its historical activity.
Therefore, I would like to enumerate few points to be taken into consideration, before delivering a proposal, for a correct effort evaluation:
- Master data & historical data: Master data or reference data(business partners, products, accounting plan, assets, banks, taxes, production plans, etc.) is what really makes sense to migrate instead of typing them manually. Historical data (orders, receipts, shipments, invoices, bank statements, amortizations, accounting entries, etc.) can be usually reviewed on the old system, so probably we could convince the customer it is not really necessary. Somehow, it is important to realize a historical data migration always requires a master data migration, and also note a historical data migration can take 4 times the master data migration. (20% & 80%).
- Accounting data & management data: There is also also difference between migrating just the accounting data or having to migrate all the invoices, bank statements, daily cashes, etc. in order to create the accounting data by the new application. Accounting data migration may take 20% of time than management data will.
- Period of time: Although the period won’t change the scope of the migration task, for sure, more defects and inconsistencies will be found as larger is the period. If we ask to the customer about the migration period, they will always say: “all existing information”.
- Extraction and transformation tasks included & excluded: Too often, when talking about migration we forget extraction and transformation tasks. Sometimes it is clear we do not know about the old system or the customer does not want to give us access to it, so it is clear we can’t deal with the extraction and transformation, but anyway, it is important to make it clear who is responsibe for data extraction and transformation. Not extracting data correctly when we have invested time on it can be a big issue. I’ll always try to ask for extracted and transformed data, ready to be loaded.
- Extracted data consistency and validation: If we can’t avoid extraction and transformation tasks, make sure the customer validates what you are going to migrate. It is useful to deliver lists or spreadsheets containing the final migration result before we finally load it so the customer can validate it.
As I tried to explained, migration offering needs to be detailed as possible in order to avoid future issues or project deviations from proposal.
Online courses and Openbravo’s e-learning strategy
The Education department was proud to introduce the new Online Basic Functional Training in a unique e-learning format. The 5-week long course took place between the 17th of November and 19th of December. Eight students participated and completed the course which was an overall success.
The course covers the basic functionality and usability of Openbravo ERP:

Using a Learning Management System (based on Open Source Moodle platform) and practical use of Openbravo ERP hosted on Amazon, the Online Basic Funtional Training provides a unique learning environment supervised by Openbravo training specialists, which also includes the following:
Weekly live sessions through webcast- News blog where live sessions and other news are published
- Materials (navigable slide show) for each module
- Links to additional readings
- Quizzes
- Discussion and Q&A forums answered by Openbravo Training Specialists
- Exercises and assignments
- A link to each participants' own Openbravo ERP application, which is used to experience the product and execute the exercises and assignments
- Evaluation form
Openbravo's online courses are the answer for those individuals with limited time, and who cannot necessarily afford to fly to a location to complete one of our live intensive courses.
As for the upcoming year, we will continue expanding our online course offer to keep pursuing the efficient dissemination of Openbravo knowledge.
Rok Lenardic
Senior Training Specialist
Openbravo ERP: 2.50alpha-r6 available
Openbravo 2.50: Data Access Layer in the overall Openbravo Architecture
The image below illustrates the different layers of the Openbravo architecture. Part of the architecture is delivered in 2.50 other parts will be delivered in future releases.

The Data Access Layer (DAL) uses the application dictionary as the basis for its operations. The application dictionary defines the tables, columns and data types in Openbravo (for example Business Partner, Sales Order, etc.). The Data Access Layer uses the application dictionary for two purposes:
- to generate Java business objects at development time
- at runtime to generate a Hibernate mapping to persist the business objects
So at development time Java business objects are generated for each table in the system. The columns of the table corresponds to properties (getters/setters) in the generated Java class. The foreign key columns are present as references to other generated business objects. The business object generation is done as part of the standard Openbravo build steps. The generated classes can be found in the src-gen folder in the openbravo development project.
At runtime the DAL is responsible for generating the mapping for Hibernate and configuring Hibernate.
The DAL provides an API to store, query and remove business objects from the database. This DAL service layer takes care of validation and security checks. In a future Openbravo release this API will be used to develop the business logic layer. The business logic layer will replace the current stored procedures and triggers. The business service layer will provide an API to the outside world to run business logic within Openbravo.
Two other interesting components are also present: UI and Web Services. Integrating the DAL into the UI will be done in a future release. In 2.50 we provide a REST webservice layer which provides CRUD operations on all Openbravo business objects. I will discuss the REST Webservice support in the next post.
At runtime the DAL takes care of transaction handling and providing a context in which all DAL operations run. The transaction handling is done using the open-session-in-view pattern whereby the developer in general does not need to take care of transaction handling explicitly (but he/she can ofcourse when required). The Openbravo context object makes it easy for a developer to retrieve the current user object and other context information.
The following parts of the new architecture are delivered as part of 2.50:
- Runtime Model
- Generation of Business Object and Hibernate Mapping
- DAL API
- REST Webservices
- Transaction Handling and User Context
For more information here are two wiki documents which give some more details:
This hopefully gives a feel for the overall current and future architecture of Openbravo. In the next blog post I will discuss the new REST Webservice functionality in Openbravo 2.50.
Openbravo Community awards announced
The Individual Awards acknowledge people that have allocated time and resources to make Openbravo POS or ERP better projects and contain the categories; Best Quality Assurance, Best localizer, Best developer, Best support participant, in order to recognise contribution within these areas.
The Technology Awards recognize outstanding projects led by any company or organization built on top of Openbravo technology. In order to acknowledge contribution within these areas, the categories are; Best Localization, Best Implementation and Best Development.
The winners will be awarded during the Conference's World Community Day 2 - Sunday 19th April, 2009. An award certificate will be given to all the winners.
On 2nd March 2009 the Candidate nomination will open. Stay tuned for more details!
Openbravo 2.50: New Architectural Developments: Data Access Layer and REST Webservices
The first main development is the Data Access Layer which provides the application developer with an object-oriented view on the Openbravo database. The Data Access Layer is also used to support new XML conversion functionality which allows the application developer to convert business objects from and to XML. The XML conversion logic again forms the basis for export and import of Client data and new REST webservices functionality provided in Openbravo 2.50.
I will cover these new developments in a series of posts which will be published the coming weeks.
In this first post for Openbravo, let me also introduce myself. I am responsible for some of the new architecture developments at Openbravo, both design and development. My background is both in ERP system as well as technical Java coding. Next to Openbravo I am involved in open source development as a committer of the Eclipse Modeling Framework project. I am looking forward to work further on extending the Openbravo architecture and hope for extensive feedback from the community on the new developments in the Openbravo 2.50 release.
The starting point for the blog series will be the new Data Access Layer (DAL). The DAL provides an object-oriented layer over the Openbravo database. It is based on Hibernate using model-driven code generation techniques. The Data Access Layer provides the application developer with the following functionality:
- type safe querying and retrieval of business objects from the database.
- a convenient API to update or create new data in the database.
- a type safe interface to update information of a business object, increased productivity by making the properties of a business object directly visible through getters and setters (in the development environment).
- transaction and context handling.
- security and validation checking.
- automatically maps new entries in the application dictionary to database tables and columns.
- generates Java class business objects (and their associations) on the basis of the Application Dictionary model.
With the DAL the application developer does not need to type in tedious/type-unsafe sql queries. He/she can make use of the code completion and compile time checking functionality of his/her development environment. The Data Access Layer can also be easily integrated in test driven development approach as it operates independent from servlet containers such as Tomcat.
The Data Access Layer uses an in-memory representation of the application dictionary (the runtime model). This runtime model is used to convert business objects from and to XML. The XML conversion functionality is very usefull for integration scenarios. It is the basis for new functions such as the export and import of Client data and Webservice functionality. The XML Conversion functionality will be discussed in a separate technical post.
The 2.50 release also provides completely new REST webservice functionality. The REST webservice offers a common APO to query, retrieve and update all Openbravo business objects (persisted in the database). The REST webservice can be reached using simple (REST) URI's making it easy to use, test and try out. The Openbravo REST framework is easy to extend and allows you to add your own (REST) webservices. I will spend a separate post on REST Webservices and how to create your own WebService.
This post was just an introduction to give you a feel for what is coming in 2.50. The next posts will dive into more details, starting with an architecture description followed by the standard Hello World DAL example!



