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

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

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

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

            try
            {
                String urlString = url.toString();

                // If the virtual URL involves a JAR file,
                // we have to figure out its physical URL ourselves because
                // in JBoss 6.1 the JAR files exploded into the VFS are empty
                // (see https://issues.jboss.org/browse/JBAS-8786).
                // Our workaround is that they are available, unexploded,
                // within the otherwise exploded WAR file.

                if (urlString.contains(".jar")) {

                    // An example URL: "vfs:/devel/jboss-6.1.0.Final/server/default/deploy/myapp.ear/myapp.war/WEB-INF/lib/tapestry-core-5.2.6.jar/org/apache/tapestry5/corelib/components/"
                    // Break the URL into its WAR part, the JAR part,
                    // and the Java package part.

                    int warPartEnd = urlString.indexOf(".war") + 4;
                    String warPart = urlString.substring(0, warPartEnd);
                    int jarPartEnd = urlString.indexOf(".jar") + 4;
                    String jarPart = urlString.substring(warPartEnd, jarPartEnd);
                    String packagePart = urlString.substring(jarPartEnd);

                    // Ask the VFS where the exploded WAR is.

                    URL warURL = new URL(warPart);
                    URLConnection warConnection = warURL.openConnection();
                    Object jBossVirtualWarDir = warConnection.getContent();
                    // Use reflection so that we don't need JBoss in the classpath at compile time.
                    File physicalWarDir = (File) invoke(jBossVirtualWarDir, "getPhysicalFile");
                    String physicalWarDirStr = physicalWarDir.toURI().toString();

                    // Return a "jar:" URL constructed from the parts
                    // eg. "jar:file:/devel/jboss-6.1.0.Final/server/default/tmp/vfs/automount40a6ed1db5eabeab/myapp.war-43e2c3dfa858f4d2//WEB-INF/lib/tapestry-core-5.2.6.jar!/org/apache/tapestry5/corelib/components/".

                    String actualJarPath = "jar:" + physicalWarDirStr + jarPart + "!" + packagePart;
                    return new URL(actualJarPath);
                }

                // Otherwise, ask the VFS what the physical URL is...

                else {

                    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 ClasspathURLConverterJBoss6Dot1.java to your project and add the following piece of code to yourAppModule.java.

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

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

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

Reference:

http://wiki.apache.org/tapestry/HowToRunTapestry5OnJBoss6Dot1?action=CopyPage

How To: Run Tapestry5 On JBoss 6/7的更多相关文章

  1. 【JBOSS】 JBOSS目录结构

    JBOSS在默认情况下可以用3种方式启动minimal,default和all.三种模式内部的模块数量依次递增   例如: 1-执行JBOSS_HOME/bin/run.bat批量处理文件启动JBos ...

  2. jboss eap 6.3 域(Domain)模式配置

    jboss提供了二种运行模式:standalone(独立运行模式).domain(域模式),日常开发中,使用standalone模式足已:但生产部署时,一个app,往往是部署在jboss集群环境中的, ...

  3. 以Debug模式启动JBoss

    JBoss服务器的启动方法: 假设JBoss的安装目录为$JBOSS_HOME,Windows以及Linux环境下的Debug模式的启动方法分别为:Windows环境:找到Windows下的JBoss ...

  4. jboss使用(eap 6.0以后版本)

    以6.3版本为例,下载地址 https://www.jboss.org/products/eap/download/,这个地址现在有问题了,下不了好像要redhat账号还要花钱?不知咋回事 下载完成后 ...

  5. eclipse 在jboss的debug配置(ubuntu系统)

    转自:https://blog.csdn.net/iteye_3878/article/details/81695877 由于我在ubuntu下权限设置分开,如 /home/jboss/ (jboss ...

  6. win7怎么安装和启动 jboss

    本文以JBoss Application Server 4.2.1 GA(以下简称JBoss)为例,介绍它在Windows平台上的启动过程.为了方便叙述,对平台环境做以下假定:Java运行时的安装路径 ...

  7. jboss之启动加载过程详解

    今天看了看jboss的boot.log和server.log日志,结合自己的理解和其他的资料,现对jboss的启动和加载过程做出如下总结: boot.xml是服务器的启动过程的日志,不涉及后续的操作过 ...

  8. CWMP开源代码研究3——ACS介绍

    声明:本文涉及的开源程序代码学习和研究,严禁用于商业目的. 如有任何问题,欢迎和我交流.(企鹅号:408797506) 本文介绍自己用过的ACS,其中包括开源版(提供下载包)和商业版(仅提供安装包下载 ...

  9. JavaEE&Docker 容器示例

    准备:jboss.jdk.一个javaee的war包.Dockerfile 注:jboss和jdk可以不用提前准备好,在命令中wget也可以,因为我恰好有,就直接复制了 Dockerfile内容: # ...

随机推荐

  1. 运行C++程序是出现错误:cannot open Debug/1.exe for writing

    今天,打开VC6.0环境编了个小程序,谁知给我报了“cannot open Debug/1.exe for writing”这样一个错,然后,我就纳闷了,这是什么错丫? 想了半天,后想通,为什么会这样 ...

  2. Tensorflow 基于分层注意网络的文件分类器

    After the exercise of building convolutional, RNN, sentence level attention RNN, finally I have come ...

  3. Cisco banner 登陆消息提示设置命令详解

    从法律角度来看,登陆消息非常重要.当入侵者进入网络而没有受到适当的警告时,他们有可能赢得官司.在放置登陆消息之前应让律师检查下,永远不要使用"欢迎"等问候语,以免被误解为邀请大家使 ...

  4. ionic 禁用 手势 滑动返回

    $ionicConfigProvider.views.swipeBackEnabled(false); 在 应用的 config里面 配置下 上面的那句话 就OK了.

  5. 2018春招实习笔试面试总结(PHP)

    博主双非渣本计算机软件大三狗一枚,眼看着春招就要结束了,现将自己所经历的的整个春招做一个个人总结. 首先就是关于投递计划,博主自己整理了一份各大公司的春招信息,包括网申地址,开始时间,结束时间,以及自 ...

  6. CAP原理和BASE思想和ACID模型

    问题的解读 对于上面三个例子,相信大家一定看出来了,我们的终端用户在使用不同的计算机产品时对于数据一致性的需求是不一样的: 1.有些系统,既要快速地响应用户,同时还要保证系统的数据对于任意客户端都是真 ...

  7. React框架 dva 和 mobx 的使用感受

    最近在用react写web项目,领导为了让前端便于维护要求都用react作为开发基础,框架选型不限.在使用 react 的时候或多或少会接触到状态管理,从开始学 react 到现在也挺久了,做一些前端 ...

  8. oss web直传

    签名信息 auth.php <?php function gmt_iso8601($time) { $dtStr = date("c", $time); $mydatetim ...

  9. 用ECMAScript4 ( ActionScript3) 实现Unity的热更新 -- CustomYieldInstruction 自定义中断指令

    ActionScript3脚本引擎为了方便热更新逻辑开发,提供的从脚本继承Unity类库功能在一些情况下可以提供开发的便利. 这次来建立一个示例,演示一下如何在脚本中自定义协程中断指令 Unity中的 ...

  10. 链表的无锁操作 (JAVA)

    看了下网上关于链表的无锁操作,写的不清楚,遂自己整理一部分,主要使用concurrent并发包的CAS操作. 1. 链表尾部插入 待插入的节点为:cur 尾节点:pred 基本插入方法: do{ pr ...