You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
To clear some of the mystery
behind Seam apps deploying in JBoss5, we'll descibe what's going on during the deploy. We'll also describe a couple of easy workarounds to stop these issues occuring.
Most of the issues we're seeing is due new functionality we introduced in JBoss5 and its new kernel - Microcontainer (MC); unfortunately we still haven't fully explored and tested them. There are just too many details to consider!
So you just want to make JBoss 5 redeployment work well? Then just make these changes to JBoss AS (they will be included in 5.2 and later).
You'll need to open up $JBOSS_HOME/server/default/conf/bootstrap/profile.xml. First, remove line 100 (<value>WEB-INF/dev</value>); this causes the hot-deploy classes to be properly read by Seam.
Next, find line 82 (<property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>), and replace it with
<property name="filter">
<!-- A pattern matching filter. We can configure this to our custom pattern.
Here we configure it to include only application.xml and web.xml
for modification check (and any subsequent redeployments) -->
<bean class="org.jboss.system.server.profile.basic.PatternIncludeVirtualFileFilter">
<constructor>
<!-- Remember, the parameter is a regex so use the correct syntax
as below -->
<parameter class="java.lang.String">application.xml|web.xml</parameter>
</constructor>
</bean>
</property>
Finally, if you are seeing a continuous redeployment loop, you need to make sure there are no files like *.jsfdia or *.spdia (or other IDE generated temp files) in your WEB-INF/ or META-INF/. This actually requires a fix to the JBoss deployers code, and we are testing whether you can make a drop in replacement for the deployers jar.
One of the issues that actually caused the most changes to overall deployment lifecycle is JBAS-6117 - some thread in the background still does some work on the resources that were just deleted at undeployment. Hence you need a copy of those resources to be actually able to find them, even though they are deleted! We only remove the temp copy after undeploy completes.
We think this was already an issue in JBoss4, but nobody ever complained about it, since it was usually some error/warning at undeploy, which didn't look very important. But conceptually, there was still a problem which dealt with in JBoss5.
With introduction of JBoss VFS, we didn't see the need to do copy/temp by default, as the VFS can handle nested archives easily. However many frameworks, such as Wicket - as the example shows - assume resources are around at undeploy. You never really know when you're gonna need a copy to make your app properly cleanup.
There is a declarative mechanism in the MC Deployers, jboss-structure.xml, where you can define that your app should be temped. Of course, this would mean that every Seam application would have to place this file in its app to make the temping take place. Not good enough! We decided to make the temping optional via programmatic check - after MC Deployers finished recognition of structure, we actually check if the app is a Seam app and declare it to be temped while building Deployer's DeploymentContext instance. And this is what SeamModificationTypeMatcher does.
A deployer's StructureBuilder uses StructureProcessor to pre- and post-process Deployments and DeploymentContexts. The current impl of StructureProcessor is ModificationTypeStructureProcessor which takes a set of ModificationTypeMatchers and runs them over Deployment in progress to see if we need to change modification type.
<bean name="ModificationTypeStructureProcessor" class="org.jboss.deployers.vfs.plugins.structure.modify.ModificationTypeStructureProcessor">
<incallback method="addMatcher"/>
<uncallback method="removeMatcher"/>
</bean>
SeamTempModificationTypeMatcher is one of those matchers, checking if there is some Seam deployment descriptor, and then changing modification type to Temp. Removing this bean, means the Deployment will stay the way it was after structure recognition.
Now have a temped app, hence we can properly handle resources lookup on undeploy. But what about checking if something needs to be redeployed or if the original files have been updated?
This proves to be a much harder task than it looked at the beginning. The problem now is strict separation between user/client and server view of the deployment. The client view is pretty much limited, where the real information is held on the sever side; e.g. metadata locations, classpath ... But in our case this is not one and the same thing, remember we temped our app. So, the client sees the original, where the server sees the temp. But for all the resource loading mechanism used should be transparent.
In JBoss5 it's the Profile Service that only knows if something changed, needs to be re-deployed, etc. At the beginning deployment modification check was part of AS code, but the issue actually proved to be a Deployers issue. So, we moved the actual impl into Deployers project under StructureModificationChecker interface.
The first impl was MetaDataStructureModificationChecker, which only checks metadata locations for potential updates / changes. The idea was use the server side information (DeploymentContext) on the client side (Deployment), to do proper checks. This way we actually don't care if the app is temped, as we only care about client changes, temping is impl detail, not known to user.
<bean name="MetaDataStructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker">
<constructor>
<parameter><inject bean="MainDeployer" /></parameter>
</constructor>
<property name="cache"><inject bean="StructureModCache" /></property>
<property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
</bean>
But this still doesn't know about changes outside metadata locations; e.g. the ones that don't need re-deployment. For this purpose SynchWrapperModificationChecker was added, which handles the updates, only when its delegate StructureModificationChecker doesn't already signal modified.
protected boolean hasStructureBeenModifed(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException
{
boolean modified = delegate.hasStructureBeenModifed(root, deploymentContext);
// it was not modifed & we're actually temped
if (modified == false && root != deploymentContext.getRoot())
{
// check for update or delete
UpdateDeleteVisitor udVisitor = new UpdateDeleteVisitor(filter, tempAttributes, getCache(), synchAdapter, root);
VirtualFile tempRoot = deploymentContext.getRoot();
tempRoot.visit(udVisitor);
// check for addition
AddVisitor addVisitor = new AddVisitor(filter, originalAttributes, getCache(), synchAdapter, tempRoot, root.getPathName().length());
root.visit(addVisitor);
}
return modified;
}
The majority of weird re-deployment problems comes from doing proper check if any of the files was actually modified. In order to do this check, we must hold previous timestamp in some sort of cache - StructureCache. To at least limit the number of resources we check, we try to define proper file filters. And this is what's mostly causing trouble, as we try to be too generic - currently matching all *.xml files, where users were mostly accustomed to classic JEE spec defined files check; e.g. web.xml, app.xml, etc.
<property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
By changing this, you limit what we check when doing metadata locations check. But defining this filter one must note that we should be able to filter two different things although they are conceptually the same - VFS files and StructureCache nodes. Hence two different filters, but they can be easily joined into one.
From MetaDataStructureModificationChecker
/**
* Check filters.
*/
public void start()
{
if (cacheFilter == null)
{
if (filter instanceof StructureCacheFilter)
cacheFilter = (StructureCacheFilter) filter;
else
log.warn("No cache filter specified, possible non match on leaves.");
}
else if (cacheFilter != filter)
{
// not the same instance
log.debug("VFS filter and structure cache filter are not the same instance, possible compatibility issue?");
}
}
Here is an example of the current XmlIncludeVirtualFileFilter
public class XmlIncludeVirtualFileFilter extends AbstractPathNameFilter
{
public boolean accepts(String path)
{
return path.endsWith(".xml");
}
}
Note AbstractPathNameFilter, which is what helps you join the two filters together - VirtualFileFilter and StructureCacheFilter.
We're actually planning on changing the current XmlIncludeVirtualFileFilter with the one that would only understand files from parsing deployers, and at the same time allowing you to define your own extension. Hopefully this way we won't pick-up any Seam custom files; e.g. pages.xml, components.xml, etc.
OK, this is a pretty long read, but hopefully a useful one. ;-)
Hot redeployment with Seam 2.2.0.GA and JBoss 5.1.0.GA was not working, so I applied the quick fixes. As a result I got the mentioned redeployment loop, both for my own Seam app and for the JBoss admin console. I have no IDE temp files in my app (testing from CLI), and of course there are no temp files in the admin console. I undeployed my seam app, but the admin console still keeps redeploying endlessly.
I suspect that this change in classloader/deployment behavior is the root cause to the seam and webbeans apps not playing together nicely issue i've reported?
Same behaviour for me, but I have solved the redeployment loop applying ONLY the first patch, i.e. you should only remove
Still broken even with the fixes outlined here.
They are working on it, but no ETA. Seam deployments and hot deployments in AS 5.1.0
I tried all the quick fixes but to no avail.
10 deploy app 20 goto 10
:)
Hope it will be fixed soon! Coen
I built JBoss 5.1.0.GA with the MetaDataStructureModificationChecker from the 5 X branch and deployers 2.0.8.GA seems to work very nicely in order to solve this problem. It is not complicated. Idea came when reading the Seam deployments and hot deployments in AS 5.1.0 entry mentioned above, which includes the configuration changes necessary to activate the new deployers. Bernhard
Yeah, I'm getting the same problem as Ben - after applying these changes the admin console keeps redeploying endlessly. 17:32:27,126 INFO [config] Initializing Mojarra (1.2_12-b01-FCS) for context '/admin-console' 17:32:45,678 INFO [TomcatDeployment] undeploy, ctxPath=/admin-console 17:32:58,307 INFO [TomcatDeployment] deploy, ctxPath=/admin-console 17:32:58,589 INFO [config] Initializing Mojarra (1.2_12-b01-FCS) for context '/admin-console' 17:33:17,276 INFO [TomcatDeployment] undeploy, ctxPath=/admin-console 17:33:30,047 INFO [TomcatDeployment] deploy, ctxPath=/admin-console 17:33:30,538 INFO [config] Initializing Mojarra (1.2_12-b01-FCS) for context '/admin-console' 17:33:49,205 INFO [TomcatDeployment] undeploy, ctxPath=/admin-console 17:34:01,963 INFO [TomcatDeployment] deploy, ctxPath=/admin-console 17:34:02,272 INFO [config] Initializing Mojarra (1.2_12-b01-FCS) for context '/admin-console' 17:34:20,834 INFO [TomcatDeployment] undeploy, ctxPath=/admin-console
I had been working with a Seam project for a while and suddenly one day my app got stuck in a deploy/undeploy loop on JBoss startup (running Seam 2.2.0.GA and JBoss 5.1.0.GA). After much frustration and searching, I finally came across this posting.
The fix for me was to delete .jsfdia and .spdia files from the server deploy folder and Seam project folder.
As for Marcello above , with jboss 5.1.0 I found I only had to apply the first patch, i.e. just remove
yes just delete
from line 100 ofThe prj.ear/prj.war/WEB_INF contains additional files (e.g. server-conifg.wsdd and viewer.properties) that do not have .xml extensions. They cause redeployment loop so JBoss5.1 and SEAM 2.2 are useles for my project.
Any chance to get not peper patch for that bug ?
Edward
I have the same problem when adding BIRT to my seam project. It redeploys in an infinite loop. Is there any way I coulnd make it stop ? Like disable hot deployment feature ? I wouldn'y mind restarting the server.
Please ! It is very urgent.
Thanks ! (I wish I ran into this post a week ago)
Same question, when I add SSL to admin-console, redeploy loop. Please release new JBoss AS version quickly!
Thank you!
Hello,
I ran into the same problem, and it was only resolved when I removed the server-conifg.wsdd and viewer.properties files mentioned above from the WEB-INF directory. Just passing this along in case you, like me, added BIRT and suddenly ran into this problem as well.
I had the same problem (deploy/undeploy loop), but the procedure described here (remove any files in WEB-INF with a non .xml extension) worked for me.
There is many post causing a lot of chaos. This works for me to both hot deploy and redeploy
Update profile.xml
1. remove
2. keep
<bean name="MetaDataStructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker"> <constructor> <parameter><inject bean="MainDeployer" /></parameter> </constructor> <property name="cache"><inject bean="StructureModCache" /></property> <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property> </bean>3 keep
<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory"> <property name="deploymentFilter"><inject bean="DeploymentFilter" /></property> <property name="checker"><inject bean="StructureModificationChecker" /></property> </bean>4 Then comment out: (reference)
Edit JBOSS/server/serverName/default/deployers/seam.deployer/META-INF/seam-deployers-jboss-beans.xml to remove (or comment out) the following entry:
----
all .jsfdia or .spdia files must be removed!
Tom