More information. I think this might have to do with the classpath setting on the compiler. It seems to be creating its own classpath instead of passing the current cocoon classpath to the compiler. The classloader, being different, cannot find any classes outside of the current WAR to compile. This would mean that you would have to deploy every single library you use in the WEB-INF/lib directory. That is untenable for large applications. Further, for applications that have to wire into EJB, it is even worse. This is because you will often have a set of interfaces for a server side component and need to redeploy them. With this limitation, my classes in cocoon could get out of synch with those deployed in the application server quite easily and cause all sorts of nastiness.
 
Is this a bug perhaps? Has anyone else hit this?
 
-- Robert
----- Original Message -----
Sent: Thursday, January 30, 2003 4:47 AM
Subject: XSP Compiler Issue: Class Not found

Greetings. I decided that I wanted to try writing an XSP page. I know about logicsheets but just to start I figured Id go the brute force approach. The following is the XSP page.
 
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
          xmlns:jconfer="http://www.jconfer.org/">
  <xsp:structure>
    <xsp:include>javax.naming.InitialContext</xsp:include>
    <xsp:include>javax.naming.NamingException</xsp:include>
    <xsp:include>javax.rmi.PortableRemoteObject</xsp:include>
    <xsp:include>java.util.Collection</xsp:include>
    <xsp:include>java.util.Set</xsp:include>
    <xsp:include>java.util.Iterator</xsp:include>
    <xsp:include>java.util.Properties</xsp:include>
    <xsp:include>jconfer.data.Smiley</xsp:include>
    <xsp:include>mirror.datafetch.DataFetch</xsp:include>
    <xsp:include>mirror.datafetch.DataFetchHome</xsp:include>
  </xsp:structure>
 
  <jconfer:page>
    <xsp:logic>
      try {
        InitialContext ictxt = new InitialContext();
        <message><xsp:expr>ictxt.getNameInNamespace()</xsp:expr></message>
       
        DataFetchHome dfHome = (DataFetchHome)PortableRemoteObject.narrow(
               ictxt.lookup("JConfer/DataFetch"), DataFetchHome.class);
        DataFetch dataFetch = dfHome.create();
        Collection smileys = dataFetch.performQuery(Smiley.class, null, null, null,
                                                  null, "code ascending");
        Iterator iter = smileys.iterator();
        Smiley tgtSmiley = null;
        <xsp:element>
          <xsp:param name="name"><xsp:expr>"smiley"</xsp:expr></xsp:param>
          while (iter.hasNext()) {
            tgtSmiley = (Smiley)iter.next();
            <xsp:attribute name="code"><xsp:expr>tgtSmiley.getCode()</xsp:expr></xsp:attribute>
            <xsp:attribute name="code"><xsp:expr>tgtSmiley.getDescription()</xsp:expr></xsp:attribute>
          }
        </xsp:element>
      } catch (Exception ex) {
        <message><xsp:expr>ex.getMessage()</xsp:expr></message>
      }
    </xsp:logic>
   
  </jconfer:page>
</xsp:page>
 
This page is basically a copy of a generator that DOES work .. SHown below.
 
package jconfer.client.generators;
 
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.servlet.http.HttpServletRequest;
import jconfer.data.Smiley;
import mirror.datafetch.DataFetch;
import mirror.datafetch.DataFetchHome;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.generation.AbstractGenerator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
 
/** Handles a command for getting an admin screen for forum smileys.
 *
 * <p><b><small>Current CVS Tag:  $Name$</b></small></p>
 * @version $Revision$
 * @author $author$
 */
public class SmileyAdminView extends GeneratorBase {
 
  /** {@inheritDoc} */
  public void generateContent() throws Exception {
    DataFetchHome dfHome = (DataFetchHome)jndiLookup(DataFetchHome.class,
                                                     "JConfer/DataFetch");
    DataFetch dataFetch = dfHome.create();
    // --
    Collection smileys = dataFetch.performQuery(Smiley.class, null, null, null,
                                                null, "code ascending");
    // --
    AttributesImpl attributes = new AttributesImpl();
    Smiley tgtSmiley = null;
    // -- Start the content
    this.contentHandler.startElement("", "smiley-admin-view", "smiley-admin-view", EMPTY_ATTRS);
    // -- Do internal elements.
    Iterator iter = smileys.iterator();
    while (iter.hasNext()) {
      tgtSmiley = (Smiley)iter.next();
      attributes.clear();
      attributes.addAttribute("", "code", "code", "", tgtSmiley.getCode());
      attributes.addAttribute("", "description", "description", "", tgtSmiley.getDescription());
      this.contentHandler.startElement("", "smiley", "smiley", attributes);
      this.contentHandler.endElement("", "smiley", "smiley");
    }
    // -- End the document
    this.contentHandler.endElement("", "smiley-admin-view", "smiley-admin-view");
  }
}
 
The problem is that when I try to run the XSP page, the compiler freaks out and cannot find any of the Mirror or JConfer classes. It gives me a class not found on all of them. However the generator works. These classes are deployed in another package and therefore are available to the classloader of the application server but somehow cocoon isnt seeing them. Is there any way I can tell cocoon that they are there? We know they are available because the generator does in fact work.
 
-- Robert
 

Reply via email to