cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <kschnei...@gmail.com>
Subject Re: Loading Java Classes through FlowScript
Date Sun, 08 Jan 2006 23:54:19 GMT
Two quick suggestions: Try putting the class in a package and make it public:

package ca.mcmastermm;

public class TestClazz {
  ...
}

On 1/8/06, mike rowse <mike@mcmastermm.ca> wrote:
> Hey.
>
> I am not a java programmer generally (although I understand enough
> syntax to be able to get by). I am currently starting to learn how to
> extend cocoon through additional java programming (as I'm going to have
> to wrap some one elses java work to be used through cocoon).
>
> With this in mind I have created a simple class that I wanted to load
> through flowscript to get going.
>
>  class TestKlazz {
>    public TestKlazz(){
>         // Tried with this line and without
>         // System.out.println("initialized");
>    }
>  }
>
> This class has been compiled and placed in
> $COCOON/build/webapp/WEB-INF/classes
>
> In flowscript I've called this function
>
> function testj(){
>         var test_obj = Packages.TestKlazz();
>         cocoon.sendPage("/");
> }
>
> Upon navigating to the pipeline that calls this function I get the
> error.
>
> org.mozilla.javascript.EvaluatorException:
> "file:/home/sator/mike/work/hyperpo/trunk/hyperpo/controller/hyperpocontroller.js", line
84: Internal error: attempt to access private/protected field "Class org.mozilla.javascript.NativeJavaClass
can not access a member of class TestKlazz with modifiers "public"".
>
> I will post the stacktrace if this might help. The machine I'm using is
> running cocoon 2.1.8 and the JVM is version 1.4.2 - 03
>
> I have tried playing with the class loader setting in web.xml and I have
> tried setting cocoon to run as a paranoid servlet. This is a very
> bizarre error (for such a simple class) and I can't find any mention of
> a similar problem on any of the mailing lists. The kind folks on IRC
> were also baffled (since this is seems to be very frequently done).
>
> I'm guessing there is something conceptually missing on my part or a
> dumb gotcha. Any help is greatly appreciated.
>
> Thanks,
> Mike
>
> ------------------------------------------------------------------------
>
> As an aside. Originally I was trying to run this class from a location
> outside of the usual locations (a need of the project). I was able to
> get the same error adding another directory through setting a
> <classpath></classpath> parameter in cocoon.xconf (for the flowscript).
> I stumbled upon this way of adding classes to the flowscript classpath
> through documentation for old versions of cocoon and there is no mention
> as far as I can see in the current documentation. I thought I'd mention
> this because it was the only way I extend the flowscript classpath but
> it seems like a deprecated way of doing things.

--
Kris Schneider <mailto:kschneider@gmail.com>

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


Mime
View raw message