Good news for JBoss 4.2.1 with T5.0.5 - I've found there's no need to switch to the JBoss classloader to get auto-loading to work. The default classloader works fine if you do this:

1. Set reloadable="true" in the Tomcat context.xml
2. Put classes and templates together in WEB-INF/classes/ In the exploded ear/war, 3. Point JBoss at your exploded ear/war or sit the exploded ear/war in the JBoss deploy directory.

Whenever you replace a class or template in WEB-INF/classes, you'll see in the JBoss log that the Tapestry auto-loader kicks in.

Here's a bit more detail about those steps:

1. Set reloadable="true" in the Tomcat context.xml...
In your JBoss server's deploy/jboss-web.deployer/context.xml, change this...
        <Context cookies="true" crossContext="true">
    to this...
        <Context cookies="true" crossContext="true" reloadable="true">

2. Put classes and templates together in WEB-INF/classes/ In the exploded ear/war.

For example, following the guidelines at http://tapestry.apache.org/ tapestry5/tapestry-core/guide/templates.html, the Start page might involve this source...
                src/main/java/org/example/myapp/pages/Start.java
                src/main/java/org/example/myapp/pages/Start.html
which results in these items in the exploded directory that JBoss will scan... myapp.ear/myapp.war/WEB-INF/classes/org/example/myapp/pages/ Start.class
                
myapp.ear/myapp.war/WEB-INF/classes/org/example/myapp/pages/Start.html

I don't use maven, so in Eclipse I use a custom project builder written in Ant to populate the exploded ear/war behind the scenes.

3. Point JBoss at your exploded ear/war or sit the exploded ear/war in the JBoss deploy directory. You can tell JBoss where to scan by modifying the <attribute name="URLs"> section in the server's deploy/conf/jboss-service.xml.

HTH
Geoff

On 02/10/2007, at 10:27 AM, Howard Lewis Ship wrote:

We should probably update the deployment notes for JBoss then. Perhaps JBoss has changed recently because I tried a lot of variations before I
found one that worked properly.

On 10/1/07, Ben Sommerville <[EMAIL PROTECTED]> wrote:

Switching to the JBoss classloader also makes auto-loading of html
templates
work for me.

Have you tried the html auto-loading after making the classloader change?

cheers
Ben


-----Original Message-----
From: Geoff Callender [mailto:[EMAIL PROTECTED]
Sent: Monday, 1 October 2007 6:52 AM
To: Tapestry users
Subject: Re: T5: the scanner and JBoss

Nice one, Ben.  For auto-reloading class files that works
beautifully, and it avoids the class-loading problems that I found
Tapestry5DevClassLoader introduced.

Does anyone know how to auto-reload T5 html templates in JBoss???

Alternatively, can someone point me to T5.0.5's template
scanning class?

Thanks in advance,
Geoff

On 30/09/2007, at 10:01 PM, Ben Sommerville wrote:

I found that using the JBoss UnifiedClassLoader instead of
the Tomcat
class loader for web applications fixes the auto-reloading issues.

To change this setting you need to edit the following file:
JBoss 4.0.x
<server dir>/deploy/jbossweb-tomcat55.sar/META-INF/jboss- service.xml
JBoss 4.2.x
<server dir>/deploy/jbossweb.deployer/META-INF/jboss-service.xml

Search for the attribute "UseJBossWebLoader" and set it to true.

Note: Changing this may affect how your web-app resolves classes.
I think the Tomcat classloader always loads classes for the webapp
libs first, even if the class exists in a parent classloader.
The JBoss classloader says it follows standard behaviour
and will use
classes from the parent classloader over classes from the webapp.

cheers
Ben

-----Original Message-----
From: Geoff Callender [mailto:[EMAIL PROTECTED]
Sent: Sunday, 30 September 2007 12:07 AM
To: Tapestry users
Subject: Re: T5: the scanner and JBoss

Nick, thanks for pointing out the earlier e-mail.

Unfortunately, it doesn't deal with how to auto-reload html
templates.  Tapestry5DevClassLoader only ensures class files
are reloaded.

Any other suggestions?

On 28/09/2007, at 9:24 PM, Nick Westgate wrote:

Geoff Callender wrote:
T5 isn't picking up changes to templates and component
classes in my
environment.  T5.0.5 is a jar in an exploded WAR in an
exploded EAR,
which JBoss has been told to use (it's pointed to in
jboss-service.xml).  When I make changes to the web app they are
copied
immediately to the exploded ear but T5 just isn't
picking them up.

I saw on Howard's blog that he'd had a problem with
JBoss/Tomcat...

     http://tapestryjava.blogspot.com/2007/02/fighting-with-
tomcat.html
     http://issues.apache.org/bugzilla/show_bug.cgi?id=41664

...but the 5.0.5 source looks like it has the necessary fix.
Besides,
I'm using an ear that's already exploded so I shouldn't
be getting
Howard's problem.  True?

Does anyone have a theory on why it isn't working?
Alternatively can anyone point me to the scanner class so I can
debug
what it isn't doing?

Geoff


The problem with Tomcat was identified in the following email as a
classloader caching issue. I've not tested this though.

Cheers,
Nick.



-------- Original Message --------
Subject: RE: T5 developing with WTP and TOMCAT
Date: Wed, 5 Sep 2007 17:59:14 +0200
From: Brysbaert Gregory <[EMAIL PROTECTED]>
Reply-To: Tapestry users <users@tapestry.apache.org>
To: Tapestry users <users@tapestry.apache.org>

Hello,

About this topic, I tried some investigations on my side,
and I found
out that the reason why classes don't auto-reload is that the
WebappClassLoader of tomcat 5 (I currently use tomcat 5.0,
but I guess
it's the same on Tomcat 5.5) keeps in cache (in a Hashtable more
precisely) all classes it already loaded once. And this
cache is never
cleared, except when the WebappClassLoader is stopped.
So, when the
class file is modified on the disk, tapestry 5 clears its
own cache,
and then asks to the parent classloader (WebAppClassLoader)
to reload
the class, which then serves the previous version of the
class from
its cache. The result is that the class is never actually updated
until the next restart of tomcat.


So, as a temporary solution, I tried to develop a class extending
WebappClassLoader that does not cache classes for packages
containing
".pages." and ".components.". The source of this class is :


public class Tapestry5DevClassLoader extends WebappClassLoader{

   private static String[] noCacheElements={".pages.","/
pages/",".components.","/components/"};

  public Tapestry5DevClassLoader() {
          super();

  }

  public Tapestry5DevClassLoader(ClassLoader arg0) {
          super(arg0);

  }



  @Override
  protected InputStream findLoadedResource(String arg0) {
          InputStream is=super.findLoadedResource(arg0);
          if (is!=null){
                  if (isNoCacheElement(arg0))
                          return null;
          }
          return is;
  }

  private boolean isNoCacheElement(String name){

          for (int i=0;i<noCacheElements.length;i++){
                  if (name.indexOf(noCacheElements[i])>=0)
                          return true;
          }

          return false;

  }



}




To make it work, you have to do 2 things :
- Compile the class and add it to the server/classes (or
server/lib if
you package it in a jar) directory of your tomcat installation
directory.
- in your server.xml file, modify the context declaration
and disable
tomcat's auto-reloading functionality, and declare the
newly created
classloader instead of the default one :


<Context docBase="testtapestry5" path="/testtapestry5"
reloadable="false"
source="org.eclipse.jst.j2ee.server:testtapestry5">
          <Loader


loaderClass="net.atos.mm.fwk.tapestry5.classloader.Tapestry5DevClass L
o
ader">

          </Loader>
</Context>

This is of course a temporary solution, but I tried it
and it works
for me.

Waiting for something better, I hope it can help.

Gregory Brysbaert

-----Message d'origine-----
De : Thiago H de Paula Figueiredo
[mailto:[EMAIL PROTECTED] Envoye :
jeudi 16 aout 2007 18:59 A : Tapestry users Objet : Re: T5
developing
with WTP and TOMCAT

On Thu, 16 Aug 2007 12:54:31 -0300, Denny
<[EMAIL PROTECTED]> wrote:

Ok, now, I am using jettylauncher eclipse plugin to develop T5. I
hope T5
can fix the problem about working with tomcat. There are
many people
using tomcat for develop and product.

It's a Tomcat issue, not a Tapestry one. Howard explains
the problem
here:
http://tapestryjava.blogspot.com/2007/02/fighting-with- tomcat.html

--
Thiago H. de Paula Figueiredo
Desenvolvedor, Instrutor e Consultor de Tecnologia Eteg
Tecnologia da
Informacao Ltda.
http://www.eteg.com.br



-------------------------------------------------------------------- -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-------------------------------------------------------------------- -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-------------------------------------------------------------------- -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-------------------------------------------------------------------- -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-------------------------------------------------------------------- -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to