You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by C Bram Dit Saint Amand <sc...@comp.leeds.ac.uk> on 2003/07/03 21:12:00 UTC

a custom class

My former problem being solved (thank you Christian Haul), I tested
something else today.
I tried to use my own class called 'DbApi' in a logicsheet.


I inserted this code (1):
----
<xsp:structure>
    <xsp:include>DbApi</xsp:include>
</xsp:structure>
<!-- DbApi is the name of the class, the file is 'DbApi.java'-->
----
into the xsp file (generator).

I added to the CLASSPATH the directory where 'DbApi.java' and
'DbApi.class' are.

As for the logicsheet, inside a <xsp:logic> tag, I tried the following:
----
DbApi db_api = new DbApi();

DbApi.newInstance().connect("", "");
//'connect(String, String)' is a method from the DbApi class
----

Both don't work (I got the infamous 'Cocoon Confusion' error message). I
have no clue if the <xsp:include> correctly included the file or not.

I tried to insert the code (1) into the logicsheet instead, but it didn't
solve the problem.


The Questions:
--------------
1) Is it possible to include custom classes with <xsp:include>, or can we
only include existing java classes this way?
2) If we really CAN include custom classes this way, what is wrong in my
code / how to do it?


Thanks in advance.


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


Re: a custom class

Posted by C Bram Dit Saint Amand <sc...@comp.leeds.ac.uk>.
I solved the problem a while ago by putting the .class file in a
subdirectory of WEB-INF/classes (and by creating the corresponding package
in the java class).

I thereore think that if you put your custom classes' files directly in
the WEB_INF/classes, you won't be able to instanciate them in your XSP
files.



On Fri, 4 Jul 2003, C Bram Dit Saint Amand wrote:

> The article I was talking about:
> http://www.aoindustries.com/docs/cocoon-1.8/faqs.html
> (search for "I used xsp:include to import my classes")
>
> But still, this FAQ refers to the v1.8 of Cocoon, and states that the
> problem should be solved in Cocoon 2.
>
>
> ---------------------------------------------------------------------
> 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: a custom class

Posted by C Bram Dit Saint Amand <sc...@comp.leeds.ac.uk>.
The article I was talking about:
http://www.aoindustries.com/docs/cocoon-1.8/faqs.html
(search for "I used xsp:include to import my classes")

But still, this FAQ refers to the v1.8 of Cocoon, and states that the
problem should be solved in Cocoon 2.


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


Re: a custom class

Posted by C Bram Dit Saint Amand <sc...@comp.leeds.ac.uk>.
The probelm is not related to the fact I'm adding the directory to the
classpath. I did this because I read an article on that (I'll give the
link in a further message probably - I don't remember it now)

My class files (the .java & the corresponding .class) are in the
'cocoon/WEB-INF/class' directory, so the problem is elsewhere.


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


Re: a custom class

Posted by Geoff Howard <co...@leverageweb.com>.
C Bram Dit Saint Amand wrote:

>My former problem being solved (thank you Christian Haul), I tested
>something else today.
>I tried to use my own class called 'DbApi' in a logicsheet.
>  
>
...

>
>I added to the CLASSPATH the directory where 'DbApi.java' and
>'DbApi.class' are.
>
I think this is your problem right here.  The CLASSPATH is not involved 
in resolving resources within Cocoon (or
usually other applications in servlet containers).  You want to put your 
classes (if unjarred) under the proper directory
structure according to their package hierarchy under WEB-INF/classes or 
(if jarred) in WEB-INF/lib.  You can
also experiment with the extra-classpath setting in... I forget where - 
either web.xml or cocoon.xconf.  But I'd
suggest using WEB-INF unless you have a real reason to the contrary.

Geoff Howard



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