Public stuff

Here you find some stuff resulting from my work as lecturer at the University of Applied Sciences Wiesbaden / Germany which might be interesting not only for my students but also for the rest of the world.
Feel free to use them in any way you want. I don't include any license, just do everything you ever wanted to do a piece of data. If you feel the need to do so you can even claim it be your own work ;-).

image without any importance



WTP 3.0: JBoss JSR88 deployment / JBoss 5.1CR1

This plugin contains two useful features:
The plugin is tested with WTP 2.0 and newer and JBoss version 4.2, 5.0 and 5.1CR1.

Requirements

The plugin requires Java 1.5 and Eclipse 3.3/WTP2.0 or newer.


Usage

There are two versions, which differ only in the ant buildfile used for JSR88. Eclipse 3.3 and 3.4 included Ant 1.7.0, while Eclipse 3.5 brings Ant 1.7.1. The latter brings the new feature of declaring classpath directories as optional. As JBoss 5.0GA introduced "common/lib", which is not present in previous versions, I need two different buildfiles for Ant 1.7.0 to declare the correct the classpath directories. For Ant 1.7.1/Eclipse 3.5, I can declare the "common/lib" directory as "optional", so I didn't need separate buildfiles.

Usage is the same for both: download the zip file, unzip it to your eclipse installation directory (the zip file contains the subdirectory "plugins\org.eclipse.jst.server.generic.jboss.jsr88ant170_1.0.0.v2009..."), and start Eclipse once with option "eclipse.exe -clean" to load the new plugin.
Now, you will find many new server runtimes.

Eclipse 3.3 (WTP 2.0) and Eclipse 3.4 (WTP 3.0): org.eclipse.jst.server.generic.jboss.jsr88ant170_1.0.1.v20090511.zip
This plugin version will not work with the 5.0 betas and community releases (JBoss 5.0 CR2 and before), because the classpath changed. It will only run with 5.0GA and newer.

Eclipse 3.5 (WTP 3.1): org.eclipse.jst.server.generic.jboss.jsr88ant171_1.0.1.v20090511.zip
This plugin version supports also 5.0CR2

One important note: If using JSR88 deployment, you have to perform a redeploy after each restart of JBoss! JSR88 deployed apps are unfortunately only available until the next server restart. This is a limitation of JBoss.


Internals

JSR88
All my JSR88 findings are documented in the JBoss wiki: http://www.jboss.org/community/docs/DOC-10988.

Logging
The JBoss classes might create some Log4J output, so a "log4j.xml" is contained in the zip. My "log4j.xml" switches off all output, because undeploy always results in an ERROR output (the deployer tries do delete the local file on undeploy, though it was already deleted on deploy).
But on rare occasions, it might happen that the plugin prints an error "Deployment failed. See server log", but there is no message in the server log. In this case, an internal error in the JSR88 client might have happened. So, open "buildfiles\log4j.xml" and set the log level to "TRACE" instead of its current value "OFF":
   <category name="org.jboss">
      <priority value="TRACE"/>
   </category>
The logging output is directed to the console output of the build task.

Optimizing WTP WTP performs an asynchronous publishing, which means that publishing is started before server startup is done (really a problem if the publishing code communicates with the server). You could switch this off in the Preferences ("Server" -> "Launching" -> uncheck "Automatically publish when starting servers").
The better solution is to tell WTP to publish after full startup. In file "plugin.xml", I located the "serverTypes" extension point and added the bold line (startBeforePublish="true") for the JBoss version to change:
	<extension point="org.eclipse.wst.server.core.serverTypes">
	     ...
	     <serverType
	           runtime="true"
	           class="org.eclipse.jst.server.generic.core.internal.GenericServer"
	           id="org.eclipse.jst.server.generic.jboss5"
	           ...
	           hasConfiguration="false"
	           startBeforePublish="true"
	           launchModes="run,debug,profile">        
	     </serverType>
	</extension>


WTP 2.0: Serverdefinition with improved deployment support for JBoss 4.0 and JBoss 4.2

I added a bit of code to the generic JBoss plugin to support deployment in a better way.
There are two annoying things I wanted to avoid:
1) The WTP plugin has a 10 seconds timeout to wait for successful deployment. Can be annoying it you have a small app and a fast machine ;-).
2) This timeout might be insufficient for larger apps, so that a "Run" on e.g. a web project might fail because the app is not ready.

So I coded a class which is called from the Ant task and makes calls to the "MainDeployer" MBean of JBoss to check for successful deployments. It waits up to 30 seconds for successful deployment (this timeout can be configured in the ant file "jboss323.xml"), and after deployment it checks for errors and shows them in the console.

Usage

Simply unzip buildfiles_2008-02-02.zip to your Eclipse installation, subdirectory "plugins\org.eclipse.jst.server.generic.jboss_1.5.105.v200709061325". This overwrites "jboss323.xml", and it adds a subdirectory with some classes.
It will run without any further actions required, you can even "install" it while Eclipse is running.

It will work with JBoss 4.0 and 4.2, untested with previous versions. It will not work with JBoss 5.0 Beta2, because there the MainDeployer seems to be broken.

Config

There are two config values in "jboss323.xml":
Deployment timeout: this specifies how many seconds the the deployer will wait for deployment of the app. Default is "30 seconds"
<property name="deploy.timeout" value="30"/>

Debugging: if you see problems, you can switch on debugging by uncommenting these lines of code (arguments to each deployer):
<arg value="debug"/>

Code internals

Connecting to the server:
(simplified snippet, from http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIGetRemoteAccessToMyMBean)
    Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
    props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
    
    InitialContext ctx = new InitialContext(props);
    
    //Get the server connection:
    MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor"); 

Checking for deployed app:
    Boolean bolIsDeployed = Boolean.FALSE;
    while (bolIsDeployed.booleanValue() == false)
    {
      // Sleep a bit.
      Thread.sleep(100);

      Object objIsDeployed = server.invoke(objName, "isDeployed", new Object[] { strUrl },
          new String[] { "java.lang.String" });

      bolIsDeployed = (Boolean) objIsDeployed;
    } 
Of course real life is more complex, the deployer code also queries the org.jboss.deployment.DeploymentInfo to check for failed deployments. And I found that e.g. deploying a standalone EJB jar will not reach the proper DeploymentState, so additional checks are required.


WTP 2.0: Serverdefinition for JBoss 4.0.4/4.0.5 with EJB3 support

This adds support for JavaEE5 to the JBoss 4.0 plugin (although JBoss actually supports only EJB 3, but not the 2.5 web projects). But by adding this, you can create EJB3 projects with Eclipse.
Simply download plugin.xml and save it to your Eclipse installation, subdirectory "plugins\org.eclipse.jst.server.generic.jboss_1.5.105.v200709061325".

You will have to restart Eclipse with argument "-clean" once to update the plugin configuration.


WTP 1.5: Serverdefinition for JBoss 4.0.4/4.0.5 with EJB3 support, for JBoss 4.2.0 and for JBoss 5.0.0

Plugin overview and installation

With some small modifications I was able to use WTP 1.5 to develop a JEE5 enterprise application.
To use the plugin:
The plugin does not more than adding some additional JAR files to the project build path:

JBoss 4.0.x: JBoss 4.2.0:
JBoss 5.0.0:
"jboss-ejb3.jar", "jboss-ejb3x.jar" and "jboss-annotations-ejb3.jar" contain the classes and annotations needed to code the EJBs.
"jboss-aop-jdk50.jar", "jboss-aspect-library-jdk50.jar" are required by the application client to start up.
The Hibernate jars are required to enabled the application client to catch Hibernate Exceptions (if not caught by server code), and are necessary for Hibernate development in an EJB project.

Another feature is that the "server configuration" is no longer a combobox but a plain text field. This way it is possible to enter any configuration other than "default", "minimal" and "all".

The plugin should also run with WTP 1.0, but I did not verify this.

JavaEE5 in WTP 1.5

Unfortunately WTP 1.5 does not the provide the facets to support J2EE5, EJB3, WebModule 2.5 or ApplicationClient 5. So it is a bit tricky: You have to create a J2EE 1.4 project and modify the deployment descriptors afterwards (take care not to loose the "id=..." attributes in each document element !).

EAR project:
"application.xml" has to look like this (bold are the differences to the WTP generated files):
<?xml version="1.0" encoding="UTF-8"?>
<application
	version="5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">
	...
</application> 

EJB project:
"ejb-jar.xml" has to look like this:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar
	version="3.0"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                           http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
	...
</ejb-jar> 

Web project:
"web.xml" has this xml definition:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	version="2.5">
	...
</web-app> 

Application client project:
"application-client.xml" needs to be changed this way:
<?xml version="1.0" encoding="UTF-8"?>
<application-client 
	version="5"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_5.xsd">
	...	
</application-client> 

Now you can start coding your EJB3 beans.
I would advice to switch off the "EJB validator" in the ejb project, because it will detect invalid errors.

Here (Stateless.ear) is a small sample application. It contains one stateless session bean "GeometricModel" which provides two simple business methods. It is accessed with a web application and an application client. Import the EAR file into eclipse by choosing "Import" - "J2EE" - "EAR file".
Beware: the application client main class will not show up after the import. You have to restart eclipse to see it. The application client will also contain a dummy "Main" class in the default package. This is also a bug of the EAR importer. Simply delete it.


WTP 1.0: JBoss 4.0.x serverdefinition:

A JBoss 4.0 serverdefinition for the Eclipse Web Tools Plugin (http://www.eclipse.org/webtools/):
There are two versions of this plugin:
Windows: org.eclipse.jst.server.jboss_1.0.0.jar
Linux/MacOS: org.eclipse.jst.server.jboss_1.0.0.jar
Installation: Just copy it to the plugins directory of your eclipse installation und start Eclipse once with the "-clean" option.
It seems that on some Windows machines Internet Explorer saves this file with the extension ".zip". Rename to ".jar" !

I had two create two versions because the value of an environment variable in the buildfile "jboss40.xml" differs beetween Windows and Linux.
In the windows version you find this command:
<zipfileset dir="${module.dir}">
Linux/MacOS requires this one:
<zipfileset dir="${project.working.dir}/${module.name}">
The corresponding bug is "Ant based publisher fails on Linux": https://bugs.eclipse.org/bugs/show_bug.cgi?id=121415

Credits go to:
WTP 1.0.1 includes a built in JBoss4 serverdefinition, so this plugin is not needed any more !




If you are interested in my work the entry point for your search would be here: http://www.informatik.fh-wiesbaden.de/~knauf/index.html (all pages are in German).

Last Modified 2009-05-24
History:
2006-01-01: Created this page.
2006-01-03: Link to bug, more credits, ie zip file problem.
2006-01-04: "about.html" in plugins had invalid link.
2006-01-08: Added "%JBOSS_HOME%\server\default\lib\javax.servlet.jsp.jar" to the classpath declared by the plugin.
2006-01-15: Linux version of the plugin also needed for MacOS.
2006-01-31: comments about the integrated plugin in 1.0.1.
2006-08-27: Added the JBoss-EJB3 plugin.
2006-08-28: Added "<?xml version="1.0" encoding="UTF-8"?>" to all deployment descriptor header.
Updated plugin: from "org.eclipse.jst.server.jboss.ejb3_1.5.0.v200608271730.jar" to "org.eclipse.jst.server.jboss.ejb3_1.5.0.v200608282050.jar"
Remove a invalid "jboss40.serverdef" from the plugin. Added two new JAR references: "ejb3-persistence.jar" (for persistence annotations) and "hibernate-client.jar" (so that an application client sees hibernate exceptions, otherwise the stack trace would contain only an error message about a not found exception class)
2006-09-22: Some changes to the plugin because EJB3 RC9 has different client jars. Updated "org.eclipse.jst.server.jboss.ejb3_1.5.0.v200608282050.jar" to "org.eclipse.jst.server.jboss.ejb3_1.5.0.v200609222200.jar"
2006-10-11: Added "jboss-annotations-ejb3.jar" to the plugin (needed for JBoss specific annotations like "@SecurityDomain"). Updated "org.eclipse.jst.server.jboss.ejb3_1.5.0.v200609222200.jar" to "org.eclipse.jst.server.jboss.ejb3_1.5.0.v200610112000.jar"
2007-03-03: Added a modified plugin for WTP 2.0
2007-03-10: Added support for JBoss 4.2.0
2007-04-09: Added JBoss 5.0 to the server definitions.
Some cleanup in Stateless.ear sample (application client Manifest was invalid, eclipse warnings).
2007-05-17: replaced "/client/hibernate-client.jar" with "/server/default/lib/hibernate3.jar", "/server/default/lib/hibernate-annotations.jar" and "/server/default/lib/hibernate-entitymanager.jar" to allow full Hibernate Access
2007-05-19: Removed "hibernate-entitymanager.jar", added "commons-logging.jar" and "javassist.jar" (only for 4.2 and 5.0 server).
2007-06-05: Added "antlr.jar" for JBoss 4.2 and JBoss 5.0
2007-10-01: Removed the WTP 2.0 JBoss plugin because it is included in WTP 2.0 now. Instead, added a modified JBoss deployer which waits for successfull deployment.
2007-10-30: Removed three Javadoc warnings in the WTP 2.0 JBoss deployer
2007-11-09: Fixed a linux problem with deployment to a JBoss on a symlink
2008-02-02: "...-service.xml" files in EJB jars caused exception in deployer (resolution: lib/endorsed/xercesImpl.jar must be on the classpath).
2008-08-04: JSR88 deployer
2008-10-03: Configuring WTP to perform publishing after startup
2008-10-06: JSR88 deployer: errors on "Start" action are reported, no more StackTraces.
2008-11-07: Update link to changed JBoss wiki entry.
2008-12-17: JSR88 deployer: added "log4j.xml", fixed some javadoc warnings.
2008-12-22: JSR 88 deloyer: changed classpath to JBoss jars (previous plugin could not deserialize deployment exception because of JBoss 5 changes).
2009-04-10: replaced the JSR88 deployer with a full plugin for Eclipse 3.3/3.4/3.5. This plugin also supports JBoss 5.1Beta1
2009-05-11: Plugin for JBoss 5.1.0CR1 adds the VM argument "-Dxb.builder.useUnorderedSequence=true"
2009-05-24: Link to the JBoss 5.1.0 bug which automatically adds this VM argument