You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2009/05/11 22:16:45 UTC

[Tapestry Wiki] Update of "HowToRunTapestry5OnJBoss5" by ShingHingMan

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.

The following page has been changed by ShingHingMan:
http://wiki.apache.org/tapestry/HowToRunTapestry5OnJBoss5

New page:
Tapestry 5.x can not find the core pages and components from the URLs provided from classloaders in Jboss 5.x. Please see   https://issues.apache.org/jira/browse/TAP5-576 for details. In JIRA 576, Benjamin Bentmann provided an implementation of ClasspathURLConverter to overcome the problem. 

{{{
public class ClasspathURLConverterJBoss5 implements ClasspathURLConverter
{
	private static Logger log = Logger.getLogger(ClasspathURLConverterJBoss5.class);

   public URL convert(URL url)
   {
        if (url != null && url.getProtocol().startsWith("vfs"))
        {
            // supports virtual filesystem used by JBoss 5.x
            try
            {
                URLConnection connection = url.openConnection();
                Object virtualFile = invokerGetter(connection, "getContent");
                Object zipEntryHandler = invokerGetter(virtualFile, "getHandler");
                Object realUrl = invokerGetter(zipEntryHandler, "getRealURL");
                return (URL) realUrl;
            }
            catch (Exception e)
            {
                log.info(e.getCause());
            }
        }
       return url;
   }

    private Object invokerGetter(Object target, String getter) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
    {
        Class<?> type = target.getClass();
        Method method;
        try
        {
            method = type.getMethod(getter);
        }
        catch (NoSuchMethodException e)
        {
            method = type.getDeclaredMethod(getter);
            method.setAccessible(true);
        }
        return method.invoke(target);
    }

}
}}}

To override the default implementation of ClasspathURLConverter, just add the above  ClasspathURLConverterJBoss5.java to your project and add the following piece of code to your AppModule.java.

{{{
public static void contributeServiceOverride(MappedConfiguration<Class,Object> configuration)
    {
      configuration.add(ClasspathURLConverter.class,  new ClasspathURLConverterJBoss5());
    }
    
}}}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org