java.lang.NoClassDefFoundError: javax.swing.tree.TreeNode is a restricted class
- 博客分类:
- GAE
今天在GAE中配置Struts中出现了不少问题,以下是其中一个
Problem accessing /hello.action. Reason: java.lang.NoClassDefFoundError: javax.swing.tree.TreeNode is a restricted class. Please see the Google App Engine developer's guide for more details. Caused by: javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax.swing.tree.TreeNode is a restricted class. Please see the Google App Engine developer's guide for more details. at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825) at org.apache.jasper.runtime.PageContextImpl.access$1100(PageContextImpl.java:64) at org.apache.jasper.runtime.PageContextImpl$12.run(PageContextImpl.java:745)
解决方法是增加一个freemarker.core.TextBlock.
也就是先在src下建包 freemarker.core,然后增加一个TextBlock类
package freemarker.core; import java.io.IOException; public class TextBlock extends TemplateElement { private static final char[] EMPTY_CHAR_ARRAY = new char[0]; static final TextBlock EMPTY_BLOCK = new TextBlock(EMPTY_CHAR_ARRAY, false); // We're using char[] instead of String for storing the text block because // Writer.write(String) involves copying the String contents to a char[] // using String.getChars(), and then calling Writer.write(char[]).By // using Writer.write(char[]) directly, we avoid array copying on each // write. private char[] text; private final boolean unparsed; public TextBlock(String text) { this(text, false); } public TextBlock(String text, boolean unparsed) { this(text.toCharArray(), unparsed); } private TextBlock(char[] text, boolean unparsed) { this.text = text; this.unparsed = unparsed; } /** * Simply outputs the text. */ public void accept(Environment env) throws IOException { env.getOut().write(text); } public String getCanonicalForm() { String text = new String(this.text); if (unparsed) { return "<#noparse>" + text + "</#noparse>"; } return text; } public String getDescription() { String s = new String(text).trim(); if (s.length() == 0) { return "whitespace"; } if (s.length() > 20) { s = s.substring(0, 20) + "..."; s = s.replace('\n', ' '); s = s.replace('\r', ' '); } return "text block (" + s + ")"; } TemplateElement postParseCleanup(boolean stripWhitespace) { if (text.length == 0) return this; int openingCharsToStrip = 0, trailingCharsToStrip = 0; boolean deliberateLeftTrim = deliberateLeftTrim(); boolean deliberateRightTrim = deliberateRightTrim(); if (!stripWhitespace || text.length == 0) { return this; } if (parent.parent == null && previousSibling() == null) return this; if (!deliberateLeftTrim) { trailingCharsToStrip = trailingCharsToStrip(); } if (!deliberateRightTrim) { openingCharsToStrip = openingCharsToStrip(); } if (openingCharsToStrip == 0 && trailingCharsToStrip == 0) { return this; } this.text = substring(text, openingCharsToStrip, text.length - trailingCharsToStrip); if (openingCharsToStrip > 0) { this.beginLine++; this.beginColumn = 1; } if (trailingCharsToStrip > 0) { this.endColumn = 0; } return this; } /** * Scans forward the nodes on the same line to see whether there is a * deliberate left trim in effect. Returns true if the left trim was * present. */ private boolean deliberateLeftTrim() { boolean result = false; for (TemplateElement elem = this.nextTerminalNode(); elem != null && elem.beginLine == this.endLine; elem = elem .nextTerminalNode()) { if (elem instanceof TrimInstruction) { TrimInstruction ti = (TrimInstruction) elem; if (!ti.left && !ti.right) { result = true; } if (ti.left) { result = true; int lastNewLineIndex = lastNewLineIndex(); if (lastNewLineIndex >= 0 || beginColumn == 1) { char[] firstPart = substring(text, 0, lastNewLineIndex + 1); char[] lastLine = substring(text, 1 + lastNewLineIndex); if (trim(lastLine).length == 0) { this.text = firstPart; this.endColumn = 0; } else { int i = 0; while (Character.isWhitespace(lastLine[i])) { i++; } char[] printablePart = substring(lastLine, i); this.text = concat(firstPart, printablePart); } } } } } if (result) { } return result; } /** * Checks for the presence of a t or rt directive on the same line. Returns * true if the right trim directive was present. */ private boolean deliberateRightTrim() { boolean result = false; for (TemplateElement elem = this.prevTerminalNode(); elem != null && elem.endLine == this.beginLine; elem = elem .prevTerminalNode()) { if (elem instanceof TrimInstruction) { TrimInstruction ti = (TrimInstruction) elem; if (!ti.left && !ti.right) { result = true; } if (ti.right) { result = true; int firstLineIndex = firstNewLineIndex() + 1; if (firstLineIndex == 0) { return false; } if (text.length > firstLineIndex && text[firstLineIndex - 1] == '\r' && text[firstLineIndex] == '\n') { firstLineIndex++; } char[] trailingPart = substring(text, firstLineIndex); char[] openingPart = substring(text, 0, firstLineIndex); if (trim(openingPart).length == 0) { this.text = trailingPart; this.beginLine++; this.beginColumn = 1; } else { int lastNonWS = openingPart.length - 1; while (Character.isWhitespace(text[lastNonWS])) { lastNonWS--; } char[] printablePart = substring(text, 0, lastNonWS + 1); if (trim(trailingPart).length == 0) { // THIS BLOCK IS HEINOUS! THERE MUST BE A BETTER // WAY! REVISIT (JR) boolean trimTrailingPart = true; for (TemplateElement te = this.nextTerminalNode(); te != null && te.beginLine == this.endLine; te = te .nextTerminalNode()) { if (te.heedsOpeningWhitespace()) { trimTrailingPart = false; } if (te instanceof TrimInstruction && ((TrimInstruction) te).left) { trimTrailingPart = true; break; } } if (trimTrailingPart) trailingPart = EMPTY_CHAR_ARRAY; } this.text = concat(printablePart, trailingPart); } } } } return result; } /* * private String leftTrim(String s) { int i =0; while (i<s.length()) { if * (!Character.isWhitespace(s.charAt(i))) break; ++i; } return * s.substring(i); } */ private int firstNewLineIndex() { String content = new String(text); int newlineIndex1 = content.indexOf('\n'); int newlineIndex2 = content.indexOf('\r'); int result = newlineIndex1 >= 0 ? newlineIndex1 : newlineIndex2; if (newlineIndex1 >= 0 && newlineIndex2 >= 0) { result = Math.min(newlineIndex1, newlineIndex2); } return result; } private int lastNewLineIndex() { String content = new String(text); return Math.max(content.lastIndexOf('\r'), content.lastIndexOf('\n')); } /** * figures out how many opening whitespace characters to strip in the * post-parse cleanup phase. */ private int openingCharsToStrip() { int newlineIndex = firstNewLineIndex(); if (newlineIndex == -1 && beginColumn != 1) { return 0; } ++newlineIndex; if (text.length > newlineIndex) { if (newlineIndex > 0 && text[newlineIndex - 1] == '\r' && text[newlineIndex] == '\n') { ++newlineIndex; } } if (new String(text).substring(0, newlineIndex).trim().length() > 0) { return 0; } // We look at the preceding elements on the line to see if we should // strip the opening newline and any whitespace preceding it. for (TemplateElement elem = this.prevTerminalNode(); elem != null && elem.endLine == this.beginLine; elem = elem .prevTerminalNode()) { if (elem.heedsOpeningWhitespace()) { return 0; } } return newlineIndex; } /** * figures out how many trailing whitespace characters to strip in the * post-parse cleanup phase. */ private int trailingCharsToStrip() { String content = new String(text); int lastNewlineIndex = lastNewLineIndex(); if (lastNewlineIndex == -1 && beginColumn != 1) { return 0; } String substring = content.substring(lastNewlineIndex + 1); if (substring.trim().length() > 0) { return 0; } // We look at the elements afterward on the same line to see if we // should strip any whitespace after the last newline for (TemplateElement elem = this.nextTerminalNode(); elem != null && elem.beginLine == this.endLine; elem = elem .nextTerminalNode()) { if (elem.heedsTrailingWhitespace()) { return 0; } } return substring.length(); } boolean heedsTrailingWhitespace() { if (isIgnorable()) { return false; } for (int i = 0; i < text.length; i++) { char c = text[i]; if (c == '\n' || c == '\r') { return false; } if (!Character.isWhitespace(c)) { return true; } } return true; } boolean heedsOpeningWhitespace() { if (isIgnorable()) { return false; } for (int i = text.length - 1; i >= 0; i--) { char c = text[i]; if (c == '\n' || c == '\r') { return false; } if (!Character.isWhitespace(c)) { return true; } } return true; } boolean isIgnorable() { if (text == null || text.length == 0) { return true; } if (!isWhitespace()) { return false; } // trick here boolean atTopLevel = true; TemplateElement prevSibling = previousSibling(); TemplateElement nextSibling = nextSibling(); return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling)) && ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling)); } private boolean nonOutputtingType(TemplateElement element) { return (element instanceof Macro || element instanceof Assignment || element instanceof AssignmentInstruction || element instanceof PropertySetting || element instanceof LibraryLoad || element instanceof Comment); } private static char[] substring(char[] c, int from, int to) { char[] c2 = new char[to - from]; System.arraycopy(c, from, c2, 0, c2.length); return c2; } private static char[] substring(char[] c, int from) { return substring(c, from, c.length); } private static char[] trim(char[] c) { if (c.length == 0) { return c; } return new String(c).trim().toCharArray(); } private static char[] concat(char[] c1, char[] c2) { char[] c = new char[c1.length + c2.length]; System.arraycopy(c1, 0, c, 0, c1.length); System.arraycopy(c2, 0, c, c1.length, c2.length); return c; } boolean isWhitespace() { return text == null || trim(text).length == 0; } }
强烈建议参考以下文章在GAE中配置Struts2
http://whyjava.wordpress.com/2009/08/30/creating-struts2-application-on-google-app-engine-gae/
发表评论
-
GAE中JDO出现的持久化问题
2010-09-16 08:35 1139The class "The class " ... -
GAE中spring无法识别jdoconfig
2010-09-15 09:31 834准备在GAE中用spring管理JDO,无奈搞了n久仍然没有搞 ... -
org.apache.jasper.JasperException: java.security.AccessControlException
2010-09-14 15:24 1320今天开始将spring整合到GAE上,竟然出现了问题。根据网络 ... -
GAE中增加Struts2支持
2010-09-13 20:53 8811.增加Struts2的jar包 ... -
Provider org.apache.xalan.processor.TransformerFactoryImpl not found
2010-09-13 19:20 1959javax.xml.transform.Transformer ... -
GAE原来有Eclipse 3.5的插件
2010-09-13 13:53 1423一直在看Google官方GAE的教程,也就傻傻地认为Googl ...
相关推荐
标题 "java.lang.NoClassDefFoundError: javax/persistence/EntityListener" 提到的问题是一个常见的Java运行时异常,通常表示在类加载时找不到指定的类定义。这个错误在Java应用程序或Web应用中出现,可能是因为...
jdk升级jdk10后,原本jdk自带的 webservice一些包确实,引起的一系列错误解决方案
在Java开发过程中,我们经常会遇到`java.lang.NoClassDefFoundError`这个异常,尤其是在进行JDK版本升级时。这个错误通常表示在运行时找不到某个类的定义,即使编译时该类是可用的。在本例中,问题发生在从一个较低...
java.lang.NoClassDefFoundError: de/javakaffee/kryoserializers/CurrencySerializer
JavaMail的java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream错误 原因: MyEclipse6.5的javaee.jar中的mail包与JavaMail包有冲突。 解决: 在MyEclipse目录下(D:\Program Files\MyEclipse ...
java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport异常处理
该jar包解决报错java.lang.NoClassDefFoundError: org/apache/james/mime4j/MimeException,亲测可用。
在Java编程中,`java.lang.NoClassDefFoundError` 是一个常见的运行时错误,它发生在类加载器尝试执行一个类,但在类路径中找不到该类的定义时。在这个特定的场景中,问题聚焦于 `net.sf.ezmorph.Morpher` 类。`...
标题中的“JSON中,java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher问题解决”指的是一类常见的Java运行时错误,当尝试加载一个类时,如果Java虚拟机(JVM)找不到该类的定义,就会抛出`...
jackson-annotations-2.10.2.jar jackson-core-2.10.2.jar jackson-databind-2.10.2.jar NoClassDefFoundError解决
在Java编程中,`java.lang.NoClassDefFoundError` 是一个常见的运行时异常,它发生在类加载器尝试加载一个在编译时存在但在运行时找不到的类定义时。这个错误通常意味着类路径设置不正确或者依赖项没有正确地被包含...
java.lang.NoClassDefFoundError: javax/validation/valueextraction/ValueExtractorDeclarationException 今天部署环境遇到这个问题,查了好长时间终于解决了; 问题原因: 由于jar包hibernate-validator、...
4. **java.lang.NoClassDefFoundError- javax-servlet-jsp-jstl-core-Config - CSDN博客.url**:这个URL指向一个CSDN博客文章,很可能提供了关于如何解决特定`NoClassDefFoundError`的详细步骤,特别是与`javax....
NULL 博文链接:https://jaychang.iteye.com/blog/980159
Java编程中的`java.lang.NoClassDefFoundError: org/jboss/logging/`是一个常见的运行时错误,通常发生在尝试执行一个类时,JVM无法找到在编译时已经存在的类定义。这个错误并不意味着类在编译期间不存在,而是表明...
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/ConditionalTagSupport 问题-附件资源
### Java中的`java.lang.NoClassDefFoundError`: javax/mail/Message #### 错误概述 在Java编程过程中遇到`java.lang.NoClassDefFoundError`是一个常见的问题,这种异常通常发生在试图加载一个类时,该类在编译时...
在Java编程中,`java.lang.ClassNotFoundException` 是一个常见的运行时异常,通常发生在尝试通过类加载器加载指定类时,但找不到对应的字节码文件。在这个特定的问题中,`ClassNotFoundException` 引发的原因是缺少...
在Java编程中,遇到“Exception in thread 'main' java.lang.NoClassDefFoundError”是一种常见的异常情况,这通常意味着JVM在运行时未能找到指定的类定义。此错误不同于ClassNotFoundException,后者发生在尝试加载...