cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Ant cgen task not working after following tutorial
Date Mon, 25 May 2009 10:27:16 GMT
I know nothing about cdef, but cgen works pretty well in all known  
environments.

The only thing I can think of is to check the classpath that you set  
on your file, and trim it to just Cayenne and its dependencies. I  
don't see task classpath in your logs. Maybe print it like this:

<property name="cp" refid="full.classpath"/>
<echo>${cp}</echo>

Andrus



On May 25, 2009, at 1:15 PM, Joseph Wamicha wrote:

> Back to the original error :(
>
> Could using the cdef class generation with ant version 1.7.1 be the  
> problem?
>
>
> Total time: 0 seconds
> sysadmin@astrodon:/mnt/sda3/EclipseWork/testpersistence$ ant -v  
> classgen
> Apache Ant version 1.7.1 compiled on November 10 2008
> Buildfile: build.xml
> Detected Java version: 1.6 in: /usr/lib/jvm/java-6-sun-1.6.0.13/jre
> Detected OS: Linux
> parsing buildfile /mnt/sda3/EclipseWork/testpersistence/build.xml  
> with URI = file:/mnt/sda3/EclipseWork/testpersistence/build.xml
> Project base dir set to: /mnt/sda3/EclipseWork/testpersistence
> [antlib:org.apache.tools.ant] Could not load definitions from  
> resource org/apache/tools/ant/antlib.xml. It could not be found.
> parsing buildfile jar:file:/mnt/sda3/EclipseWork/testpersistence/lib/ 
> cayenne-server-3.0M5.jar!/org/apache/cayenne/tools/antlib.xml with  
> URI = jar:file:/mnt/sda3/EclipseWork/testpersistence/lib/cayenne- 
> server-3.0M5.jar!/org/apache/cayenne/tools/antlib.xml
> Build sequence for target(s) `classgen' is [classgen]
> Complete build sequence is [classgen, prepare, clean, deploy,  
> hsqldbgen, build, dist, ]
>
> classgen:
>    [cgen] Generating superclass file: /mnt/sda3/EclipseWork/ 
> testpersistence/test/com/persistence/_Config.java
>
> BUILD FAILED
> java.lang.Exception: Problem initializing template loader:  
> org.apache.cayenne.gen.ClassGeneratorResourceLoader
> Error is: java.lang.ClassNotFoundException:  
> org.apache.cayenne.gen.ClassGeneratorResourceLoader
>   at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>   at java.lang.Class.forName0(Native Method)
>   at java.lang.Class.forName(Class.java:169)
>   at  
> org 
> .apache 
> .velocity 
> .runtime 
> .resource 
> .loader.ResourceLoaderFactory.getLoader(ResourceLoaderFactory.java:41)
>   at  
> org 
> .apache 
> .velocity 
> .runtime 
> .resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:142)
>   at  
> org 
> .apache 
> .velocity 
> .runtime 
> .RuntimeInstance.initializeResourceManager(RuntimeInstance.java:522)
>   at  
> org 
> .apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java: 
> 227)
>   at  
> org 
> .apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java: 
> 461)
>   at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java: 
> 106)
>   at  
> org 
> .apache 
> .cayenne 
> .gen.ClassGenerationAction.getTemplate(ClassGenerationAction.java:273)
>   at  
> org 
> .apache 
> .cayenne 
> .gen.ClassGenerationAction.execute(ClassGenerationAction.java:241)
>   at  
> org 
> .apache 
> .cayenne 
> .gen.ClassGenerationAction.execute(ClassGenerationAction.java:213)
>   at  
> org 
> .apache 
> .cayenne 
> .tools.CayenneGeneratorTask.execute(CayenneGeneratorTask.java:163)
>   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java: 
> 288)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at  
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>   at  
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:25)
>   at java.lang.reflect.Method.invoke(Method.java:597)
>   at  
> org 
> .apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java: 
> 106)
>   at org.apache.tools.ant.Task.perform(Task.java:348)
>   at org.apache.tools.ant.Target.execute(Target.java:357)
>   at org.apache.tools.ant.Target.performTasks(Target.java:385)
>   at org.apache.tools.ant.Project.executeSortedTargets(Project.java: 
> 1337)
>   at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>   at  
> org 
> .apache 
> .tools 
> .ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>   at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>   at org.apache.tools.ant.Main.runBuild(Main.java:758)
>   at org.apache.tools.ant.Main.startAnt(Main.java:217)
>   at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>   at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>
>   at  
> org 
> .apache 
> .velocity 
> .runtime 
> .resource 
> .loader.ResourceLoaderFactory.getLoader(ResourceLoaderFactory.java:56)
>   at  
> org 
> .apache 
> .velocity 
> .runtime 
> .resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:142)
>   at  
> org 
> .apache 
> .velocity 
> .runtime 
> .RuntimeInstance.initializeResourceManager(RuntimeInstance.java:522)
>   at  
> org 
> .apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java: 
> 227)
>   at  
> org 
> .apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java: 
> 461)
>   at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java: 
> 106)
>   at  
> org 
> .apache 
> .cayenne 
> .gen.ClassGenerationAction.getTemplate(ClassGenerationAction.java:273)
>   at  
> org 
> .apache 
> .cayenne 
> .gen.ClassGenerationAction.execute(ClassGenerationAction.java:241)
>   at  
> org 
> .apache 
> .cayenne 
> .gen.ClassGenerationAction.execute(ClassGenerationAction.java:213)
>   at  
> org 
> .apache 
> .cayenne 
> .tools.CayenneGeneratorTask.execute(CayenneGeneratorTask.java:163)
>   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java: 
> 288)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at  
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>   at  
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:25)
>   at java.lang.reflect.Method.invoke(Method.java:597)
>   at  
> org 
> .apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java: 
> 106)
>   at org.apache.tools.ant.Task.perform(Task.java:348)
>   at org.apache.tools.ant.Target.execute(Target.java:357)
>   at org.apache.tools.ant.Target.performTasks(Target.java:385)
>   at org.apache.tools.ant.Project.executeSortedTargets(Project.java: 
> 1337)
>   at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>   at  
> org 
> .apache 
> .tools 
> .ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>   at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>   at org.apache.tools.ant.Main.runBuild(Main.java:758)
>   at org.apache.tools.ant.Main.startAnt(Main.java:217)
>   at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>   at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>
> Total time: 0 seconds
> Andrus Adamchik wrote:
>> Yeah, in 3.0 you also need a VPP library (we should put it in lib/ 
>> third-party I guess...). Anyways, you can get it from here:
>>
>> http://sourceforge.net/projects/vpp
>>
>> Andrus
>>
>> On May 25, 2009, at 12:44 PM, Joseph Wamicha wrote:
>>
>>> I'm now trying with Cayenne 3.0M5. Please find the error logs below:
>>>
>>> sysadmin@astrodon:/mnt/sda3/EclipseWork/testpersistence$ ant -v  
>>> classgen
>>> Apache Ant version 1.7.1 compiled on November 10 2008
>>> Buildfile: build.xml
>>> Detected Java version: 1.6 in: /usr/lib/jvm/java-6-sun-1.6.0.13/jre
>>> Detected OS: Linux
>>> parsing buildfile /mnt/sda3/EclipseWork/testpersistence/build.xml  
>>> with URI = file:/mnt/sda3/EclipseWork/testpersistence/build.xml
>>> Project base dir set to: /mnt/sda3/EclipseWork/testpersistence
>>> [antlib:org.apache.tools.ant] Could not load definitions from  
>>> resource org/apache/tools/ant/antlib.xml. It could not be found.
>>> parsing buildfile jar:file:/mnt/sda3/EclipseWork/testpersistence/ 
>>> lib/cayenne-server-3.0M5.jar!/org/apache/cayenne/tools/antlib.xml  
>>> with URI = jar:file:/mnt/sda3/EclipseWork/testpersistence/lib/ 
>>> cayenne-server-3.0M5.jar!/org/apache/cayenne/tools/antlib.xml
>>> Build sequence for target(s) `classgen' is [classgen]
>>> Complete build sequence is [classgen, prepare, clean, deploy,  
>>> hsqldbgen, build, dist, ]
>>>
>>> classgen:
>>>
>>> BUILD FAILED
>>> java.lang.NoClassDefFoundError: foundrylogic/vpp/VPPConfig
>>>  at  
>>> org 
>>> .apache 
>>> .cayenne 
>>> .tools 
>>> .CayenneGeneratorTask 
>>> .initializeVppConfig(CayenneGeneratorTask.java:326)
>>>  at  
>>> org 
>>> .apache 
>>> .cayenne 
>>> .tools 
>>> .CayenneGeneratorTask.getVppContext(CayenneGeneratorTask.java:76)
>>>  at  
>>> org 
>>> .apache 
>>> .cayenne 
>>> .tools 
>>> .CayenneGeneratorTask 
>>> .createGeneratorAction(CayenneGeneratorTask.java:91)
>>>  at  
>>> org 
>>> .apache 
>>> .cayenne 
>>> .tools.CayenneGeneratorTask.execute(CayenneGeneratorTask.java:156)
>>>  at  
>>> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
>>>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>  at  
>>> sun 
>>> .reflect 
>>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>  at  
>>> sun 
>>> .reflect 
>>> .DelegatingMethodAccessorImpl 
>>> .invoke(DelegatingMethodAccessorImpl.java:25)
>>>  at java.lang.reflect.Method.invoke(Method.java:597)
>>>  at  
>>> org 
>>> .apache 
>>> .tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>>>  at org.apache.tools.ant.Task.perform(Task.java:348)
>>>  at org.apache.tools.ant.Target.execute(Target.java:357)
>>>  at org.apache.tools.ant.Target.performTasks(Target.java:385)
>>>  at org.apache.tools.ant.Project.executeSortedTargets(Project.java: 
>>> 1337)
>>>  at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>>>  at  
>>> org 
>>> .apache 
>>> .tools 
>>> .ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>>>  at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>>>  at org.apache.tools.ant.Main.runBuild(Main.java:758)
>>>  at org.apache.tools.ant.Main.startAnt(Main.java:217)
>>>  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>>>  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>>> Caused by: java.lang.ClassNotFoundException:  
>>> foundrylogic.vpp.VPPConfig
>>>  at  
>>> org 
>>> .apache 
>>> .tools 
>>> .ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1400)
>>>  at  
>>> org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java: 
>>> 1341)
>>>  at  
>>> org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java: 
>>> 1088)
>>>  at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>>>  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>>>  ... 21 more
>>>
>>> Total time: 0 seconds
>>>
>>> Thanks,
>>> Joseph.
>>>
>>> Andrus Adamchik wrote:
>>>> The stack shows that ClassGenerator class is present, while  
>>>> ClassGeneratorResourceLoader is not. Both are coming from the  
>>>> same JAR. Very strange... Could you possibly try the same thing  
>>>> with Cayenne 3.0M5?
>>>>
>>>> Also you can debug it with "ant -v" to see what the  
>>>> "full.classpath" is set to (maybe there's a conflicting Velocity  
>>>> installation or something).
>>>>
>>>> Andrus
>>>>
>>>>
>>>> On May 25, 2009, at 11:55 AM, Joseph Wamicha wrote:
>>>>
>>>>> Hi Andrus,
>>>>>
>>>>> Thanks for your response. The version is: cayenne-2.0.4
>>>>>
>>>>> Andrus Adamchik wrote:
>>>>>> Hi Joseph,
>>>>>>
>>>>>> which version of Cayenne is that?
>>>>>>
>>>>>> Andrus
>>>>>>
>>>>>>
>>>>>> On May 25, 2009, at 11:21 AM, Joseph Wamicha wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm currently experimenting with cayenne; it's looking good.
>>>>>>>
>>>>>>> I have however run into problems while running the ant cgen 

>>>>>>> task. I'm not sure what's going wrong with ant cgen. I would
 
>>>>>>> be grateful for any help on this. Please see my ant task below:
>>>>>>>
>>>>>>> <path id="full.classpath">
>>>>>>>   <fileset dir="lib" />
>>>>>>> </path>
>>>>>>> <!-- Custom apache cayenne ant tasks...-->
>>>>>>> <typedef resource="org/apache/cayenne/tools/antlib.xml">
>>>>>>>  <classpath refid="full.classpath"/>
>>>>>>> </typedef>
>>>>>>> <target name="classgen">
>>>>>>> <cgen map="src/PersistenceMap.map.xml" destDir="test"
>>>>>>>   usepkgpath="true" superpkg="com.plugin.persistence" />
>>>>>>> </target>
>>>>>>>
>>>>>>> and inside my lib directory I have the cayenne.jar file
>>>>>>>
>>>>>>> When I now run ant classgen, I get the following error:
>>>>>>>
>>>>>>> sysadmin@astrodon$ ant classgen
>>>>>>> Buildfile: build.xml
>>>>>>>
>>>>>>> classgen:
>>>>>>> [cgen] Error generating classes: Problem initializing template
 
>>>>>>> loader: org.apache.cayenne.gen.ClassGeneratorResourceLoader
>>>>>>> [cgen] Error is: java.lang.ClassNotFoundException:  
>>>>>>> org.apache.cayenne.gen.ClassGeneratorResourceLoader
>>>>>>> [cgen]     at java.net.URLClassLoader 
>>>>>>> $1.run(URLClassLoader.java:200)
>>>>>>> [cgen]     at  
>>>>>>> java.security.AccessController.doPrivileged(Native Method)
>>>>>>> [cgen]     at  
>>>>>>> java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>>>> [cgen]     at java.lang.ClassLoader.loadClass(ClassLoader.java:

>>>>>>> 307)
>>>>>>> [cgen]     at java.lang.ClassLoader.loadClass(ClassLoader.java:

>>>>>>> 252)
>>>>>>> [cgen]     at  
>>>>>>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>>>>>>> [cgen]     at java.lang.Class.forName0(Native Method)
>>>>>>> [cgen]     at java.lang.Class.forName(Class.java:169)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .velocity 
>>>>>>> .runtime 
>>>>>>> .resource 
>>>>>>> .loader 
>>>>>>> .ResourceLoaderFactory.getLoader(ResourceLoaderFactory.java:41)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .velocity 
>>>>>>> .runtime 
>>>>>>> .resource 
>>>>>>> .ResourceManagerImpl.initialize(ResourceManagerImpl.java:142)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .velocity 
>>>>>>> .runtime 
>>>>>>> .RuntimeInstance 
>>>>>>> .initializeResourceManager(RuntimeInstance.java:522)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:227)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:461)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache.velocity.app.VelocityEngine.init(VelocityEngine.java:

>>>>>>> 106)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .cayenne 
>>>>>>> .gen 
>>>>>>> .ClassGenerator.initializeClassTemplate(ClassGenerator.java:149)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache.cayenne.gen.ClassGenerator.<init>(ClassGenerator.java:

>>>>>>> 94)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .cayenne 
>>>>>>> .gen 
>>>>>>> .MapClassGenerator 
>>>>>>> .generateClassPairs_1_1(MapClassGenerator.java:222)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .cayenne 
>>>>>>> .gen 
>>>>>>> .MapClassGenerator.generateClassPairs(MapClassGenerator.java:

>>>>>>> 199)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .cayenne 
>>>>>>> .gen.DefaultClassGenerator.execute(DefaultClassGenerator.java:

>>>>>>> 98)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .cayenne 
>>>>>>> .tools.CayenneGenerator.processMap(CayenneGenerator.java:144)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .cayenne.tools.CayenneGenerator.execute(CayenneGenerator.java:

>>>>>>> 80)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache.tools.ant.UnknownElement.execute(UnknownElement.java:

>>>>>>> 288)
>>>>>>> [cgen]     at  
>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>> [cgen]     at  
>>>>>>> sun 
>>>>>>> .reflect 
>>>>>>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:

>>>>>>> 39)
>>>>>>> [cgen]     at  
>>>>>>> sun 
>>>>>>> .reflect 
>>>>>>> .DelegatingMethodAccessorImpl 
>>>>>>> .invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>>> [cgen]     at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:

>>>>>>> 106)
>>>>>>> [cgen]     at org.apache.tools.ant.Task.perform(Task.java:348)
>>>>>>> [cgen]     at org.apache.tools.ant.Target.execute(Target.java:

>>>>>>> 357)
>>>>>>> [cgen]     at  
>>>>>>> org.apache.tools.ant.Target.performTasks(Target.java:385)
>>>>>>> [cgen]     at  
>>>>>>> org.apache.tools.ant.Project.executeSortedTargets(Project.java:

>>>>>>> 1337)
>>>>>>> [cgen]     at  
>>>>>>> org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>>>>>>> [cgen]     at  
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .tools 
>>>>>>> .ant 
>>>>>>> .helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>>>>>>> [cgen]     at  
>>>>>>> org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>>>>>>> [cgen]     at org.apache.tools.ant.Main.runBuild(Main.java:758)
>>>>>>> [cgen]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
>>>>>>> [cgen]     at  
>>>>>>> org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>>>>>>> [cgen]     at  
>>>>>>> org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>>>>>>>
>>>>>>> BUILD FAILED
>>>>>>>
>>>>>>> What could be going wrong?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Joseph.
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>


Mime
View raw message