[Cocoon Wiki] Update of "WorkaroundForCOCOON-1579" by ReynaldoPorras
Apache Wiki <[email protected]>
| Newsgroups | gmane.text.xml.cocoon.documentation |
|---|---|
| Message-ID | <[email protected]> |
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.
The following page has been changed by ReynaldoPorras:
http://wiki.apache.org/cocoon/WorkaroundForCOCOON-1579
------------------------------------------------------------------------------
[http://issues.apache.org/jira/browse/COCOON-1579 COCOON-1579] describes a continuation issue when using rhino 1.6 in cocoon 2.1.10+.
The workaround is to replace rhino 1.6 with the previous version. Before compiling cocoon, please follow this steps:
-
+ For Cocoon 2.1:
1. Download [http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/lib/core/rhino1.5r4-continuations-R26.jar?revision=226968&pathrev=479984 rhino1.5r4-continuations-R26.jar] and locate it on "$COCOON/lib/core" folder.
2. Delete js-1.6R5.jar from "$COCOON/lib/core".
3. Change the jar location (<lib/>) for rhino on $COCOON/lib/jars.xml from
@@ -51, +51 @@
5. Then you can build cocoon by running the script (build.bat or build.sh)
+ For Cocoon 2.2:
+
+ 1.Download [http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/lib/core/rhino1.5r4-continuations-R26.jar?revision=226968&pathrev=479984 rhino1.5r4-continuations-R26.jar] and deploy it in your local maven repo with the next command
+ {{{
+ mvn deploy:deploy-file -Durl=file:///m2-repo -DrepositoryId=some.id -Dfile=/path-to-rhino-jar/rhino1.5r4-continuations-R26.jar -DgroupId=rhino -DartifactId=js -Dversion=1.5r4-continuations -Dpackaging=jar
+ }}}
+ 2. Change the rhino's dependency to one recently created, in "$COCOON/parent/pom.xml"
+ From
+ {{{
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R7</version>
+ </dependency>
+ }}}
+ to
+ {{{
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.5r4-continuations</version>
+ </dependency>
+ }}}
+ 3. Change the code to use rhino 1.5r4-continuations api. These are the changes:
+
+ 3.1.$COCOON/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/
+ cocoon/components/flow/javascript/LocationTrackingDebugger.java
+ 3.1.1. Add the following import:
+ {{{
+ import org.mozilla.javascript.NativeFunction;
+ }}}
+ 3.1.2.Change line 54
+ {{{
+ if (ex.sourceName() != null) {
+ return new LocationImpl(ex.getName(), ex.sourceName(), ex.lineNumber(), ex.columnNumber());
+ }}}
+ to
+ {{{
+ if (ex.getSourceName() != null) {
+ return new LocationImpl(ex.getName(), ex.getSourceName(), ex.getLineNumber(), ex.getColumnNumber());
+ }}}
+ 3.1.3. Change line 82
+ {{{
+ public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, String source)
+ }}}
+ to
+ {{{
+ public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, StringBuffer source)
+ }}}
+ 3.1.4. Change line 86
+ {{{
+ public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript)
+ }}}
+ to
+ {{{
+ public DebugFrame enterFrame(Context cx, Scriptable scope, Scriptable thisObj, Object[] args, DebuggableScript fnOrScript)
+ }}}
+ 3.1.5. Change line 127
+ {{{
+ public void onLineChange(Context cx, int lineNumber)
+ }}}
+ to
+ {{{
+ public void onLineChange(Context cx, int lineNumber, boolean breakpoint)
+ }}}
+ 3.1.6. Change in line 138
+ {{{
+ if (script.isFunction()) {
+ name = script.getFunctionName();
+ } else {
+ name = "[script]";
+ }
+ }}}
+ to
+ {{{
+ Scriptable obj = script.getScriptable();
+ name = obj instanceof NativeFunction ? ((NativeFunction)obj).getFunctionName() : "Top-level script";
+ if (name == null || name.length() == 0) {
+ name = "[unnamed]";
+ }
+ }}}
+
+ 3.2.$COCOON/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/
+ cocoon/components/flow/javascript/fom/FOM_Cocoon.java:
+ 3.2.1. Change line 324
+ {{{
+ return org.mozilla.javascript.Context.javaToJS(currentCall.webAppContext.getBean(id), getParentScope());
+ }}}
+ to
+ {{{
+ return currentCall.webAppContext.getBean(id);
+ }}}
+ 3.2.2.Change line 375
+ {{{
+ return org.mozilla.javascript.Context.javaToJS(obj, getParentScope());
+ }}}
+ to
+ {{{
+ return obj;
+ }}}
+ 3.2.3. Change line 489
+ {{{
+ result = org.mozilla.javascript.Context.javaToJS(result, start);
+ }}}
+ to
+ {{{
+ result = wrap(start, result, null);
+ }}}
+ 3.3.$COCOON/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/
+ cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java:
+
+ 3.3.1.Add the import:
+ {{{
+ import java.io.StringReader;
+ }}}
+ 3.3.2. Change line 500
+ {{{
+ Script compiledScript = cx.compileReader(reader, src.getURI(), 1, null);
+ }}}
+ to
+ {{{
+ Script compiledScript = cx.compileReader(scope, reader, src.getURI(), 1, null);
+ }}}
+ 3.3.3. Change line 593
+ {{{
+ fun = context.compileString(funName, null, 1, null).exec (context, thrScope);
+ }}}
+ to
+ {{{
+ fun = context.compileReader (thrScope, new StringReader(funName), null, 1, null).exec (context, thrScope);
+ }}}
+
+ 3.4.$COCOON/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/
+ cocoon/components/flow/javascript/fom/FOM_WebContinuation.java
+ 3.4.1. Change in line 104
+ {{{
+ return org.mozilla.javascript.Context.javaToJS(
+ wk.getAttribute(name),
+ getParentScope());
+ }}}
+ to
+ {{{
+ return org.mozilla.javascript.Context.toObject(
+ wk.getAttribute(name),
+ getParentScope());
+ }}}
+ 3.4.2. Change in line 118
+ {{{
+ return org.mozilla.javascript.Context.javaToJS(
+ wk.getAttributeNames(),
+ getParentScope());
+ }}}
+ to
+ {{{
+ return org.mozilla.javascript.Context.toObject(
+ wk.getAttributeNames(),
+ getParentScope());
+ }}}
+
+ 3.5.$COCOON/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/
+ forms/util/JavaScriptHelper.java, Uncomment line 65
+ {{{
+ // To use rhino1.5r4-continuations-R26.jar as a workaround for COCOON-1579: Uncomment the next line.
+ // getRootScope(null), //scope
+ }}}
+ It should look like this:
+ {{{
+ // To use rhino1.5r4-continuations-R26.jar as a workaround for COCOON-1579: Uncomment the next line.
+ getRootScope(null), //scope
+ }}}
+
+ 3.6.$COCOON/blocks/cocoon-scratchpad/cocoon-scraptchpad-impl/src/main/java/org/apache/
+ cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java
+ 3.6.1. Change in line 554
+ {{{
+ compiledScript = cx.compileReader(reader, src.getURI(), 1, null );
+ to
+ {{{
+ compiledScript = cx.compileReader(scope, reader, src.getURI(), 1, null);
+ }}}
+ 3.6.2. Change in line 561
+ {{{
+ compiledScript = cx.compileReader(reader, src.getURI() + INTERCEPTION_POSTFIX, 1, null );
+ }}}
+ to
+ {{{
+ compiledScript = cx.compileReader(scope, reader, src.getURI() + INTERCEPTION_POSTFIX, 1, null);
+ }}}
+
+ 3.6.3. Change in line 628
+ {{{
+ if (ee.sourceName() != null) {
+ Context.reportRuntimeError(msg,
+ ee.sourceName(),
+ ee.lineNumber(),
+ ee.lineSource(),
+ ee.columnNumber());
+ }}}
+ to
+ {{{
+ if (ee.getSourceName() != null) {
+ Context.reportRuntimeError(msg,
+ ee.getSourceName(),
+ ee.getLineNumber(),
+ ee.getLineSource(),
+ ee.getColumnNumber());
+ }}}
+ 3.6.4. Change line 710
+ {{{
+ if (ee.sourceName() != null) {
+ Context.reportRuntimeError(msg,
+ ee.sourceName(),
+ ee.lineNumber(),
+ ee.lineSource(),
+ ee.columnNumber());
+ }}}
+ to
+ {{{
+ if (ee.getSourceName() != null) {
+ Context.reportRuntimeError(msg,
+ ee.getSourceName(),
+ ee.getLineNumber(),
+ ee.getLineSource(),
+ ee.getColumnNumber());
+ }}}
+
+ 3.7.$COCOON/block/cocoon-xsp/cocoon-xsp-impl/src/main/java/org/apache/cocoon/
+ components/language/markup/xsp/JSGenerator.java, change in line 111
+ {{{
+ script = context.compileReader(new FileReader(file), file.toString(), 1, null);
+ }}}
+ to
+ {{{
+ script = context.compileReader(global, new FileReader(file), file.toString(), 1, null);
+ }}}
+
+ 3.8.$COCOON/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/
+ java/org/apache/cocoon/el/impl/javascript/JavaScriptExpression.java
+ 3.8.1. Add the following import
+ {{{
+ import java.io.StringReader;
+ }}}
+ 3.8.2. Change in line 48
+ {{{
+ this.script = ctx.compileString(getExpression(), "", 1, null);
+ }}}
+ to
+ {{{
+ this.script = ctx.compileReader(getScope(rootScope), new StringReader(getExpression()), "", 1, null);
+ } catch (Exception e) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ } else{
+ throw new RuntimeException("Runtime exception.", e);
+ }
+ }}}
+
+ 3.9. $COCOON/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/
+ java/org/apache/cocoon/el/impl/javascript/JavaScriptTestCase.java change line 40,
+ {{{
+ assertEquals(new Integer(3), result);
+ }}}
+ to
+ {{{
+ assertEquals(new Double(3), result);
+ }}}
+
+ 4. Build cocoon with maven ( mvn -P allblocks clean install )
+