You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by "Nacho G. Mac Dowell" <ig...@informa.es> on 2005/08/05 11:43:04 UTC

ChainGenerator

I've successfully mavenized api, xs and js. All tests are ran by maven 
and pass. I am now mavenizing jm and I am facing a class loading problem 
with the chain generator. If I use it as-is (not from ant, from maven), 
then there is a npe because 
Thread.currentThread().getContextClassLoader() is null. I tried using 
getClass().getClassLoader() but it then fails with

java.lang.ClassCastException: The controller must be an interface

If I do a JavaSource.toString it is not an interface so what I am 
thinking is that maybe there is a bug in CompiledClassReflector.

If in CompildeClassReflector#getJavaSource(JavaSourceFactory)

we do the following:

        Class c = getCompiledClass();
        JavaSource js = new 
JavaSourceFactory().newJavaSource(JavaQNameImpl.getInstance(c.getName(), 
true));
+        if (c.isInterface()) {
+            js.setType(JavaSource.INTERFACE);
+        }
        Method[] methods = c.getMethods();
        for (int i = 0;  i < methods.length;  i++) {
            Method m = methods[i];
            getMethod(js, m);
        }

it works. Maybe more checks might be needed to get it correct. What do 
you think?


nacho

PD: I think there might be an error in ChainGenerator on method
loadSources(ClassLoader pClassLoader, JavaQName pQName,
                             JavaSourceFactory pFactory,
                             List pSources, Set pNames)

In this method it then calls loadSource like this:

JavaSource js = loadSource(Thread.currentThread().getContextClassLoader(),
                                   pQName.toString(), pFactory);

using a (possibly) different class loader.

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


Re: ChainGenerator

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 8/19/05, Nacho G. Mac Dowell <ig...@informa.es> wrote:

Update and try again, please.

-- 
What are the first steps on the moon, compared to your child's?

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


Re: ChainGenerator

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
Update your sources to be able to reproduce!

nacho

PD: On common-build there is a maven.xml with a goal build. All projects 
inherit this goal

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


Re: ChainGenerator

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
Jochen Wiedmann wrote:

>Checked out the branch, but have no idea how to build and test the project?
>  
>
I'd suggest that you first do on the top level project a maven 
multiproject:install to get all the artifacts on your local repository.

Then on jm do a maven clean test

If you play around with the js ant target then you'll need to do on js a 
maven jar:install each time. It's a bit of a pain, but I'm sure someone 
can come up with a better solution...

Is this reproducible?

On eclipse I am not sure if I created the MAVEN_REPO var or if the maven 
plugin set this for me. All eclipse dependencies extend MAVEN_REPO

best regards,

nacho

PD: I found that you can't do anything out of the workspace with 
subclipse. If you do, it won't see it in the sync view. Even more weird 
it might even think that the file has been deleted.

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


Re: ChainGenerator

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 8/19/05, Nacho G. Mac Dowell <ig...@informa.es> wrote:

> Can you take a look at this?

Checked out the branch, but have no idea how to build and test the project?

Sorry,

Jochen

-- 
What are the first steps on the moon, compared to your child's?

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


Re: ChainGenerator

Posted by "Nacho G. Mac Dowell" <ig...@informa.es>.
Jochen Wiedmann wrote:

> I can't tell you what's wrong, but definitely, there is an error. The 
> ChainGenerator is indeed invoked for interfaces only.
>
> I suggest that you commit your current status into a branch and give 
> me a chance to look into the problem.

Can you take a look at this?

Nacho G. Mac Dowell wrote:

> If I use it as-is (not from ant, from maven), then there is a npe 
> because Thread.currentThread().getContextClassLoader() is null. I 
> tried using getClass().getClassLoader() but it then fails with
>
> java.lang.ClassCastException: The controller must be an interface
>
> If I do a JavaSource.toString it is not an interface so what I am 
> thinking is that maybe there is a bug in CompiledClassReflector.
>
> If in CompildeClassReflector#getJavaSource(JavaSourceFactory)
>
> we do the following:
>
>        Class c = getCompiledClass();
>        JavaSource js = new 
> JavaSourceFactory().newJavaSource(JavaQNameImpl.getInstance(c.getName(), 
> true));
> +        if (c.isInterface()) {
> +            js.setType(JavaSource.INTERFACE);
> +        }
>        Method[] methods = c.getMethods();
>        for (int i = 0;  i < methods.length;  i++) {
>            Method m = methods[i];
>            getMethod(js, m);
>        }
>
> it works. Maybe more checks might be needed to get it correct. What do 
> you think?
>
>
> nacho
>
> PD: I think there might be an error in ChainGenerator on method
> loadSources(ClassLoader pClassLoader, JavaQName pQName,
>                             JavaSourceFactory pFactory,
>                             List pSources, Set pNames)
>
> In this method it then calls loadSource like this:
>
> JavaSource js = 
> loadSource(Thread.currentThread().getContextClassLoader(),
>                                   pQName.toString(), pFactory);
>
> using a (possibly) different class loader.



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


Re: ChainGenerator

Posted by Jochen Wiedmann <jo...@gmail.com>.
Nacho G. Mac Dowell wrote:
> I've successfully mavenized api, xs and js. All tests are ran by maven 
> and pass. I am now mavenizing jm and I am facing a class loading problem 
> with the chain generator. If I use it as-is (not from ant, from maven), 
> then there is a npe because 
> Thread.currentThread().getContextClassLoader() is null. I tried using 
> getClass().getClassLoader() but it then fails with
> 
> java.lang.ClassCastException: The controller must be an interface
> 
> If I do a JavaSource.toString it is not an interface so what I am 
> thinking is that maybe there is a bug in CompiledClassReflector.

I can't tell you what's wrong, but definitely, there is an error. The 
ChainGenerator is indeed invoked for interfaces only.

I suggest that you commit your current status into a branch and give me 
a chance to look into the problem.


Jochen

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