[grails-dev] Class resolving changes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[grails-dev] Class resolving changes

Jochen Theodorou
Hi

it would be nice if you people could test Grails against groovy cvs
head. I commited my changes to ClassNode and class resolving yesterday.
I should solve some of the issues, so I would like to get feedback...
maybe there are new bugs in there too

bye blackdrag
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

graemer
Jochen,

I have attempted to replace the embeddeble groovy jar in Grails with a
version built from the latest groovy/core sources, it has
unfortunately broken Grails with the below error. To replicate
checkout grails, setup it as per the instructions
(http://grails.codehaus.org/Installation) and run the "blog" sample
app by typing:

grails init
grails run-app

The error will appear immediately and Grails will fail to start.Oh and
you'll need to replace the groovy jar in "grails/lib" as I
didn't commit it because of the problem

java.lang.LinkageError: duplicate class definition: User
  [script] java.lang.LinkageError: duplicate class definition: User
  [script]     at java.lang.ClassLoader.defineClass1(Native Method)
  [script]     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
  [script]     at java.security.SecureClassLoader.defineClass(SecureClassLoader
.java:124)
  [script]     at groovy.lang.GroovyClassLoader.access$200(GroovyClassLoader.ja
va:83)
  [script]     at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(Groo
vyClassLoader.java:550)
  [script]     at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClass
Loader.java:561)
  [script]     at org.codehaus.groovy.control.CompilationUnit$7.call(Compilatio
nUnit.java:729)
  [script]     at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryCla
ssNodes(CompilationUnit.java:936)
  [script]     at org.codehaus.groovy.control.CompilationUnit.classgen(Compilat
ionUnit.java:645)
  [script]     at org.codehaus.groovy.control.CompilationUnit.compile(Compilati
onUnit.java:481)
  [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
va:282)
  [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
va:245)
  [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
va:195)
  [script]     at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<
init>(DefaultGrailsApplication.java:105)
  [script]     at org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBe
an.afterPropertiesSet(GrailsApplicationFactoryBean.java:45)
  [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1003)
  [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
  [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
.getBean(AbstractBeanFactory.java:226)
  [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
.getBean(AbstractBeanFactory.java:147)
  [script]     at org.springframework.beans.factory.support.DefaultListableBean
Factory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
  [script]     at org.springframework.context.support.AbstractApplicationContex
t.refresh(AbstractApplicationContext.java:317)
  [script]     at org.springframework.web.context.support.AbstractRefreshableWe
bApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
  [script]     at org.springframework.web.context.ContextLoader.createWebApplic
ationContext(ContextLoader.java:230)
  [script]     at org.springframework.web.context.ContextLoader.initWebApplicat
ionContext(ContextLoader.java:156)
  [script]     at org.springframework.web.context.ContextLoaderServlet.init(Con
textLoaderServlet.java:81)
  [script]     at javax.servlet.GenericServlet.init(GenericServlet.java:168)
  [script]     at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHo
lder.java:383)
  [script]     at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.j
ava:243)
  [script]     at org.mortbay.jetty.servlet.ServletHandler.initializeServlets(S
ervletHandler.java:446)
  [script]     at org.mortbay.jetty.servlet.WebApplicationHandler.initializeSer
vlets(WebApplicationHandler.java:321)
  [script]     at org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebAp
plicationContext.java:511)
  [script]     at org.mortbay.util.Container.start(Container.java:72)
  [script]     at org.mortbay.http.HttpServer.doStart(HttpServer.java:753)
  [script]     at org.mortbay.util.Container.start(Container.java:72)
  [script]     at gjdk.org.mortbay.jetty.Server_GroovyReflector.invoke(Unknown
Source)
  [script]     at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
  [script]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(Me
taClassHelper.java:584)
  [script]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:345
)
  [script]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java
:144)
  [script]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(Invoke
rHelper.java:104)
  [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMetho
d(ScriptBytecodeAdapter.java:85)
  [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArg
umentsMethod(ScriptBytecodeAdapter.java:175)
  [script]     at ANT.run(ANT:10)
  [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:506)
  [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:458)
  [script]     at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:1
58)
  [script]     at org.apache.bsf.BSFManager$6.run(Unknown Source)
  [script]     at java.security.AccessController.doPrivileged(Native Method)
  [script]     at org.apache.bsf.BSFManager.exec(Unknown Source)
  [script]     at org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRu
nner.java:128)
  [script]     at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.
java:60)
  [script]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
  [script]     at org.apache.tools.ant.Task.perform(Task.java:364)
  [script]     at org.apache.tools.ant.Target.execute(Target.java:341)
  [script]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
  [script]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
a:1216)
  [script]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)

  [script]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
faultExecutor.java:40)
  [script]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068
)
  [script]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
  [script]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
  [script]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
  [script]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
  [script] Initializing servlet 'grails'
  [script] FrameworkServlet 'grails': initialization started
  [script] Loading WebApplicationContext for Spring FrameworkServlet 'grails'
  [script] Context initialization failed
  [script] org.springframework.beans.factory.BeanCreationException: Error creat
ing bean with name 'grailsApplication' defined in ServletContext resource [/WEB-
INF/applicationContext.xml]: Initialization of bean failed; nested exception is
java.lang.LinkageError: duplicate class definition: User
  [script] java.lang.LinkageError: duplicate class definition: User
  [script]     at java.lang.ClassLoader.defineClass1(Native Method)
  [script]     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
  [script]     at java.security.SecureClassLoader.defineClass(SecureClassLoader
.java:124)
  [script]     at groovy.lang.GroovyClassLoader.access$200(GroovyClassLoader.ja
va:83)
  [script]     at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(Groo
vyClassLoader.java:550)
  [script]     at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClass
Loader.java:561)
  [script]     at org.codehaus.groovy.control.CompilationUnit$7.call(Compilatio
nUnit.java:729)
  [script]     at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryCla
ssNodes(CompilationUnit.java:936)
  [script]     at org.codehaus.groovy.control.CompilationUnit.classgen(Compilat
ionUnit.java:645)
  [script]     at org.codehaus.groovy.control.CompilationUnit.compile(Compilati
onUnit.java:481)
  [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
va:282)
  [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
va:245)
  [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
va:195)
  [script]     at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<
init>(DefaultGrailsApplication.java:105)
  [script]     at org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBe
an.afterPropertiesSet(GrailsApplicationFactoryBean.java:45)
  [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1003)
  [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
  [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
.getBean(AbstractBeanFactory.java:226)
  [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
.getBean(AbstractBeanFactory.java:147)
  [script]     at org.springframework.beans.factory.support.DefaultListableBean
Factory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
  [script]     at org.springframework.context.support.AbstractApplicationContex
t.refresh(AbstractApplicationContext.java:317)
  [script]     at org.springframework.web.context.support.AbstractRefreshableWe
bApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
  [script]     at org.springframework.web.context.ContextLoader.createWebApplic
ationContext(ContextLoader.java:230)
  [script]     at org.springframework.web.context.ContextLoader.initWebApplicat
ionContext(ContextLoader.java:156)
  [script]     at org.springframework.web.context.ContextLoaderServlet.init(Con
textLoaderServlet.java:81)
  [script]     at javax.servlet.GenericServlet.init(GenericServlet.java:168)
  [script]     at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHo
lder.java:383)
  [script]     at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.j
ava:243)
  [script]     at org.mortbay.jetty.servlet.ServletHandler.initializeServlets(S
ervletHandler.java:446)
  [script]     at org.mortbay.jetty.servlet.WebApplicationHandler.initializeSer
vlets(WebApplicationHandler.java:321)
  [script]     at org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebAp
plicationContext.java:511)
  [script]     at org.mortbay.util.Container.start(Container.java:72)
  [script]     at org.mortbay.http.HttpServer.doStart(HttpServer.java:753)
  [script]     at org.mortbay.util.Container.start(Container.java:72)
  [script]     at gjdk.org.mortbay.jetty.Server_GroovyReflector.invoke(Unknown
Source)
  [script]     at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
  [script]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(Me
taClassHelper.java:584)
  [script]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:345
)
  [script]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java
:144)
  [script]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(Invoke
rHelper.java:104)
  [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMetho
d(ScriptBytecodeAdapter.java:85)
  [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArg
umentsMethod(ScriptBytecodeAdapter.java:175)
  [script]     at ANT.run(ANT:10)
  [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:506)
  [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:458)
  [script]     at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:1
58)
  [script]     at org.apache.bsf.BSFManager$6.run(Unknown Source)
  [script]     at java.security.AccessController.doPrivileged(Native Method)
  [script]     at org.apache.bsf.BSFManager.exec(Unknown Source)
  [script]     at org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRu
nner.java:128)
  [script]     at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.
java:60)
  [script]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
  [script]     at org.apache.tools.ant.Task.perform(Task.java:364)
  [script]     at org.apache.tools.ant.Target.execute(Target.java:341)
  [script]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
  [script]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
a:1216)
  [script]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)

  [script]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
faultExecutor.java:40)
  [script]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068
)
  [script]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
  [script]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
  [script]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
  [script]     at org.apache.tools.ant.launch.Launch
On 14/11/05, Jochen Theodorou <[hidden email]> wrote:
> Hi
>
> it would be nice if you people could test Grails against groovy cvs
> head. I commited my changes to ClassNode and class resolving yesterday.
> I should solve some of the issues, so I would like to get feedback...
> maybe there are new bugs in there too
>
> bye blackdrag
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

graemer
I have just run the grails code through a debugger and the class
loader appears to load BlogController.groovy first (which has a
reference to the User class) it then trys to load BlogBootStrap.groovy
(which also has a reference to this class. This is where it fails..

Could it be something wrong with the way we are loading classes in
Grails?  See "org.codehaus.groovy.grails.commons.DefaultGrailsApplication"
for how we are doing it

Regards,
Graeme

On 15/11/05, Graeme Rocher <[hidden email]> wrote:

> Jochen,
>
> I have attempted to replace the embeddeble groovy jar in Grails with a
> version built from the latest groovy/core sources, it has
> unfortunately broken Grails with the below error. To replicate
> checkout grails, setup it as per the instructions
> (http://grails.codehaus.org/Installation) and run the "blog" sample
> app by typing:
>
> grails init
> grails run-app
>
> The error will appear immediately and Grails will fail to start.Oh and
> you'll need to replace the groovy jar in "grails/lib" as I
> didn't commit it because of the problem
>
> java.lang.LinkageError: duplicate class definition: User
>   [script] java.lang.LinkageError: duplicate class definition: User
>   [script]     at java.lang.ClassLoader.defineClass1(Native Method)
>   [script]     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>   [script]     at java.security.SecureClassLoader.defineClass(SecureClassLoader
> .java:124)
>   [script]     at groovy.lang.GroovyClassLoader.access$200(GroovyClassLoader.ja
> va:83)
>   [script]     at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(Groo
> vyClassLoader.java:550)
>   [script]     at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClass
> Loader.java:561)
>   [script]     at org.codehaus.groovy.control.CompilationUnit$7.call(Compilatio
> nUnit.java:729)
>   [script]     at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryCla
> ssNodes(CompilationUnit.java:936)
>   [script]     at org.codehaus.groovy.control.CompilationUnit.classgen(Compilat
> ionUnit.java:645)
>   [script]     at org.codehaus.groovy.control.CompilationUnit.compile(Compilati
> onUnit.java:481)
>   [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
> va:282)
>   [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
> va:245)
>   [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
> va:195)
>   [script]     at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<
> init>(DefaultGrailsApplication.java:105)
>   [script]     at org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBe
> an.afterPropertiesSet(GrailsApplicationFactoryBean.java:45)
>   [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
> ableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1003)
>   [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
> ableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
>   [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
> .getBean(AbstractBeanFactory.java:226)
>   [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
> .getBean(AbstractBeanFactory.java:147)
>   [script]     at org.springframework.beans.factory.support.DefaultListableBean
> Factory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
>   [script]     at org.springframework.context.support.AbstractApplicationContex
> t.refresh(AbstractApplicationContext.java:317)
>   [script]     at org.springframework.web.context.support.AbstractRefreshableWe
> bApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
>   [script]     at org.springframework.web.context.ContextLoader.createWebApplic
> ationContext(ContextLoader.java:230)
>   [script]     at org.springframework.web.context.ContextLoader.initWebApplicat
> ionContext(ContextLoader.java:156)
>   [script]     at org.springframework.web.context.ContextLoaderServlet.init(Con
> textLoaderServlet.java:81)
>   [script]     at javax.servlet.GenericServlet.init(GenericServlet.java:168)
>   [script]     at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHo
> lder.java:383)
>   [script]     at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.j
> ava:243)
>   [script]     at org.mortbay.jetty.servlet.ServletHandler.initializeServlets(S
> ervletHandler.java:446)
>   [script]     at org.mortbay.jetty.servlet.WebApplicationHandler.initializeSer
> vlets(WebApplicationHandler.java:321)
>   [script]     at org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebAp
> plicationContext.java:511)
>   [script]     at org.mortbay.util.Container.start(Container.java:72)
>   [script]     at org.mortbay.http.HttpServer.doStart(HttpServer.java:753)
>   [script]     at org.mortbay.util.Container.start(Container.java:72)
>   [script]     at gjdk.org.mortbay.jetty.Server_GroovyReflector.invoke(Unknown
> Source)
>   [script]     at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
>   [script]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(Me
> taClassHelper.java:584)
>   [script]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:345
> )
>   [script]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java
> :144)
>   [script]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(Invoke
> rHelper.java:104)
>   [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMetho
> d(ScriptBytecodeAdapter.java:85)
>   [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArg
> umentsMethod(ScriptBytecodeAdapter.java:175)
>   [script]     at ANT.run(ANT:10)
>   [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:506)
>   [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:458)
>   [script]     at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:1
> 58)
>   [script]     at org.apache.bsf.BSFManager$6.run(Unknown Source)
>   [script]     at java.security.AccessController.doPrivileged(Native Method)
>   [script]     at org.apache.bsf.BSFManager.exec(Unknown Source)
>   [script]     at org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRu
> nner.java:128)
>   [script]     at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.
> java:60)
>   [script]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
> va:275)
>   [script]     at org.apache.tools.ant.Task.perform(Task.java:364)
>   [script]     at org.apache.tools.ant.Target.execute(Target.java:341)
>   [script]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
>   [script]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
> a:1216)
>   [script]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
>
>   [script]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
> faultExecutor.java:40)
>   [script]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068
> )
>   [script]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
>   [script]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
>   [script]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
>   [script]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
>   [script] Initializing servlet 'grails'
>   [script] FrameworkServlet 'grails': initialization started
>   [script] Loading WebApplicationContext for Spring FrameworkServlet 'grails'
>   [script] Context initialization failed
>   [script] org.springframework.beans.factory.BeanCreationException: Error creat
> ing bean with name 'grailsApplication' defined in ServletContext resource [/WEB-
> INF/applicationContext.xml]: Initialization of bean failed; nested exception is
> java.lang.LinkageError: duplicate class definition: User
>   [script] java.lang.LinkageError: duplicate class definition: User
>   [script]     at java.lang.ClassLoader.defineClass1(Native Method)
>   [script]     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>   [script]     at java.security.SecureClassLoader.defineClass(SecureClassLoader
> .java:124)
>   [script]     at groovy.lang.GroovyClassLoader.access$200(GroovyClassLoader.ja
> va:83)
>   [script]     at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(Groo
> vyClassLoader.java:550)
>   [script]     at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClass
> Loader.java:561)
>   [script]     at org.codehaus.groovy.control.CompilationUnit$7.call(Compilatio
> nUnit.java:729)
>   [script]     at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryCla
> ssNodes(CompilationUnit.java:936)
>   [script]     at org.codehaus.groovy.control.CompilationUnit.classgen(Compilat
> ionUnit.java:645)
>   [script]     at org.codehaus.groovy.control.CompilationUnit.compile(Compilati
> onUnit.java:481)
>   [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
> va:282)
>   [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
> va:245)
>   [script]     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.ja
> va:195)
>   [script]     at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<
> init>(DefaultGrailsApplication.java:105)
>   [script]     at org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBe
> an.afterPropertiesSet(GrailsApplicationFactoryBean.java:45)
>   [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
> ableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1003)
>   [script]     at org.springframework.beans.factory.support.AbstractAutowireCap
> ableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
>   [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
> .getBean(AbstractBeanFactory.java:226)
>   [script]     at org.springframework.beans.factory.support.AbstractBeanFactory
> .getBean(AbstractBeanFactory.java:147)
>   [script]     at org.springframework.beans.factory.support.DefaultListableBean
> Factory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
>   [script]     at org.springframework.context.support.AbstractApplicationContex
> t.refresh(AbstractApplicationContext.java:317)
>   [script]     at org.springframework.web.context.support.AbstractRefreshableWe
> bApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
>   [script]     at org.springframework.web.context.ContextLoader.createWebApplic
> ationContext(ContextLoader.java:230)
>   [script]     at org.springframework.web.context.ContextLoader.initWebApplicat
> ionContext(ContextLoader.java:156)
>   [script]     at org.springframework.web.context.ContextLoaderServlet.init(Con
> textLoaderServlet.java:81)
>   [script]     at javax.servlet.GenericServlet.init(GenericServlet.java:168)
>   [script]     at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHo
> lder.java:383)
>   [script]     at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.j
> ava:243)
>   [script]     at org.mortbay.jetty.servlet.ServletHandler.initializeServlets(S
> ervletHandler.java:446)
>   [script]     at org.mortbay.jetty.servlet.WebApplicationHandler.initializeSer
> vlets(WebApplicationHandler.java:321)
>   [script]     at org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebAp
> plicationContext.java:511)
>   [script]     at org.mortbay.util.Container.start(Container.java:72)
>   [script]     at org.mortbay.http.HttpServer.doStart(HttpServer.java:753)
>   [script]     at org.mortbay.util.Container.start(Container.java:72)
>   [script]     at gjdk.org.mortbay.jetty.Server_GroovyReflector.invoke(Unknown
> Source)
>   [script]     at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
>   [script]     at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(Me
> taClassHelper.java:584)
>   [script]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:345
> )
>   [script]     at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java
> :144)
>   [script]     at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(Invoke
> rHelper.java:104)
>   [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMetho
> d(ScriptBytecodeAdapter.java:85)
>   [script]     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArg
> umentsMethod(ScriptBytecodeAdapter.java:175)
>   [script]     at ANT.run(ANT:10)
>   [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:506)
>   [script]     at groovy.lang.GroovyShell.evaluate(GroovyShell.java:458)
>   [script]     at org.codehaus.groovy.bsf.GroovyEngine.exec(GroovyEngine.java:1
> 58)
>   [script]     at org.apache.bsf.BSFManager$6.run(Unknown Source)
>   [script]     at java.security.AccessController.doPrivileged(Native Method)
>   [script]     at org.apache.bsf.BSFManager.exec(Unknown Source)
>   [script]     at org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRu
> nner.java:128)
>   [script]     at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.
> java:60)
>   [script]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
> va:275)
>   [script]     at org.apache.tools.ant.Task.perform(Task.java:364)
>   [script]     at org.apache.tools.ant.Target.execute(Target.java:341)
>   [script]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
>   [script]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
> a:1216)
>   [script]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
>
>   [script]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
> faultExecutor.java:40)
>   [script]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068
> )
>   [script]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
>   [script]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
>   [script]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
>   [script]     at org.apache.tools.ant.launch.Launch
> On 14/11/05, Jochen Theodorou <[hidden email]> wrote:
> > Hi
> >
> > it would be nice if you people could test Grails against groovy cvs
> > head. I commited my changes to ClassNode and class resolving yesterday.
> > I should solve some of the issues, so I would like to get feedback...
> > maybe there are new bugs in there too
> >
> > bye blackdrag
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

Jochen Theodorou
In reply to this post by graemer
Graeme Rocher schrieb:

> Jochen,
>
> I have attempted to replace the embeddeble groovy jar in Grails with a
> version built from the latest groovy/core sources, it has
> unfortunately broken Grails with the below error. To replicate
> checkout grails, setup it as per the instructions
> (http://grails.codehaus.org/Installation) and run the "blog" sample
> app by typing:
>
> grails init
> grails run-app
>
> The error will appear immediately and Grails will fail to start.Oh and
> you'll need to replace the groovy jar in "grails/lib" as I
> didn't commit it because of the problem
>
> java.lang.LinkageError: duplicate class definition: User

looking at the trace I suspect some things... first, you are creating a
new CompilationUnit for each script, because you are using
GroovyClassLoader#parseClass.

parseClass can't handle compilation of multiple files very good. It's
only to compile 1 file. To compile multiple files you have to use the
same mechanisms groovyc is using, that means to use CompilationUnit
directly.

basically this is:

CompilationUnit cu = new CompilationUnit(configuration,null,loader)
for (i:sources){ cu.addSource(i) }
unit.compile()

configuration is of type CompilerConfiguration and contains for example
the target directory. If you don't wish to use that configuration can be
null.
loader is a GroovyClassLoader. This loader will be used to define
classes in. If you wish to create the class multiple times, then you
should give different loaders here. setting loader to null is possible,
but since you need the classes after, I would not recommend it.

and an explanation why the above Exception happens. User is a groovy
script that is required by another script, that is compiled before User.
compiling that script let's the compiler look for the file and compile
it then. If it were ot be able to find that file or compile it, then
compilation would have failed. next, you are calling parseClass for
User. A new CompilationUnit is created, which does not know that we have
already created a class for User. The result is, that User again is
parsed and compiled and again a byte[] is created to define the class.
But as the classloader is the same, the definition of the class fails.
It has to fail.

So this is no bug, it's moe wrong handling ;)

bye blackdrag

bye blackdrag
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

graemer
On 15/11/05, Jochen Theodorou <[hidden email]> wrote:

> Graeme Rocher schrieb:
>
> > Jochen,
> >
> > I have attempted to replace the embeddeble groovy jar in Grails with a
> > version built from the latest groovy/core sources, it has
> > unfortunately broken Grails with the below error. To replicate
> > checkout grails, setup it as per the instructions
> > (http://grails.codehaus.org/Installation) and run the "blog" sample
> > app by typing:
> >
> > grails init
> > grails run-app
> >
> > The error will appear immediately and Grails will fail to start.Oh and
> > you'll need to replace the groovy jar in "grails/lib" as I
> > didn't commit it because of the problem
> >
> > java.lang.LinkageError: duplicate class definition: User
>
> looking at the trace I suspect some things... first, you are creating a
> new CompilationUnit for each script, because you are using
> GroovyClassLoader#parseClass.
>
> parseClass can't handle compilation of multiple files very good. It's
> only to compile 1 file. To compile multiple files you have to use the
> same mechanisms groovyc is using, that means to use CompilationUnit
> directly.
>
> basically this is:
>
> CompilationUnit cu = new CompilationUnit(configuration,null,loader)
> for (i:sources){ cu.addSource(i) }
> unit.compile()
>
> configuration is of type CompilerConfiguration and contains for example
> the target directory. If you don't wish to use that configuration can be
> null.
> loader is a GroovyClassLoader. This loader will be used to define
> classes in. If you wish to create the class multiple times, then you
> should give different loaders here. setting loader to null is possible,
> but since you need the classes after, I would not recommend it.

Ok, but why did this problem not occur in the current groovy jsr 04
jar that we are using which is a few weeks older than the latest
build?

>
> and an explanation why the above Exception happens. User is a groovy
> script that is required by another script, that is compiled before User.
> compiling that script let's the compiler look for the file and compile
> it then. If it were ot be able to find that file or compile it, then
> compilation would have failed. next, you are calling parseClass for
> User. A new CompilationUnit is created, which does not know that we have
> already created a class for User. The result is, that User again is
> parsed and compiled and again a byte[] is created to define the class.
> But as the classloader is the same, the definition of the class fails.
> It has to fail.

Actually I dispute that when I ran the code through the debugger
parseClass("User.groovy") is NEVER called, it actually fails when
attempting to load it as a related class. i.e.

First BlogBootStrap.groovy is loaded which has a relationship to User.groovy
Then BlogController.groovy is loaded which ALSO has a relationship to
User.groovy

This is where it fails not whent calling parseClass
>
> So this is no bug, it's moe wrong handling ;)
>
> bye blackdrag
>
> bye blackdrag
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

Jochen Theodorou
Graeme Rocher schrieb:
[...]
>
> Ok, but why did this problem not occur in the current groovy jsr 04
> jar that we are using which is a few weeks older than the latest
> build?

because the old mechanism was to guess a classname sometimes. With the
result that script files are not compiled, or compiled later when the
script runs and becasue of this compilation errors were swallowed.

[...]
> Actually I dispute that when I ran the code through the debugger
> parseClass("User.groovy") is NEVER called, it actually fails when
> attempting to load it as a related class. i.e.
 >
> First BlogBootStrap.groovy is loaded which has a relationship to User.groovy
> Then BlogController.groovy is loaded which ALSO has a relationship to
> User.groovy
>
> This is where it fails not whent calling parseClass

ah ok, it is parseClass, but not for User.groovy. It's the same as if
you would compile User.groovy directly the secound time. You just added
one level of indirection. Btw, in the example with the CompilationUnit I
gave in my last email, you don't have to add User.groovy as source
there, but you have to add the Blog files. That's enough

bye blackdrag

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

graemer
On 15/11/05, Jochen Theodorou <[hidden email]> wrote:

> Graeme Rocher schrieb:
> [...]
> >
> > Ok, but why did this problem not occur in the current groovy jsr 04
> > jar that we are using which is a few weeks older than the latest
> > build?
>
> because the old mechanism was to guess a classname sometimes. With the
> result that script files are not compiled, or compiled later when the
> script runs and becasue of this compilation errors were swallowed.

Ok I understand

>
> [...]
> > Actually I dispute that when I ran the code through the debugger
> > parseClass("User.groovy") is NEVER called, it actually fails when
> > attempting to load it as a related class. i.e.
>  >
> > First BlogBootStrap.groovy is loaded which has a relationship to User.groovy
> > Then BlogController.groovy is loaded which ALSO has a relationship to
> > User.groovy
> >
> > This is where it fails not whent calling parseClass
>
> ah ok, it is parseClass, but not for User.groovy. It's the same as if
> you would compile User.groovy directly the secound time. You just added
> one level of indirection. Btw, in the example with the CompilationUnit I
> gave in my last email, you don't have to add User.groovy as source
> there, but you have to add the Blog files. That's enough

ok any advice as to how I guess which classes to add to
CompilationUnit and which not or do i have to do an analysis of all
the class relationships first? :-)

>
> bye blackdrag
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

Jochen Theodorou
Graeme Rocher schrieb:

[..]
>
> ok any advice as to how I guess which classes to add to
> CompilationUnit and which not or do i have to do an analysis of all
> the class relationships first? :-)

just add all files you would have put into parseClass. The analysis is
done by the compiler

bye blackdrag
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

graemer
On 15/11/05, Jochen Theodorou <[hidden email]> wrote:

> Graeme Rocher schrieb:
>
> [..]
> >
> > ok any advice as to how I guess which classes to add to
> > CompilationUnit and which not or do i have to do an analysis of all
> > the class relationships first? :-)
>
> just add all files you would have put into parseClass. The analysis is
> done by the compiler

Great thanks!
Graeme
>
> bye blackdrag
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [grails-dev] Class resolving changes

graemer
Hi Jochen,

I'm struggling to understand what I'm doing wrong here. This is my
code trimmed down for clarity:

                this.cl = new GroovyClassLoader();
                CompilationUnit cu = new CompilationUnit(this.cl);
                                               
                for (int i = 0; resources != null && i < resources.length; i++) {
                                cu.addSource(resources[i].getFile());
                }
                try {
                        cu.compile();
                } catch (CompilationFailedException e) {
                          throw new CompilationFailedException();
                }
                // get all the classes that were loaded
                Class[] classes = cl.getLoadedClasses();

However, all it gives me is a long list of
"groovy.lang.GroovyClassLoader$NOT_RESOLVED" classes no compilations
errors nothing. I know the classes are being added because in the
actual code i have logging which inside the for loop.

Am I missing something?

Cheers,
Graeme


On 15/11/05, Graeme Rocher <[hidden email]> wrote:

> On 15/11/05, Jochen Theodorou <[hidden email]> wrote:
> > Graeme Rocher schrieb:
> >
> > [..]
> > >
> > > ok any advice as to how I guess which classes to add to
> > > CompilationUnit and which not or do i have to do an analysis of all
> > > the class relationships first? :-)
> >
> > just add all files you would have put into parseClass. The analysis is
> > done by the compiler
>
> Great thanks!
> Graeme
> >
> > bye blackdrag
> >
>
Loading...