无法将Tapestry罐子从战争中移出战争中的页面代码

时间:2017-02-23 18:53:06

标签: tapestry

我正在尝试进行实验,因为我们现在有多次网络战,其中至少有2次使用Tapestry 5.4.1。

这个想法是将Tapestry相关的jar放在系统类路径上战争一侧的一个地方。

但是当我尝试在浏览器中打开Tapestry页面时,它会抱怨在准备构建它时不能找到页面类/代码。

我认为战争之外的Tapestry类没有看到WAR内部的页面类。

所以我真的可以尝试吗?对我而言,它看起来并不像Tapestry罐子应该与Tapestry页面代码所在的类路径相同。

异常追踪

java.lang.RuntimeException: Exception assembling root component of page ExceptionReport: Exception assembling embedded component 'layout' (of type myproject.web.components.Layout, within ExceptionReport): Could not convert 'style' into a component parameter binding: Exception generating conduit for expression 'style': java.lang.RuntimeException: java.lang.ClassNotFoundException: myproject.web.pages.reassign.ReAssign
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.performAssembleRootComponent(ComponentAssemblerImpl.java:129)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.access$000(ComponentAssemblerImpl.java:37)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl$1.invoke(ComponentAssemblerImpl.java:81)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl$1.invoke(ComponentAssemblerImpl.java:78)
    org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
    org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
    org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1260)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.assembleRootComponent(ComponentAssemblerImpl.java:76)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl$3.invoke(PageLoaderImpl.java:197)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl$3.invoke(PageLoaderImpl.java:190)
    org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
    org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
    org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1260)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl.loadPage(PageLoaderImpl.java:189)
    $PageLoader_12d4e53af23f.loadPage(Unknown Source)
    org.apache.tapestry5.internal.services.PageSourceImpl.getPage(PageSourceImpl.java:104)
    $PageSource_12d4e53af23e.getPage(Unknown Source)
    org.apache.tapestry5.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:86)
    $RequestPageCache_12d4e53af23d.get(Unknown Source)
    $RequestPageCache_12d4e53af20f.get(Unknown Source)
    org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.renderException(DefaultRequestExceptionHandler.java:254)
    org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:145)
    $RequestExceptionHandler_12d4e53af1f7.handleRequestException(Unknown Source)
    org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:42)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$3.service(TapestryModule.java:846)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$2.service(TapestryModule.java:836)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:89)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    $RequestHandler_12d4e53af1ef.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:256)
    org.got5.tapestry5.jquery.services.AjaxUploadServletRequestFilter.service(AjaxUploadServletRequestFilter.java:27)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:45)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:59)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
    $HttpServletRequestFilter_12d4e53af1eb.service(Unknown Source)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$1.service(TapestryModule.java:796)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    $HttpServletRequestHandler_12d4e53af1ea.service(Unknown Source)
    org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:166)
root cause

org.apache.tapestry5.ioc.internal.OperationException: Exception assembling embedded component 'layout' (of type myproject.web.components.Layout, within ExceptionReport): Could not convert 'style' into a component parameter binding: Exception generating conduit for expression 'style': java.lang.RuntimeException: java.lang.ClassNotFoundException: myproject.web.pages.reassign.ReAssign [at classpath:myproject/web/pages/ExceptionReport.tml, line 3]
    org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:186)
    org.apache.tapestry5.ioc.internal.OperationTrackerImpl.run(OperationTrackerImpl.java:62)
    org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.run(PerThreadOperationTracker.java:60)
    org.apache.tapestry5.ioc.internal.RegistryImpl.run(RegistryImpl.java:1254)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.assembleEmbeddedComponent(ComponentAssemblerImpl.java:158)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl$12.execute(PageLoaderImpl.java:963)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.runActions(ComponentAssemblerImpl.java:229)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.performAssembleRootComponent(ComponentAssemblerImpl.java:105)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.access$000(ComponentAssemblerImpl.java:37)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl$1.invoke(ComponentAssemblerImpl.java:81)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl$1.invoke(ComponentAssemblerImpl.java:78)
    org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
    org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
    org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1260)
    org.apache.tapestry5.internal.pageload.ComponentAssemblerImpl.assembleRootComponent(ComponentAssemblerImpl.java:76)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl$3.invoke(PageLoaderImpl.java:197)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl$3.invoke(PageLoaderImpl.java:190)
    org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
    org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:72)
    org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1260)
    org.apache.tapestry5.internal.pageload.PageLoaderImpl.loadPage(PageLoaderImpl.java:189)
    $PageLoader_12d4e53af23f.loadPage(Unknown Source)
    org.apache.tapestry5.internal.services.PageSourceImpl.getPage(PageSourceImpl.java:104)
    $PageSource_12d4e53af23e.getPage(Unknown Source)
    org.apache.tapestry5.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:86)
    $RequestPageCache_12d4e53af23d.get(Unknown Source)
    $RequestPageCache_12d4e53af20f.get(Unknown Source)
    org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.renderException(DefaultRequestExceptionHandler.java:254)
    org.apache.tapestry5.internal.services.DefaultRequestExceptionHandler.handleRequestException(DefaultRequestExceptionHandler.java:145)
    $RequestExceptionHandler_12d4e53af1f7.handleRequestException(Unknown Source)
    org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:42)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$3.service(TapestryModule.java:846)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$2.service(TapestryModule.java:836)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:89)
    $RequestHandler_12d4e53af1f9.service(Unknown Source)
    $RequestHandler_12d4e53af1ef.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:256)
    org.got5.tapestry5.jquery.services.AjaxUploadServletRequestFilter.service(AjaxUploadServletRequestFilter.java:27)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:45)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:59)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
    $HttpServletRequestFilter_12d4e53af1eb.service(Unknown Source)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    org.apache.tapestry5.modules.TapestryModule$1.service(TapestryModule.java:796)
    $HttpServletRequestHandler_12d4e53af1f1.service(Unknown Source)
    $HttpServletRequestHandler_12d4e53af1ea.service(Unknown Source)
    org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:166)

1 个答案:

答案 0 :(得分:0)

几天前,在JBoss 7.0.0.GA下开发一个新项目,我遇到了这个问题;我调查了这个问题,并找到了所有邪恶的来源:塑料类“org.apache.tapestry5.internal.plastic.asm.ClassWriter”。

用于通过塑料查找(和加载)类的类加载器实际上与appserver不兼容。应用程序服务器需要强制执行类加载隔离,塑料忽略这一点。 无论如何塑料可以修补以解决问题;在这里我附上一个补丁,请我向一些开发人员请求将此补丁应用到5.4.x分支和5.5。

我还要感谢这些家伙帮助我集中解决问题:

Unable to move Tapestry jars out of the war with page code inside the war still https://blog.progs.be/50/tapestry-classloading-problems-on-jboss

此致

以下是原始代码:

1752 protected String getCommonSuperClass(final String type1, final String type2) {
1753   Class<?> c, d;
1754   ClassLoader classLoader = getClass().getClassLoader();
1755   try {
1756     c = Class.forName(type1.replace('/', '.'), false, classLoader);
1757     d = Class.forName(type2.replace('/', '.'), false, classLoader);
1758   } catch (Exception e) {
1759     throw new RuntimeException(e.toString());
1760   }
1761   if (c.isAssignableFrom(d)) {
1762     return type1;
1763   }
1764   if (d.isAssignableFrom(c)) {
1765     return type2;
1766   }
1767   if (c.isInterface() || d.isInterface()) {
1768     return "java/lang/Object";
1769   } else {
1770   do {
1771     c = c.getSuperclass();
1772   } while (!c.isAssignableFrom(d));
1773   return c.getName().replace('.', '/');
1774   }
1775 }

以下是修补后的代码:

1752 protected String getCommonSuperClass(final String type1, final String type2) {
1753   Class<?> c, d;
1754   ClassLoader classLoader = getClass().getClassLoader();
1755   try {
1756     c = Class.forName(type1.replace('/', '.'), false, classLoader);
1757     d = Class.forName(type2.replace('/', '.'), false, classLoader);
1758   } catch (Exception e) {
// --- ARZILLO PATCH BEGIN -----------------------------------------------------------

         System.err.println("WARNING: type1:" + type1 + ", type2: " + type2 + ", exception: " + e + ", classLoader: " + classLoader +", attempting to use the classloader of the current thread");

         classLoader = Thread.currentThread().getContextClassLoader();
         if ( classLoader != null ) {
           try {
             c = Class.forName(type1.replace('/', '.'), false, classLoader);
             d = Class.forName(type2.replace('/', '.'), false, classLoader);
           }
           catch (Exception e_inner) {
             System.err.println("ERROR 1: type1:" + type1 + ", type2: " + type2 + ", e_inner: " + e_inner + ", classLoader: " + classLoader +", failed even using the classloader of the current thread");
             throw new RuntimeException(e_inner.toString());
           }
         }
         else {
           System.err.println("ERROR 2: type1:" + type1 + ", type2: " + type2 + ", exception: " + e + ", classLoader: " + classLoader +", unable to get the classloader of the current thread");
           throw new RuntimeException(e.toString());
         }
// --- ARZILLO PATCH END ------------------------------------------------    -----------
1760   }
1761   if (c.isAssignableFrom(d)) {
1762     return type1;
1763   }
1764   if (d.isAssignableFrom(c)) {
1765     return type2;
1766   }
1767   if (c.isInterface() || d.isInterface()) {
1768     return "java/lang/Object";
1779   } else {
1770     do {
1771       c = c.getSuperclass();
1772     } while (!c.isAssignableFrom(d));
1773   return c.getName().replace('.', '/');
1774   }
1775 }