Using the NetBeans Platform on the Server with Wicket on the Client
<context-param>
<param-name>netBeansHome</param-name>
<param-value>{catalina.base}/webapps/blueOcean/WEB-INF/lib/blueocean</param-value>
</context-param>
<context-param>
<param-name>netBeansUserDir</param-name>
<param-value>{user.home}/.blueOcean/NetBeans</param-value>
</context-param>
As explained earlier, braces are used as macro-expansion, their content will be replaced by the value of the related system property. Two things are worth mentioning here:
- I'm supposing that I'll deploy the whole application as a single .war file. In this case, I will unpack the platform files under WEB-INF/lib/blueocean, that is pointed by the "netBeansHome" parameter. I'm relying on the fact that the property "catalina.base" points to the directory where Tomcat in installed.
- If you're using a different Web Container (e.g. Glassfish), this part has to be modified. Also, I'm relying on the fact that the Web Container will actually expand a .war file on the disk (they are not required to do that, and could work in memory). The server needs to be properly configured for these requirements.
A properly packed, all-inclusive .war file can be created with this ant target:
<target name="war" depends="build-zip">
<zip destfile="dist/blueocean.war">
<zipfileset src="WebApplicationWrapper/dist/WebApplicationWrapper.war" />
<zipfileset src="dist/blueocean.zip" prefix="WEB-INF/lib"/>
</zip>
</target>
which relies upon the Platform "build-zip" target for packaging your application into a complete .zip file.
During the development, re-creating the whole .war and redeploying it could take too long. In this case, you can override the web.xml settings with these two system properties like these (the most practical way to do is to create a new instance of Tomcat inside the NetBeans IDE):
-Dnetbeans.home=/Users/fritz/Business/Tidalwave/Projects/blueOcean/trunk/src/lib/platform
-Dnetbeans.build.dir=/Users/fritz/Business/Tidalwave/Projects/blueOcean/trunk/src/build/cluster
Both of them point to your working directory; the former to the base platform you're using for developing the application (in my case, a custom platform); the latter to the "build/cluster" directory, where NetBeans prepares the binary files for your application, laid out as a valid platform.
Now you just need to deploy the .war once, and then just compile your changes, and restart the .war inside Tomcat. Probably, working on it, it could be possible to play with the class loaders so you don't have to restart the .war every time. In any case, consider that the .war is very small, so it restarts almost immediately.
- Login or register to post comments
- 10805 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
harris goldstone replied on Fri, 2009/01/09 - 3:25pm
Fabrizio Giudici replied on Sun, 2009/01/11 - 7:12am
Hi Harris.
At the moment, the great advantage is for what concerns the tier of services and models, that is the business tier. It is something that can be best clarified by examples, and I'll post some in future here on DZone (also with other two "series" of posts about NetBeans Platform Idioms etc...); for the moment, take this small one: I have a Metadata infrastructure that allow to extract metadata from media (e.g. photos), eventually store them in a database, where they can be searched for. Every kind of metadata (EXIF, IPTC, whatever) is implemented by separate modules, as well as persistence in the database is enabled by just adding specific modules, without requiring any configuration. This means that I can easily satisfy different needs (blueMarine itself, blueOcean base, blueOcean as used by my customer, and hopefully other future customers) by just assembling different set of modules in specific custom platforms. This has been achieved mostly by means of the Lookup API (and in future I could use more the layer.xml facility). Most of this stuff could be used also by taking simple .jars as libraries out of the NetBeans Platform; but as the number of configurations increases, it is really important to have the capability of checking compatibilities and dependencies among modules. You could be always safe with a good testing, but in any case I appreciate when a static tool finds / prevents problems as early as possible. Furthermore, having the very same process for two different projects is a big time saver for me.
There are two different uses of the Platform that I'll evaluate soon. First is the "Event Bus" (based on "Central Lookup" by Wade Chandler) that I've talked about a few months ago; in blueMarine it introduces another great deal of decoupling that in the customer's project based on blueOcean I don't have yet. While the Event Bus as is works fine with a single user (it is a singleton), it must be adapted in the case of concurrency (it should be enough to write a variant based on ThreadLocal). Second is about the use of Nodes for a number of things, including dynamic generation of menus based on the functions that you have dynamically included in the current configuration. This is more sensible because of the cited potential problem with the AWT Thread, which would be a serious bottleneck on the server side.
aldobrucale replied on Mon, 2009/01/19 - 8:49am
org.netbeans.Mainfrom my module? It belongs to the Bootstrap module, but when I add this dependency and try to compile, the build system says that the module containing NetBeansPlatformUtils "is not a friend of<nb-platform-dir>/nbbuild/netbeans/platform9/lib/boot.jar".Fabrizio Giudici replied on Mon, 2009/01/19 - 9:08am
aldobrucale replied on Mon, 2009/01/19 - 11:22am
in response to: fabriziogiudici
Thank you Fabrizio, of course a module cannot boot the application that is supposed to load it!
I placed the servlet in a regular web project, now it works perfectly. Very interesting, thank you.