Home  Development Resources  EMail 
Home > Development Resources > AppQuery

Online Application Usage Query


A web application with complete source code for online internet service monitoring that provides a simple query interface to list sessions and related requests using Struts Tiles, EJB 2.x persistence and JAAS authentication.


AppQuery is a web application for online internet service monitoring. Other such solutions exist, some commercial with all kinds of report generators, to gather information on how users navigate a website, what functionalities are most popular, referrers and what other websites were visited, to name some.

The functionality of AppQuery is fairly basic, it offers an interface to list user requests with parameters, ordered by user session and period of time. Please use the guest login "guest/guest" to see for yourself. Query results will be limited to the activity on AppQuery.

AppQuery comprises Struts tiles, JAAS authentication, an Enterprise Java Bean (EJB 2.x CMP) interface to SQL databases, Session Facade beans and named sequences to generate primary key values. To run AppQuery, you will need a Servlet/JSP specification 2.3/1.2 servlet container for the web application, a specification 2.0 EJB container, like JBoss 4.x, for the enterprise beans and the following components:

  • Appquery web application (appquery.war)
  • Struts extensions (included in appquery.war)
  • Application usage query and logging enterprise beans (appusageEJB.jar)
  • Named sequences library (crusius-persist.jar)


To deploy AppQuery, copy appquery.war and appusageEJB.jar to your server's deployment directory and the sequences library crusius-persist.jar into the server's class path. The Struts extensions are included in the web application.

Unless you change the deployment descriptors, the appusage beans will look for a data source "appusageDS". The source-tarball for appusage includes a DDL script to create the required tables on MySQL 4.x with InnoDB extension.

Furthermore, AppQuery requires a login module for JAAS authentication. The login context is hard coded "appuser-login", which defaults to "other" on JBoss. You can use any standard login module, so long as at least one principal of type "java.security.acl.Group" named "Roles", containing at least one member or named role, is returned.

On JBoss login modules, refer to the JBoss documentation, keywords LoginContext, UsersRolesLoginModule, AbstractServerLoginModule. If you want to adapt AppQuery authentication to your needs, "AuthenticationService" in package "info.crusius.auth.jaas" is the class to look for. Also, see the instructions for the installation of a basic login module below.

Login Module

To install the provided basic login module, copy usermodelEJB.jar into your server's deployment directory. The contained CMP 2.x EJBs will look for a data source named "appuserDS". MySQL create scripts and a JUnit init testcase for the data scheme are part of the usermodel source-tarball. The user model beans are a proof of concept implementation of a temporal database design, which cannot be discussed within the scope of this article. For the login module, they provide a mechanism to associate a login name with roles and to verify a password.

The login module crusius-loginmodule.jar then needs to be copied into your server's class path. The login module will load the user model's LoginSessionBean by Jndi lookup. To enable the login module, add the following application policy to the server's login configuration "login-config.xml":

    <!-- Login via crusius-loginmodule -->
    <application-policy name = "appuser-login">
          <login-module code = "info.crusius.loginmodule.JndiLoginModule"
             flag = "required">
		name = "jndiName">ejb/usermodel/LoginSession</module-option>
		name = "cacheHome">false</module-option>


The EJB.jar files are not fully compliant with the EJB specifiation and do not work on Bea Weblogic Server.