cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saskia Heesen" <saskia.hee...@gmx.de>
Subject CoWarp: Loading Class ApplicationUtil
Date Mon, 11 Sep 2006 21:14:09 GMT
Hello

in my application, I'd like to check if the user has the appropriate role. There is a method
isUserInRole() in the ApplicationUtil class from the cowarp package.

My first attempt was:

ApplicationUtil appUtil = new ApplicationUtil();
if (appMan.isLoggedIn("Demo")){
  User user = appUtil.getUser(); // Line no 39

I got an exception:

java.lang.NullPointerException
        at org.apache.cocoon.components.ContextHelper.getObjectModel(ContextHelper.java:89)
        at org.osoco.cowarp.ApplicationUtil.getUser(ApplicationUtil.java:99)
        at org.test.auth.CFormsFlow.doQuadrat(CFormsFlow.java:39)

Then I tried to load ApplicationUtil as a component. I added in cocoon.xconf:

<component role="org.osoco.cowarp.ApplicationUtil"
             class="org.osoco.cowarp.ApplicationUtil"/>

My flowscript was:

var appMan = cocoon.getComponent("org.osoco.cowarp.ApplicationManager");
if (appMan.isLoggedIn("Demo")){ 
var appUtil = cocoon.getComponent("org.osoco.cowarp.ApplicationUtil");
var user = appUtil.getUser(); //Line no 8

I received this error message:

org.mozilla.javascript.EcmaError: getUser is not a function.
TypeError - context://square/square.js - 8:0

My javaflow was:

appUtil = (ApplicationUtil)getComponent(
"org.osoco.cowarp.ApplicationUtil");

Error message is:

java.lang.ClassCastException: $Proxy27

The output of "System.out.println(o.getClass() + "@" + o.getClass().getClassLoader());" is:

class $Proxy27@WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
StandardClassLoader
  delegate: true
  repositories:
    file:/usr/local/jakarta-tomcat5.0/shared/classes/
----------> Parent Classloader:
StandardClassLoader
  delegate: true
  repositories:
    file:/usr/local/jakarta-tomcat5.0/common/classes/
    file:/usr/local/jakarta-tomcat5.0/common/lib/servlet-api.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/ant.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/commons-collections-3.1.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/commons-dbcp-1.2.1.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/commons-el.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/commons-pool-1.2.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/jasper-compiler.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/jasper-runtime.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/jsp-api.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/naming-common.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/naming-factory.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/naming-java.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/naming-resources.jar
    file:/usr/local/jakarta-tomcat5.0/common/lib/ant-launcher.jar
    file:/usr/local/diablo-jdk1.5.0/lib/tools.jar
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@1855af5

I think the classloader didn't find the component. I changed the javaflow into 

appUtil = (ApplicationUtil)getComponent(ApplicationUtil);

Then I get the message in eclipse: ApplicationUtil can't be resolved

Is there a way to load the component ApplicationUtil?

Thanks in advance

 Saskia


-- 


"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail

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


Mime
View raw message