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

Here is the first version of an experimental WTP plugin, which performs deployment according to the JSR88 specification: http://jcp.org/en/jsr/detail?id=88. This should allow even remote deployment (a local JBoss installation is still required so that Eclips finds the required JavaEE libraries, but by setting the "server address" config parameter, one should be able to do remote deployment).

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

The plugin is tested with WTP 3.0 and JBoss version 4.2 and 5.0.

Usage

Simply unzip buildfiles_JSR88_2008-12-22.zip to your Eclipse installation, subdirectory "plugins\org.eclipse.jst.server.generic.jboss_1.5.205.v200805140145". This overwrites "jboss323.xml", and it adds a subdirectory with some classes and the source code.
It will run without any further actions required, you can even "install" it while Eclipse is running.

The JBoss classes might create some Log4J output, so a "log4j.xml" is contained in the zip (JBoss 5.0GA seems to have introduced this logging). My "log4j.xml" switches off all output, because undeploy always results in an ERROR output (though undeploy seems valid).

JBoss 4.2 and 5.0CR2 or earlier:
The ant task includes all JAR files in the relevant JBoss lib directories (because exceptions must be deserializable on client side). Unfortunately, a lot of them moved in JBoss 5.0 GA from "server/default/lib" to "common/lib". So, if you use this version, open "jboss323.xml" and comment/remove those lines:
		<fileset dir="${serverRootDirectory}/common/lib" >
			<include name="**/*.jar"/>
		</fileset>
Hopefully, Eclipse will upgrade its Ant to 1.7.1, because this one allows optional filesets (erroronmissingdir="false").

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 "plugins\org.eclipse.jst.server.generic.jboss_1.5.205.v200805140145\plugin.xml", edit the "serverTypes" extension point and add the bold line (startBeforePublish="true") for the JBoss version you use:
	<extension point="org.eclipse.wst.server.core.serverTypes">
	     <serverType
	           ....   
	     </serverType>
	     <serverType
	           runtime="true"
	           class="org.eclipse.jst.server.generic.core.internal.GenericServer"
	           id="org.eclipse.jst.server.generic.jboss5"
	           initialState="stopped"
	           supportsRemoteHosts="false"
	           runtimeTypeId="org.eclipse.jst.server.generic.runtime.jboss5"
	           description="%jboss5serverTypeDescription"
	           launchConfigId="org.eclipse.jst.server.generic.core.launchConfigurationType"
	           behaviourClass="org.eclipse.jst.server.generic.core.internal.GenericServerBehaviour"
	           name="%jboss5serverTypeName"
	           startTimeout="50000"
	           stopTimeout="15000"
	           hasConfiguration="false"
	           startBeforePublish="true"
	           launchModes="run,debug,profile">        
	     </serverType>
	</extension>
Important: restart Eclipse with the "-clean" parameter once to activate this setting!

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 2008-12-22
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).