Tapestry 5.x cannot find the core pages and components from the URLs provided from classloaders in JBoss 6.0. We will override Tapestry's ClasspathURLConverter with one customised for JBoss 6.0. This builds on the work done for JBoss 5 in https://issues.apache.org/jira/browse/TAP5-576 .

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

    public URL convert(URL url)
    {
        // If the URL is a "vfs" URL (JBoss 6.0 uses a Virtual File System)...

        if (url != null && url.getProtocol().startsWith("vfs"))
        {
            // Ask the VFS what the physical URL is...

            try
            {
                URLConnection connection = url.openConnection();
                Object jBossVirtualFile = connection.getContent();
                // Use reflection so that we don't need JBoss in the classpath at compile time.
                File physicalFile = (File) invoke(jBossVirtualFile, "getPhysicalFile");
                URL physicalFileURL = physicalFile.toURI().toURL();
                return physicalFileURL;
            }
            catch (Exception e)
            {
                logger.error(e.getCause().toString());
            }
        }

        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 ClasspathURLConverterJBoss6Dot0.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 ClasspathURLConverterJBoss6Dot0());
}    

The above just override the default ClaspathURLConverter service. For more information on overriding a general service, please see http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html.

The above fix has been tested with Tapestry 5.2 on JBoss 6.0.0.

  • No labels