Home Programming Apache OfBiz Cookbook

Apache OfBiz Cookbook

books-svg-icon Book
eBook $28.99 $19.99
Print $48.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $28.99 $19.99
Print $48.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Getting Started
About this book
Apache Open For Business (OFBiz) is an enterprise resource planning (ERP) system that provides a common data model and an extensive set of business processes. But without proper guidance on developing performance-critical applications, it is easy to make the wrong design and technology decisions. The power and promise of Apache OFBiz is comprehensively revealed in a collection of self-contained, quick, practical recipes in this Cookbook. This book covers a range of topics from initial system setup to web application and HTML page creation, Java development, and data maintenance tasks. Focusing on a series of the most commonly performed OFBiz tasks, it provides clear, cogent, and easy-to-follow instructions designed to make the most of your OFBiz experience. Let this book be your guide to enhancing your OFBiz productivity by saving you valuable time. Written specifically to give clear and straightforward answers to the most commonly asked OFBiz questions, this compendium of OFBiz recipes will show you everything you need to know to get things done in OFBiz. Whether you are new to OFBiz or an old pro, you are sure to find many useful hints and handy tips here. Topics range from getting started to configuration and system setup, security and database management through the final stages of developing and testing new OFBiz applications.
Publication date:
September 2010
Publisher
Packt
Pages
300
ISBN
9781847199188

 

Chapter 1. Getting Started

The OFBiz project is a collection of hundreds of directories and files, organized to allow for easy download, start-up, customization, and enterprise deployment.

In this chapter, we shall look at a number of commonly performed tasks related to setting up and running with OFBiz, including:

  • Getting the project code

  • Getting code from the Apache Subversion source code repository

  • Fixing IP port collision error

  • Setting the JAVA_HOME environment variable

  • Fixing "Class Not Found" errors

  • Installation verification

  • SSL operational verification

  • Running JUnit tests

  • Finding an OFBiz Component's top-level directory

  • Locating an OFBiz Application

Introduction

OFBiz appeals to a remarkably diverse audience because of the breadth of solutions it enables. Whether you are a software developer or a business owner, you will find much to surprise, delight, and, most importantly use for your next enterprise software endeavor under the OFBiz umbrella.

In fact, there is so much to OFBiz that it is often difficult to know where to start. Unlike learning HTML or Java, OFBiz has no specification or authoritative source acting as the final arbiter of what works or is "correct". Rather, OFBiz is a well organized collection of "artifacts" that may, at the user's discretion, be mixed, matched, reorganized, and augmented with new artifacts to arrive at just about any business solution imaginable.

Just imagine an open source software project that includes:

  • Its own database schema and seed data already loaded and ready to run.

  • An event-driven Service engine that enables code reusability across the entire instance. Services may be written in Java or any supported language, including Groovy, Bean Shell, JPython, and more.

  • Hundreds of business logic workflow implementations ranging from a complete e-commerce Application to manufacturing and MRP, content management, user authentication, and authorization support all out-of-the-box and ready to use.

  • Everything you need to serve up complete browser compliant User Interfaces (UI).

  • And much more!

With all the possibilities that OFBiz brings to the table, where does one begin? From experience, the best way to get up and running quickly is to download the project code and start kicking the "tires". Use some of the suggestions in this book to help quickly experience some of the state-of-the-art tools, utilities, and complete Applications that are part of OFBiz out-of-the-box.

Always remember: there is no "right" or "wrong" way to doing anything with OFBiz.

Everything you need to get up and running quickly and with minimum fuss is packaged with the OFBiz distribution. That includes an integrated database, a ready to use web server, and all the network and communications infrastructure necessary to be up and running in minutes. All you need to do before you download OFBiz is:

  • Ensure that the prerequisite Java Software Development Kit (SDK) is installed. Please see the following table.

  • Access to a reliable Internet connection.

  • A modern browser handy to do some installation verification.

How do you know which version of Java to install? The following table summarizes available download options and necessary Java prerequisites:

Download title

Recommended usage

Minimum Java version

OFBiz version

apache-ofbiz-09.04.zip

Recommended for new users and those looking for the most stable project package.

Java 1.5

*

apache-ofbiz-4.0.zip

Legacy release. Not recommended for new users.

Java 1.4 or Java 1.5

 

"Nightly Trunk Builds"

ofbiz-trunk-current.zip

Project committers or users needing latest code. May not be stable or thoroughly tested!

These files are available on the "snapshots" download page.

Java 1.6

* *

Nightly trunk builds do not have release numbers.

* Nightly builds and version numbers represent bug fixes only.

* * "trunk" versions before January 2010, Java 1.5

Once OFBiz is downloaded and available locally on your hard drive, install it by "unpacking" it with your operating system's "unzip" tool.

Once unzipped, OFBiz is ready to run.

Note

Looking for the Java SDK?

Most Java SDKs are available from Sun Microsystems at:

http://www.java.com/

MAC users will need to contact Apple directly or use the Software Update feature available on the Apple menu.

 

Introduction


OFBiz appeals to a remarkably diverse audience because of the breadth of solutions it enables. Whether you are a software developer or a business owner, you will find much to surprise, delight, and, most importantly use for your next enterprise software endeavor under the OFBiz umbrella.

In fact, there is so much to OFBiz that it is often difficult to know where to start. Unlike learning HTML or Java, OFBiz has no specification or authoritative source acting as the final arbiter of what works or is "correct". Rather, OFBiz is a well organized collection of "artifacts" that may, at the user's discretion, be mixed, matched, reorganized, and augmented with new artifacts to arrive at just about any business solution imaginable.

Just imagine an open source software project that includes:

  • Its own database schema and seed data already loaded and ready to run.

  • An event-driven Service engine that enables code reusability across the entire instance. Services may be written in Java or any supported language, including Groovy, Bean Shell, JPython, and more.

  • Hundreds of business logic workflow implementations ranging from a complete e-commerce Application to manufacturing and MRP, content management, user authentication, and authorization support all out-of-the-box and ready to use.

  • Everything you need to serve up complete browser compliant User Interfaces (UI).

  • And much more!

With all the possibilities that OFBiz brings to the table, where does one begin? From experience, the best way to get up and running quickly is to download the project code and start kicking the "tires". Use some of the suggestions in this book to help quickly experience some of the state-of-the-art tools, utilities, and complete Applications that are part of OFBiz out-of-the-box.

Always remember: there is no "right" or "wrong" way to doing anything with OFBiz.

Everything you need to get up and running quickly and with minimum fuss is packaged with the OFBiz distribution. That includes an integrated database, a ready to use web server, and all the network and communications infrastructure necessary to be up and running in minutes. All you need to do before you download OFBiz is:

  • Ensure that the prerequisite Java Software Development Kit (SDK) is installed. Please see the following table.

  • Access to a reliable Internet connection.

  • A modern browser handy to do some installation verification.

How do you know which version of Java to install? The following table summarizes available download options and necessary Java prerequisites:

Download title

Recommended usage

Minimum Java version

OFBiz version

apache-ofbiz-09.04.zip

Recommended for new users and those looking for the most stable project package.

Java 1.5

*

apache-ofbiz-4.0.zip

Legacy release. Not recommended for new users.

Java 1.4 or Java 1.5

 

"Nightly Trunk Builds"

ofbiz-trunk-current.zip

Project committers or users needing latest code. May not be stable or thoroughly tested!

These files are available on the "snapshots" download page.

Java 1.6

* *

Nightly trunk builds do not have release numbers.

* Nightly builds and version numbers represent bug fixes only.

* * "trunk" versions before January 2010, Java 1.5

Once OFBiz is downloaded and available locally on your hard drive, install it by "unpacking" it with your operating system's "unzip" tool.

Once unzipped, OFBiz is ready to run.

Note

Looking for the Java SDK?

Most Java SDKs are available from Sun Microsystems at:

http://www.java.com/

MAC users will need to contact Apple directly or use the Software Update feature available on the Apple menu.

 

Getting the project code


Because OFBiz is more than just a few randomly organized files and directories, the collective and organized resources that go into making OFBiz, including the Apache infrastructure and software developers, are often called the "Project". The OFBiz project generates OFBiz code that is stored in a Subversion source code repository. It is a release and version of this code, extracted from the source code repository, built, and packaged using a "zip" archive tool, that we download as an OFBiz user.

Getting ready

Decide which version to download. It is recommended that new users download OFBiz Release 9.04. Experienced users and those wishing to contribute back to the project should consider starting with the latest version of the OFBiz source code "trunk". This code may be found on the Apache OFBiz "snapshot" web page.

Ensure you have the following necessary prerequisites in place:

  • A computer with a Java Virtual Machine (JVM) installed. If you are unsure of the version, please refer to the table provided in the introduction to this chapter.

  • A modern browser (Internet Explorer, Firefox, Safari, Opera or the like).

  • Internet connection with HTTP access to the OFBiz download website.

How to do it...

Apache OFBiz can be downloaded as shown in the following steps:

  1. 1. Using your browser, navigate to the Apache OFBiz download site (http://ofbiz.apache.org/download.html) to reveal the Download Apache OFBiz web page as shown:

  1. 2. Use your browser to select the desired OFBiz release. New users are urged to download the release represented by the apache-ofbiz-09.04.zip file. At any point in time, this download represents the most stable release of OFBiz.

  2. 3. Commence the download by clicking on the file link provided.

Note

Note: The official OFBiz download website is often in a state of flux. At times, you may be directed to a mirror site before you are allowed to download any code. On other occasions, clicking the OFBiz download file will directly initiate the download. If you find this all very confusing, you are not alone. Feel free to comment on the official OFBiz mailing list and voice your opinion. More information about the OFBiz user mailing lists may be found here: https://cwiki.apache.org/confluence/display/OFBADMIN/Mailing+Lists

  1. 4. Once the download has completed, unpack OFBiz by running your operating system's unzip or equivalent command against the download file.

  2. 5. Change directories to the OFBiz install directory and run the following ANT command to build the distribution and load the database: ant run-install

  3. 6. After the ANT build script has completed, from the install directory run the appropriate OFBiz startup script provided for your operating system.

  4. 7. Optionally, run tests to verify that everything is working

How it works...

OFBiz is packaged to include everything you need to run right out-of-the-box. Once your download is on your desktop, all you need do is unbundle it, build the distribution using the provided ANT tool, and start it up. No other configuration steps are necessary.

There's more...

There are a number of ways to start up OFBiz. Depending on your operating system environment and your proclivities towards working on the command line, you may:

  • Use one of the provided start up scripts

  • Invoke OFBiz from the command line directly or use the ANT build tool as shown here:

Windows

Unix

Command line

startofbiz.bat

startofbiz.sh

java -Xmx256M -jar ofbiz.jar

ant run

OFBiz runs inside and depends on a JVM. Before OFBiz can even start up, the JVM must be operational. The distribution provides all the tools necessary in the form of startup scripts to get the JVM up and running without any further work on your part.

For the curious, the following summarizes the OFBiz start-up sequence. This information is useful if you ever want to integrate third-party code or add your own Java programs to the OFBiz mix:

  1. 1. The Java Virtual Machine (JVM) is started from one of the available startup scripts or the command line.

  2. 2. The OFBiz startup program (ofbiz.jar) is invoked as part of the JVM initialization.

  3. 3. OFBiz loads all Components, builds the Java classpath, initializes communications, and verifies connections to one or more configured databases. While the OFBiz distribution includes the embedded Derby database, any number and combination of other databases may be configured.

  4. 4. The embedded Tomcat http/https listener is started.

  5. 5. OFBiz is up and running!

See also

For more information on prerequisites, getting the OFBiz code, and downloading and starting OFBiz up, please visit the What Do I Get? section on the following OFBiz web page: http://ci.apache.org/projects/ofbiz/snapshots/

Note

Note: Be careful not to use the DOWNLOAD OFBIZ button on the snapshots download web page. Unless you want to download the latest OFBiz trunk nightly build, this button should not be confused with the DOWNLOAD OFBIZ button found on the official OFBiz loading web page: http://ofbiz.apache.org

 

Getting code from the Subversion repository


If you are planning to contribute back to the project or are just curious about downloading from the OFBiz source code control system, you may download a complete OFBiz package from the Subversion source code repository using the following procedure.

You will need a Subversion client, or an IDE with a Subversion client installed in order to access and download from Subversion.

Getting ready

Before you can download directly from the OFBiz Subversion repository, you must first have a Subversion client installed locally. Subversion clients come in several forms. The Subversion software comes with a command-line client and a command-line tool that facilitates checkout and download from a Subversion repository. This command is the co command.

Some users prefer to use built-in IDE (Integrated Development Environment) Subversion clients. One such client, Subclipse (http://subclpse.tigris.org), allows the user to checkout and install OFBiz from within the IDE using IDE-specific commands.

It goes without saying: you must also have an Internet connection with access to the OFBiz Subversion repository.

How to do it...

OFBiz source code can be downloaded from the Subversion repository by the following steps:

  1. 1. From a command-line window, type the following Subversion command:

    svn co http://svn.apache.org/repos/asf/ofbiz/trunk ofbiz
    
  2. 2. Navigate to the install directory. If you used the above command, navigate to the ofbiz directory. For UNIX users, a command similar to the following is suggested:

    cd ofbiz
    
  3. 3. Run the build script provided:

    ant run-install
    

How it works...

OFBiz project source code is saved in a repository managed by the Subversion source code control system. Subversion uses a tree-like structure to organize and group together project artifacts, including source code. Each time a project developer commits an artifact to the repository, a new OFBiz version number is created, similar to a leaf on a tree. The project has had thousands of commits over its lifetime, hence the current version number is well on its way towards one million.

To request a version of OFBiz from the repository, a user issues a Subversion checkout command, co. A Subversion checkout fetches by default the latest leaf or version of the project from the Subversion code tree.

The OFBiz source code repository contains all previous versions of OFBiz. You may checkout any version at any time. Additionally, you may checkout "releases" of OFBiz where a "release" is a "branch" of the source code tree, by indicating your desire using the co command options.

Once the fetch from the repository is complete, you must run the OFBiz build script to build the project before running the OFBiz startup scripts. The build script rebuilds all included Java programs, rebuilds the runtime CLASSPATH, and checks and loads the database with seed and demonstration data.

See also

For more information on using Eclipse with the OFBiz Subversion repository, please refer to the following OFBiz Wiki page:

http://cwiki.apache.org/confluence/display/OFBIZ/Running+and+Debugging+OFBiz+in+Eclipse

For more information on Subversion, please refer to the Subversion website located at:

http://subversion.tigris.org

 

Fixing IP port collision errors


One of the most common OFBiz startup errors involves IP port collisions. OFBiz requires several Internet Protocol (IP) ports to run. All OFBiz downloads have these ports set to default values so that you may start up OFBiz without further configuration.

Occasionally, these default values are in conflict with IP ports used by other software already running on your system. If OFBiz cannot acquire the ports it needs to run, it will immediately shutdown and you will receive an error similar to the following on the command line (from which you started OFBiz):

(main) [ Http11Protocol.java:178:ERROR]
Error initializing endpoint java.net.BindException: Address already in use: 8080

Getting ready

To remedy IP port conflicts, you may either turn off the software using the ports OFBiz needs or you can change the OFBiz configuration so that it uses ports not used by other software.

How to do it...

To change the OFBiz IP port configuration, perform the following:

  1. 1. Determine the port(s) that is/are in conflict by observing the console or command line window. Alternatively, you may view the primary OFBiz log file located in ~/runtime/logs/ofbiz.log

  2. 2. Locate the OFBiz configuration file where the port is set.

  3. 3. Edit the OFBiz configuration by changing the port number to a non-conflicting value.

  4. 4. Restart OFBiz.

How it works...

For example, to fix collisions on port 8080, the IP port that OFBiz listens on for HTTP requests, navigate to the ofbiz-containers.xml file as shown in the following figure and change the value for port 8080 to another port not in use.

Note

Note: Setting the HTTP port to a value between 1-1024 may require operating system administrative privileges in order to start up OFBiz. This is a constraint placed on these ports outside the control of OFBiz.

There's more...

The following is a list of IP port configuration file locators for reference:

Port #

Configuration file location relative to install directory

Port usage note

8080

~framework/base/config/ofbiz-containers.xml

Tomcat HTTP listener

 

~framework/webapp/config/url.properties

Internal HTTP port *

8443

~framework/base/config/ofbiz-containers.xml

Tomcat HTTPS listener

 

~framework/webapp/config/url.properties

Internal HTTPS port *

8009

~framework/base/config/ofbiz-containers.xml

AJP connector

9990

~framework/base/config/ofbiz-containers.xml

BeanShell remote telnet port

9991

~framework/base/config/ofbiz-containers.xml

Second, required telnet port

1099

~framework/base/config/rmi-containers.xml

JNDI/RMI dispatcher

10523

~startofbiz.sh ~startofbiz.bat ~startofbizNoLog.bat ~stopofbiz.sh

Admin port to start/stop OFBiz

389

~framework/base/config/jndiLdap.properties

LDAP port**

* Internal ports are used by OFBiz to translate HTTP port references internal to the framework. For example, OFBiz automatically translates between HTTP and HTTPS if a user requests an Application running on a secure port, but the user enters the wrong protocol and/or port number; OFBiz knows based on these settings how to correct the URL request.

** This port is not checked at OFBiz start-up.

 

The JAVA_HOME setting


OFBiz startup scripts must invoke the Java executable as part of its initiation process. If you are using one of the provided startup scripts and you can't start up OFBiz because the Java executable cannot be found (you will get an immediate error to this effect), you can easily add the necessary statement to the script to indicate the location of the Java executable.

Note

Note: The scripts as they are distributed today assume that you have previously set the JAVA_HOME environment variable using your computer's environment variable setting tools to the location of the Java runtime executable. This setting should be in the environment prior to invoking the OFBiz startup script. If this location has not been set or has been set incorrectly, you will not be able to start up OFBiz.

Getting ready

To set up JAVA_HOME, you need to first perform the following steps:

  1. 1. Determine the location of the appropriate version of Java given the release of OFBiz installed.

  2. 2. Navigate to the install directory where the startup scripts are located.

  3. 3. Open up the appropriate startup script (startofbiz.bat for Windows or startofbiz.sh for Unix).

How to do it...

JAVA_HOME can be set up in the following way:

  1. 1. Add a line similar to the following prior to the comment line "location of java executables" as shown in the following snippet from the Unix startofbiz.sh startup script shown here:

    # This is an example of setting the JAVA_HOME variable in the
    # UNIX startofbiz.sh script:
    JAVA_HOME=/bin/java
    export JAVA_HOME
    # location of java executables
    if [ -f "$JAVA_HOME/bin/java" ]; then
    JAVA="$JAVA_HOME/bin/java"
    else
    JAVA=java
    fi
    
  2. 2. Save your changes.

  3. 3. Restart OFBiz using the modified startup script.

How it works...

The JAVA_HOME environment variable sets the location of the Java executable relative to the hard drive and the file system of the host operating system so that the startup scripts know where to find it. In this way, you could have many Java versions installed on your computer and still tell OFBiz which installed version to use at any point in time.

Out-of-the-box OFBiz assumes that the JAVA_HOME variable has been set prior to the invocation of the startup script. As an alternative to modifying startup scripts, you may also set JAVA_HOME from the command line prior to invoking the startup script.

There's more...

If you are starting up OFBiz from the command line and not using the startup scripts, you should set your JAVA_HOME prior to invoking OFBiz. For example, if your Java executable is located in the /opt/java directory (folder for Windows readers), and you are running a Unix system, then set the JAVA_HOME environment variable as follows:

JAVA_HOME=/opt/java
export $JAVA_HOME
java jar ofbiz.jar
 

"Class Not Found" errors


Another startup error that you may encounter is a "Class Not Found" error. This is usually indicative of incompatibilities between the Java runtime in use and the version of OFBiz. These errors will show up in the console window and in the OFBiz log file (~runtime/logs/ofbiz.log), and occasionally as a web page error during normal OFBiz operations.

Getting ready

Tracking down the source of "Class Not Found" errors may involve some detective work. In some cases, these errors are not immediately fatal. If the error is causing OFBiz to immediately shutdown, then you most probably have an incompatibility between the OFBiz runtime and the version of the JVM in use.

To fix OFBiz startup "Class Not Found" errors, you must first determine the version of Java being invoked from the startup script or the command line. The following section shows how this can be determined.

How to do it...

To find out which version of the Java JVM OFBiz is running in and where your JAVA_HOME environment variable is pointing, perform the following:

  1. 1. Navigate to the OFBiz install directory.

  2. 2. As the user invoking the startup script or command line Java execute statement, type in the following Java command:

    java version
    

If the information returned does not say 1.5 or 1.6, then you will need to install the Java 1.5 or 1.6 SDK. You may also need to modify the JAVA_HOME variable as shown previously.

How it works...

The Java runtime executable may be invoked with the -version parameter to return the version of the JVM being called. When executed this way, the JVM is started, the version number is checked, and then the JVM is shutdown.

Running this command as the same user who invokes the OFBiz startup scripts ensures that you pass to the JVM the same environment settings, including the JAVA_HOME setting that will be available when the startup script is invoked. In this way, you may quickly determine which version of Java you are running when you start up OFBiz.

If the version number returned is not compatible with the OFBiz release you are running, then you will need to either set your JAVA_HOME variable as shown previously to the appropriate version of Java or install the necessary Java SDK. The following table summarizes OFBiz Java dependencies:

Release

Java version

OFBiz 9.04

1.5

OFBiz 4.0

1.5

OFBiz trunk

1.6

There's more...

There is no recommended Java reference platform for OFBiz. Known implementations of the Java SDK that have successfully built OFBiz include the Sun and Mac Java SDKs.

 

Installation verification


To quickly ascertain if OFBiz has installed correctly and is ready for use, you may use your browser to view various OFBiz Application features, including the built-in e-commerce demonstration store.

Getting ready

Once OFBiz is unpacked and, if downloaded from the Subversion repository, built using the ant run-install command, you are ready to start the installation verification by observing the OFBiz e-commerce demonstration store.

How to do it...

To view the e-commerce demonstration store, follow these steps:

  1. 1. Change to the OFBiz install directory.

  2. 2. Start OFBiz using one of the startup scripts provided or directly from the command line.

  3. 3. Open a web browser and enter the URL of the OFBiz e-commerce Application demonstration website: http://localhost:8080/ecommerce

  4. 4. Observe the OFBiz e-commerce demonstration store's main web page. It should look something like the following:

  5. 5. If the web page displays correctly, then you may be confident that at least the OFBiz database and web server software are operating correctly.

How it works...

A quick and easy way to verify that your OFBiz download is working correctly is to start an instance and observe that one of the non-password protected Applications is operational. The OFBiz e-commerce Application, a fully-featured e-commerce website store, is a robust and demanding OFBiz Application. Running the e-commerce Application demonstrates and exercises many core OFBiz features including, but not limited to, successful operations of the following:

  • OFBiz Entity engine

  • OFBiz Service engine

  • Integrated web server (Apache Tomcat)

  • Integrated Java servlet container (Apache Catalina/Tomcat)

  • Network connectivity

  • Web browser UI compliance

There's more...

If the main e-commerce web page is displayed and looks similar to that shown above then you may be confident that at least part of OFBiz is working correctly. This, however, should be considered simply the starting point.

 

SSL verification


It is entirely possible that the HTTP listener may be working, but secure URLs using the HTTPS protocol may not be. To verify that the Secure Sockets Layer (SSL) encryption works and that OFBiz is listening for web requests on the secure HTTPS configured port, navigate to the OFBiz WebTools main landing page and attempt to access any of the menu selections provided.

Getting ready

Aside from starting up an instance of OFBiz, there are no special prerequisites necessary to test OFBiz SSL support.

How to do it...

OFBiz SSL support can be tested by following these steps:

  1. 1. From any compliant web browser, enter the URL of an OFBiz password-protected Application. For example, enter the URL of the WebTools Application: http://localhost:8080/webtools

  2. 2. The WebTools Application has a main landing web page as shown below. This web page is not password-protected. In order to access the protected WebTools applications, you must select the Login link on this main landing page as shown in the following:

  1. 3. When presented with the WebTools login screen, login using the default username of admin and default password of ofbiz. This HTML login form should look something like the following:

  2. 4. Successful login will bring up the protected portion of the WebTools Application UI. Observe that you are able to see the main web page as shown here:

How it works...

The SSL protocol implementation is an integral part of the OFBiz project. Out-of-the-box, OFBiz is configured to use the HTTPS protocol running on port 8443 to support SSL. All password-protected portions of the project use SSL keys and encryption to secure the transfer and storage of sensitive information.

OFBiz comes with the necessary SSL certificate installed to support a generic web browser to web server SSL environment. By accessing password-protected web pages such as the WebTools main menu, you effectively are exercising the built-in support for the SSL implementation.

Note

Note: HTTPS, SSL and SSL encryption are no substitutes for a firewall and a well thought-out security policy.

There's more...

WebTools, like all OFBiz backend Applications, has been configured to require authentication prior to access. The default OFBiz authentication process forces the user to access any SSL-secured URL through the HTTPS port. The astute observer may have noticed that WebTools was initially accessed using the HTTP protocol on port 8080. If OFBiz is working correctly, it will automatically make the translation from HTTP port 8080 to HTTPS port 8443.

See also

For more on security, refer to Chapter 7, OFBiz Security.

 

Running JUnit tests


Beyond simple "is it running ok?" types of tests, OFBiz comes with many JUnit tests that you can run. JUnit exercises very specific processing logic within OFBiz, and success or failure of any particular JUnit test is not an indication of OFBiz overall health.

Getting ready

The following must be performed first of all:

  1. 1. If OFBiz is running, shut it down by running the shutdown script provided or by killing the Java process from the command line.

  2. 2. Navigate to the OFBiz install directory.

How to do it...

JUnit tests can be run in the following way:

  1. 1. Open a command line in the OFBiz install directory.

  2. 2. Run the following ANT command to start all available JUnit tests, ant run-tests

  3. 3. Observe the results by reviewing the OFBiz ofbiz.log logfile located in the ~runtime/logs directory or the output on the command line from which the JUnit test command was invoked.

How it works...

Out-of-the-box OFBiz comes complete with many JUnit test scenarios embedded within the code base. The provided ANT target directives, when invoked, run through all available tests, redirecting results to the primary OFBiz logfile located in the ~runtime/logs/ofbiz.log file.

There's more...

JUnit test results are intermixed with standard logfile text. A sample of what you may expect to see after running all tests from the command line is extracted from the OFBiz logfile (~runtime/logs/ofbiz.log) and shown here:

 

Locating an OFBiz Component


The OFBiz project is organized into groups of directories and files where some directories have a special meaning and are called "Components". To find an OFBiz Component is to find the top-level directory where the Component begins and to locate the configuration file ofbiz-component.xml used to configure that Component.

Note

Note: OFBiz is flexible enough to support an unlimited number of Components. To enable this feature, OFBiz has its own Component configuration files starting with the file located in ~framework/base/config/component-load.xml. This recipe assumes you are looking for and wish to navigate to the top-level location of an existing Component as configured in this and other OFBiz Component configuration settings files.

Getting ready

Before the Component can be located, the following prerequisites should be met:

  1. 1. Determine the name of the Component you are searching for.

  2. 2. Make sure you have the Component name and not the Application name.

  3. 3. If you know which parent grouping the Component falls into, make note of this directory name. The basic OFBiz directory layout is shown here:

How to do it...

To locate the Component, perform the following:

  1. 1. Navigate to the OFBiz install directory.

  2. 2. If you know the parent directory name for this Component, navigate to that directory.

  3. 3. If you do not know the name of the parent Component directory, search each of the OFBiz Component parent directories for the directory with the same name as the Component name you are looking for.

  4. 4. When you find a match, you will have located your Component.

Note

Note: This technique only works if you have not altered any of the Component configuration files discussed later. Because OFBiz may be configured to support any number of Components located anywhere within the code base, a Component's name and a Component's location are only guaranteed to be the same out-of-the-box. This guarantee is predicated on nothing more than best practices. Take note that under normal circumstances, the Component's name and top-level directory name most probably will be the same.

How it works...

The OFBiz distribution is organized into directories and files. At the highest level is the installation or install directory. This directory contains all the files needed by OFBiz to start up and run. It also contains the five parent Component directories:

  • The framework directory contains all the Components necessary to run OFBiz. Many of the other Components have dependencies on Components in this directory. This directory is loaded first during system initialization.

  • The applications directory contains Components that represent many of the business related Applications packaged with OFBiz. For example, you will find the manufacturing, content management, and order management Components and associated Applications in this directory.

  • The specialpurpose directory contains yet more OFBiz packaged Applications and Components.

  • The themes directory contains the resources necessary to implement one or more OFBiz themes.

  • The hot-deploy directory is intended for the placement of new Components and Applications. Out-of-the-box it is empty, containing no OFBiz artifacts.

These parent directories are not Components in and of themselves, but rather are directories that group similar Components. Organizing Components this way makes it easier for humans to find specific Components. It also allows OFBiz to load Components in a pre-set order.

A master list of all Components within an OFBiz installation is found in the ~framework/base/config/component-load.xml file. This file informs OFBiz which parent Component directories should be searched for the parent Component directory configuration file: component-load.xml. Within each component-load.xml file are found directives instructing OFBiz on which Components to load per parent Component directory.

There's more...

You may exclude an entire parent Component directory and all its contained Components from being loaded by commenting out directives in the ~framework/base/config/component-load.xml. You may also exclude individual Components from loading by commenting the appropriate component-load.xml for each individual parent Component.

 

Locating an OFBiz Application


An OFBiz "Application" is a set of directories and files that are located within a Component. Referred to as "webapps", an OFBiz Application may contain all the artifacts necessary to deliver a web browser-compliant UI. As a testament to its flexibility, an OFBiz instance and any OFBiz Component may include an unlimited number of webapps.

An OFBiz Application is defined by the presence of the webapp directory located just beneath a containing Component's top-level directory, and may include one or more of the following files and directories:

  • A single WEB-INF directory

  • Beneath the WEB-INF directory, find a web.xml deployment descriptor file

  • Also beneath the WEB-INF directory, a controller.xml controller servlet configuration file may be present

  • Many other resources may be present depending on the needs of the Application

Getting ready

To locate an Application, firstly the following should be taken care of:

  1. 1. Determine the name of the Application you are searching for.

  2. 2. Try to ascertain the Component in which this Application is located An OFBiz Component may have one or more OFBiz Applications within it.

How to do it...

To locate the Application, perform the following:

  1. 1. Navigate to the OFBiz install directory.

  2. 2. If you know the name of the Component in which this Application is located, navigate to that Component's top-level directory.

  3. 3. Open the ofbiz-component.xml file in the top-level Component directory. In this file, locate any XML elements starting with a webapp tag. There may be many of these declarations within a single ofbiz-component.xml file. Each declaration represents the configuration of a single OFBiz web Application. For example, the following is taken from the OFBiz e-commerce Component. Two OFBiz Applications, the"eccomerce" and the"ecomclone", are configured. The top-level directory location of each Component is given by the location attribute value for the webapp element:

    <webapp name="ecommerce"
    title="eCommerce"
    server="default-server"
    location="webapp/ecommerce"
    mount-point="/"
    app-bar-display="false"/>
    <webapp name="ecomclone"
    title="eCommerce Clone"
    server="default-server"
    location="webapp/ecomclone"
    mount-point="/ecomclone"
    app-bar-display="false"/>
    

How it works...

OFBiz Applications are configured for each Component using the ofbiz-component.xml file. If one or more webapp elements are present in an ofbiz-component.xml file, this is a trigger to OFBiz that there are Applications for this Component. OFBiz will attempt to load all Component applications in the order defined in the ofbiz-component.xml file at system startup.

There's more...

To mount an Application as the "root" Application, set the mount-point attribute value to"/" as shown earlier. This will change the default URL for this webapp from http://localhost:8080/name to http://localhost:8080/. Only one webapp may be set to the root mount-point per OFBiz instance.

Latest Reviews (2 reviews total)
Book very out of date with recent versions of ERP software
Very helpful to understand the very basic of OFBiz, but I must say it's outdated. Huge expectations for major updates.
Apache OfBiz Cookbook
Unlock this book and the full library FREE for 7 days
Start now