Hey its great to hear you're writing a groovy sample, would you contribute
it back to Tuscany to include in our samples?

I think you're correct, the classloader is not being initialized correctly.
In the GroovyComponentBuilder the ClassLoader from the DeploymentContext is
the wrong one to be using, its null as you've seen. It really wants the
application ClassLoader which is available in the DeploymentContext passed
into the load method of the ImplementationLoader class in the Groovy
package. I think what needs to happen is GroovyImplementation should have a
ClassLoader field added with getter/setters, the
ImplementationLoader.loadmethod should set the Classloader on the
GroovyImplementation from the
DeploymentContext, then the GroovyComponentBuilder should create the
GroovyClassLoader using the ClassLoader from the GroovyImplementation  (the
implementation variable) instead of the DeploymentContext.

You can see all that being done if you look at the Tuscany JavaScript
container.

Does this make sense to you? Would you be interested in submitting a patch
for this? Say if you'd prefer to be just be using Groovy and I'll fix this
for you right away.

  ...ant

PS. Note, i think there's another problem you'll hit after fixing this which
is the GroovyComponentType is not initializing the Scope correctly. This
could be done in a a default constructor just as the JavaScriptComponentType
does.

On 1/12/07, lee zhenghui <[EMAIL PROTECTED]> wrote:

hi,
   I am writing a helloworld sample for sca groovy service, but
encountered
a problem here:

     java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java
:124)
    at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:92)
    at groovy.lang.GroovyClassLoader$ClassCollector.createClass(
GroovyClassLoader.java:457)
    at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(
GroovyClassLoader.java:475)
    at groovy.lang.GroovyClassLoader$ClassCollector.call(
GroovyClassLoader.java:479)
    at org.codehaus.groovy.control.CompilationUnit$9.call(
CompilationUnit.java:757)
    at
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(
CompilationUnit.java:947)
    at org.codehaus.groovy.control.CompilationUnit.compile(
CompilationUnit.java:478)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java
:306)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java
:275)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java
:270)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java
:242)
    at org.apache.tuscany.container.groovy.GroovyComponentBuilder.build(
GroovyComponentBuilder.java:80)
    at org.apache.tuscany.core.builder.BuilderRegistryImpl.build(
BuilderRegistryImpl.java:106)
    at
org.apache.tuscany.core.implementation.composite.CompositeBuilder.build(
CompositeBuilder.java:56)
    at org.apache.tuscany.core.builder.BuilderRegistryImpl.build(
BuilderRegistryImpl.java:106)
    at org.apache.tuscany.core.deployer.DeployerImpl.build(
DeployerImpl.java
:142)
    at org.apache.tuscany.core.deployer.DeployerImpl.deploy(
DeployerImpl.java:97)
    at org.apache.tuscany.core.launcher.LauncherImpl.bootApplication(
LauncherImpl.java:215)
    at org.apache.tuscany.test.SCATestCase.setUp(SCATestCase.java:88)
    at test.tuscany.groovy.HelloWorldTest.setUp(HelloWorldTest.java:35)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(
JUnit3TestReference.java:128)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)

  I gave an investigation on this issue, What I found is,
GroovyClassLoader's parent class loader is Null (pls see in
GroovyComponentBuilder.java) , in addition, the parent classloader for
GroovyClassLoader is obtained from DeploymentContext,  actually this
DeploymentContext will always be constructed without specify a
classloader.
(pls see line 90 in DeployerImpl.java).

  Does anybody can tell me that this problem is caused by usage error or
product issue?
--
Thanks & Best Wishes
-----------------------------------
[EMAIL PROTECTED]


Reply via email to