You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Paul Joseph <pj...@gmail.com> on 2009/02/23 16:05:10 UTC

problem with this line?

Hi There,

I am upgrading a stable (2.1.7) customer application that I wrote to 2.1.11.

In my flowscript, I get an error on this line and I don't know why--the 
jar file with this package is on the classpath.
var encoder = new 
Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder();

The "caused by" is below.

Any ideas what I am doing wrong?

thx
Paul

Caused by: org.mozilla.javascript.EcmaError: TypeError: [JavaPackage 
org.apache.cocoon.ojb.samples.bean.PasswordEncoder] is not a function, 
it is org.mozilla.javascript.NativeJavaPackage. (file:///C:/Program 
Files/Apache Software Foundation/Tomcat 
5.5/webapps/webapp/webtask/request/Request.js#8)
at 
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229) 

at 
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219) 

at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3235)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3254)
at 
org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3309) 

at 
org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3297) 

at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3116)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2251)
at 
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:161) 

at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758)
at 
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:172) 

at 
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.setupContext(FOM_JavaScriptInterpreter.java:610) 

at 
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.callFunction(FOM_JavaScriptInterpreter.java:718) 
...
47 more

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: problem with this line?

Posted by Christofer Dutz <ma...@c-ware.de>.
Hi Paul,

one of the things I have learned, when dealing with Cocoon was, never to
trust the actual error message ... or, when thinking about try-catch blocks
inside finally blocks in my Java Flow, not even to try to understand them
;-)

I would guess your original code was fine. I would tip on the
PasswordEncoder class not being there anymore or it having a changed
signature.
Have you checked your classpath manually that it is really there? I would
never depend on code in the demo and samples parts of Cocoon, as I would
think they change much too often ... as they are just used for demonstration
purposes.

Chris





-----Ursprüngliche Nachricht-----
Von: Paul Joseph [mailto:pjoseph@gmail.com] 
Gesendet: Dienstag, 24. Februar 2009 01:16
An: users@cocoon.apache.org
Betreff: Re: problem with this line?

I guess the message (below) was telling me that I had a Package, not a 
class.

org.mozilla.javascript.EvaluatorException: "file:///C:/Program 
Files/Apache Software Foundation/Tomcat 
5.5/webapps/webapp/webtask/request/Request.js", line 8: Not a Java 
class: [JavaPackage org.apache.cocoon.ojb.samples.bean.PasswordEncoder]

I changed the line by taking out the "new" at the beginning and the () 
at the end to:
var encoder = Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder;

And lo and behold it works.

Not sure why as in my PasswordEncoder.java file, PasswordEncoder is a class.

public class PasswordEncoder {
...
}

Paul




Benjamin Boksa wrote:
>> Any ideas anyone?
>
> Have you tried
>
> importClass(Packages.rg.apache.cocoon.ojb.samples.bean.PasswordEncoder);
>
> [...]
>
> var encoder = new PasswordEncoder();
>
> ?
>
> Just an "any idea"  ;-). I have not tried it - but I use the construct 
> above in some places.
>
> Let me know if that helps
>
> Benjamin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by Paul Joseph <pj...@gmail.com>.
I guess the message (below) was telling me that I had a Package, not a 
class.

org.mozilla.javascript.EvaluatorException: "file:///C:/Program 
Files/Apache Software Foundation/Tomcat 
5.5/webapps/webapp/webtask/request/Request.js", line 8: Not a Java 
class: [JavaPackage org.apache.cocoon.ojb.samples.bean.PasswordEncoder]

I changed the line by taking out the "new" at the beginning and the () 
at the end to:
var encoder = Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder;

And lo and behold it works.

Not sure why as in my PasswordEncoder.java file, PasswordEncoder is a class.

public class PasswordEncoder {
...
}

Paul




Benjamin Boksa wrote:
>> Any ideas anyone?
>
> Have you tried
>
> importClass(Packages.rg.apache.cocoon.ojb.samples.bean.PasswordEncoder);
>
> [...]
>
> var encoder = new PasswordEncoder();
>
> ?
>
> Just an "any idea"  ;-). I have not tried it - but I use the construct 
> above in some places.
>
> Let me know if that helps
>
> Benjamin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by Benjamin Boksa <ma...@boksa.de>.
> Any ideas anyone?

Have you tried

importClass(Packages.rg.apache.cocoon.ojb.samples.bean.PasswordEncoder);

[...]

var encoder = new PasswordEncoder();

?

Just an "any idea"  ;-). I have not tried it - but I use the construct  
above in some places.

Let me know if that helps

Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by Paul Joseph <pj...@gmail.com>.
Ok, I removed the end brackets from line 8 of Request.js.  It used to be:
var encoder = new 
Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder();

After removing the end brackets it now is:
var encoder = new 
Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder;

I get this error with Cocoon 2.1.11 (used to be fine with 2.1.7):
org.mozilla.javascript.EcmaError: TypeError: [JavaPackage 
org.apache.cocoon.ojb.samples.bean.PasswordEncoder] is not a function, 
it is org.mozilla.javascript.NativeJavaPackage. (file:///C:/Program 
Files/Apache Software Foundation/Tomcat 
5.5/webapps/webapp/webtask/request/Request.js#8)

Any ideas anyone?

thx
Paul
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by David Legg <da...@searchevent.co.uk>.
Paul,

It occurs to me I might be talking complete gibberish here :-)

Unfortunately, I don't have the time to investigate more fully... but 
you might like to peruse the Rhino paper [1] which discusses how to 
communicate between Java and Javascript in far more detail.

[1] http://www.mozilla.org/rhino/ScriptingJava.html

Regards,
David Legg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by David Legg <da...@searchevent.co.uk>.
Don't quote me but I bet the version of the Rhino JavaScript interpreter 
[1] was upgraded and the new version does a better job of spotting this 
syntax error.

Regards,
David Legg

[1] http://www.mozilla.org/rhino/


Paul Joseph wrote:
> Hi David,
>
> Thank you for your reply.
>
> It works perfectly fine AS IS with Cocoon 2.1.7.
> Would you know what changed in Cocoon 2.1.11 to make this change needed?
>
> thx
> Paul
>
> David Legg wrote:
>> Hi Paul,
>>
>>> In my flowscript, I get an error on this line and I don't know 
>>> why--the jar file with this package is on the classpath.
>>> var encoder = new 
>>> Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder();
>>
>> Remove the brackets '()' from the end of the line.  You want to 
>> create a new Object and not call a function.
>>
>> Regards,
>> David Legg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by Paul Joseph <pj...@gmail.com>.
Hi David,

Thank you for your reply.

It works perfectly fine AS IS with Cocoon 2.1.7. 

Would you know what changed in Cocoon 2.1.11 to make this change needed?

thx
Paul

David Legg wrote:
> Hi Paul,
>
>> In my flowscript, I get an error on this line and I don't know 
>> why--the jar file with this package is on the classpath.
>> var encoder = new 
>> Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder();
>
> Remove the brackets '()' from the end of the line.  You want to create 
> a new Object and not call a function.
>
> Regards,
> David Legg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: problem with this line?

Posted by David Legg <da...@searchevent.co.uk>.
Hi Paul,

> In my flowscript, I get an error on this line and I don't know 
> why--the jar file with this package is on the classpath.
> var encoder = new 
> Packages.org.apache.cocoon.ojb.samples.bean.PasswordEncoder();

Remove the brackets '()' from the end of the line.  You want to create a 
new Object and not call a function.

Regards,
David Legg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org