SelfDiagnose is a library of diagnotistic tasks that can verify the availability of external resources required for the execution of a J2EE web application.

How does it help?
When applications are deployed on a development, test or production environment, you need to perform integration tests to verify that all systems are working together and provide the application functionality.

Although your application is properly JUnit tested, the validity highly depends on its environment. For instance, the Web container should accept incoming requests, database connections can be established, log files are writeable, etc.

Depending on your level of automation in deployment, problems in the configuration of your environment will prevent the application from working as expected. And even if your environment is setup correctly, will it be available 24x7? SelfDiagnose can help detect such problems during both deployment and in production. Reports can provide information about possible causes of application problems that are related to the availability of external resources.

How does it work?
SelfDiagnose provides a collection of diagnostic tasks that check some external or internal aspect required by the application. For instance, the task CheckURLReachable verifies that a connection to a server can be opened. The task CheckJNDIBinding verifies that a resource can be found in a naming server. CheckDatabaseTableExists simply does what it says. Using a simple XML configuration, you specifiy which tasks should run. Running the tasks is requested through a servlet that responds with a report.

Let's Get Started

Task Selection Guide

Find the task to check the availability or configuration of your resource. To use a task, enter the declaration in the selfdiagnose.xml after you completed the Installation .

File System

CheckDirectoryAccessible <checkdirectoryaccessible name="/home/user" read="true" write="false" /> Verifies access properties of a directory in a File System.
CheckFileContainsString <checkfilecontainsstring name="" string="" /> Scans a file for at least one occurrence of a String. The file must be character-based and is found as a resource (on the classpath) or a simple file/url.
CheckPropertyValuesAreJavaTypes <checkpropertyvaluesarejavatypes name="" filter=".*[.]class" /> Verifies that each Java type name is loadable. The pattern parameter is used to filter only those keys for which the value represent a Java type.
CheckResourceAccessible <checkresourceaccessible name="" /> Verifies the availability of a resource by name on the classpath.


CheckJNDIBinding <checkjndibinding name="jdbc/mydb" /> Checks whether the naming server has a JNDI binding for a given name.
CheckDataSourceConnectable < checkdatasourceconnectable name="jdbc/demo" /> Verifies the availability and ability to create a connection to a DataSource.
CheckDatabaseTableExists < checkdatabasetableexists name="BUZ.CUSTOMERS" datasource="BusinessDs" /> Verifies whether a database schema has a definition for a table. This task requires a datasource. It uses the basic COUNT(*) query to detect table presence. If found then the number of records is reported.

Message Queue

CheckJNDIBinding < checkjndibinding name="jms/Orders" /> Check whether the naming server has a JNDI binding for a given name. Optional parameters are "class" , the JNDI server "url" and "factory". If you add a variable declaration then you can use CheckBeanProperty to access the properties of the Queue object. See also CheckWebSphereJMSListenerPort


CheckHttpRequestHeader < checkhttprequestheader header="Content-Type" protocol="http" pattern="text*" /> Reads a header field from the current Http Servlet Request and matches it against a pattern if specified.
CheckURLReachable < checkurlreachable url="" /> Verifies that an URL is reachable by connecting to it and inspecting the (http) response code.
CheckValidURL < checkvalidurl url="" /> Verifies the syntax of a given URL.
CheckXMLContent < checkxmlcontent url="${variable with URL value}" xpath="/root/child" pattern="childvalue" /> Verifies the presence of an element or attribute (by evaluating an XPath) and optionally test is against a given pattern.


ReportMavenPOMProperties < reportmavenpomproperties name="/META-INF/maven/package/app/" /> Reports information written by a Maven build.
CheckClassLoadable <checkclassloadable name="org.xml.sax.Attributes" /> Verifies that a given class is loadable.
CheckBeanProperty <checkbeanproperty bean="${name of var}" property="attribute name" pattern="regular expression"/> Checks a property and matches its (String) value to a regular expression pattern. This task can only be used together with another task that provides the bean by inserting a variable into the execution context
CheckSystemProperty <checksystemproperty property="java.version" /> Checks a global Java System property.
CheckValueMatches <checkvaluematches value="${country_names[0]}" pattern="NL" /> The value is specified by an expression that refers to objects available in the execution context. The pattern attribute speficy the regular expression that is used to perform the match against the value. If a variable is specified then store the element into the execution context using the variable name.
CheckResourceBundleKey <checkresourcebundlekey name="" key="welcome" /> Verifies the existence of a given key for a given resource.
CheckResourceProperty <checkresourceproperty name="" property="help.url" /> Verifies the availability of a property in a resource.
CheckMBeanProperty <checkmbeanproperty query="MyApp:name=myBean" operation="getVersion" /> CheckMBeanProperty is a DiagnosticTask that checks a property and matches its (String) value to a regular expression pattern.


ReportMavenPOMProperties <reportmavenpomproperties comment="Maven POM properties" name="/META-INF/maven/com.yours.appp/myapp/" /> ReportMavenPOMProperties is a task that reports the Maven build properties which are included in the application if it is build using Maven.
ReportJVMRuntimeMemory <reportjvmruntimememory comment="Java VM Memory" /> ReportJVMRuntimeMemory is a task that reports the current JVM memory consumption.
ReportProperties <reportproperties value="${myProperties}" comment=""/> ReportProperties can dump the key value pairs of a Properties object. This object must be available in the execution context of the tasks. Use a context variable to put a Properties in that context. Here by the name "myProperties".
ReportMap <reportmap value="${myMap}" comment=""/> ReportMap can dump the key value pairs of a Map object. This object must be available in the execution context of the tasks. Use a context variable to put a Properties in that context. Here by the name "myMap".
ReportJamonMonitors <reportjamonmonitors comment=""/> ReportJamonMonitors reports for each Monitor its main statistics values (hits,max,min,avg,last).

Third party (vendor)

CheckAtgComponentProperty <checkatgcomponentproperty component="/atg/dynamo/Configuration" property="siteHttpServerName" /> Checks the availability of a component and its property. If a pattern is specified then perform the match and report the result.
CheckEndecaService <checkendecaservice host="" port="8000" query="N=0" /> Checks the availability of an Endeca service by running a query. It reports the results of this query by count and execution time.
CheckWebSphereJMSListenerPort <checkwebspherejmslistenerport name="sli_caseStatusService-ontvangenBLIBerichtLp" /> Verifies the operational status of a ListenerPort in WAS.
CheckSpringBeanProperty <checkspringbeanproperty id="myBean" property="myFieldOrOperation" pattern="*.*"/> Checks the value of a property from an object that is available in the Spring ApplicationContext.
CheckSpringDatasourceConnectable <checkspringdatasourceconnectable name="myDatasource" /> Access a Datasource from the application context and uses that to check that a connection can be created (and closed)