You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Hugo Burm <hu...@xs4all.nl> on 2003/07/06 14:22:50 UTC

Component not visible from class loader

Hello,

I am using Avalon framework 4.1.4, and JDK 1.4.1

I have written an Avalon component following the white paper "Developing
with Apache Avalon".
I have written my ContainerComponent that creates a
ExcaliburComponentManager also based on the code in this white paper.
When I contextualize, configure and initialize my manager everything works
OK and the manager instantiates my Avalon component.
But when I am trying to do a lookup of this component I get the exception:

java.lang.IllegalArgumentException: interface
org.apache.avalon.framework.component.Component is not visible from class
loader
	at java.lang.reflect.Proxy.getProxyClass(Proxy.java:331)

The problem occurs only when I try to do this (create the container) from my
junit test class started from java main.
When I use exactly the same code, also using my own container, within a
servlet context (Cocoon), the lookup works fine, so it is not a simple type
error in e.g. the name of the role.

I experimented with class loaders but could not found a solution.

Any help appreciated.

Thanks

Hugo Burm

parts from the code:

The problem occurs at the third line below:
  FlowContainer container  = new FlowContainer();
  container.initialize();
  factory = (PersistenceFactory)
container.manager.lookup(survey.PersistenceFactory.ROLE);

The initialize function in the container:
  manager = new ExcaliburComponentManager();
  DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  Configuration conf = builder.buildFromFile("flow.xconf");

this.manager.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("documen
t"));
  this.manager.contextualize(new DefaultContext());
  this.manager.configure(conf);
  this.manager.initialize();


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Component not visible from class loader

Posted by Anton Tagunov <at...@mail.cnt.ru>.
Hello Hugo!

HB> I have written an Avalon component following the white paper
HB> "Developing with Apache Avalon".
An excellent book indeed :-)

HB> java.lang.IllegalArgumentException: interface
HB> org.apache.avalon.framework.component.Component is not visible from class
HB> loader
HB>         at java.lang.reflect.Proxy.getProxyClass(Proxy.java:331)

HB> The problem occurs only when I try to do this (create the container) from my
HB> junit test class started from java main.

My guess is that you're using the graphical JUnit launcher.
Probably I can not help you with that as I have never used it myself
(as you guess its some classloader issue, and probably needs more
dubegging)

But, if instead you create an Ant task, like I do

    <target name="test" depends="..."
            description="run tests">
        <junit printsummary="off">
            <formatter type="plain" usefile="false"/>
            <formatter type="xml"/> <!--*-->
            <classpath>
                <pathelement path="${java.api.compiled}"/>
                <pathelement path="${java.impl.compiled}"/>
                <pathelement path="${java.test.compiled}"/>
                <path refid="runtimecp"/>
            </classpath>
            <batchtest todir="${test.reports.dir}">
                <fileset dir="${java.test.prepr}">
                    <include name="**/test/*TestCase.java"/>
                    <exclude name="**/Abstract*"/>
                    <exclude name="**/UpdateableBoxTestCase*"/>
                </fileset>
            </batchtest>
        </junit>
    </target>
    
you're going to be okay. The line marked with <!--*-->
may be removed if you do not want test reports be put into xml
files to ${test.reports.dir}

    ant test

and only want the results to be printed to your console as you do.
Of course the todir attribute can also be removed in that case.

I agree that using the junit task in Ant 1.5.1 is somewhat tricky,
that's why I'm sending you the Ant task that does use it successfully.

In particular it looks to me that the printsummary attribute on
junit task does not work, so instead of setting it to 'true'
we use a plain-text formatter with usefile="false".

WBR, Anton


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org