Issue Details (XML | Word | Printable)

Key: CASTOR-2670
Type: Bug Bug
Status: Reopened Reopened
Priority: Critical Critical
Assignee: Werner Guttmann
Reporter: Thomas Dreyer
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
castor

Embedded error by generating classes with descriptor from XSDs.

Created: 09/Mar/09 05:29 AM   Updated: 31/Dec/09 01:27 PM
Component/s: XML code generator
Affects Version/s: 1.3
Fix Version/s: 1.3.2

Time Tracking:
Not Specified

File Attachments: 1. Text File patch.c2670.20090528.txt (1 kB)

Environment: Windows XP SP2, Maven 2.0.10
Issue Links:
Related
 


 Description  « Hide

Hi Werner,

I get an embedded error by generating from XSDs with descriptor.

The problem occur in DescriptorSourceFactory.createDiscriptor(...)
by calling on JClass the addMember(final JMember jMember) method.
Since this issue the method is called with the new JConstant class and
can not handle this.

Regards Thomas Dreyer

...
[INFO] ------------------------------------------------------------------------
[INFO] Building VK Backend: Value Objects
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [castor:generate {execution: Generating common VOs}]
[INFO] Processing D:\vk\main\backend\vo\xsd\dekanet\PersonAddress.xsd
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Castor execution failed

Embedded error: An Exception occurred processing D:\vk\main\backend\vo\xsd\dekanet\PersonAddress.xsd
Cannot add JMember 'org.exolab.javasource.JConstant' to JClass, unrecognized type.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Castor execution failed
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:584)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:500)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:479)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
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:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Castor execution failed
at org.codehaus.mojo.castor.GenerateMojo.execute(GenerateMojo.java:257)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:453)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
... 16 more
Caused by: org.apache.maven.plugin.MojoExecutionException: An Exception occurred processing D:\vk\main\backend\vo\xsd\dekanet\PersonAddress.xsd
at org.codehaus.mojo.castor.GenerateMojo.processFile(GenerateMojo.java:452)
at org.codehaus.mojo.castor.GenerateMojo.execute(GenerateMojo.java:239)
... 18 more
Caused by: java.lang.IllegalArgumentException: Cannot add JMember 'org.exolab.javasource.JConstant' to JClass, unrecognized type.
at org.exolab.javasource.JClass.addMember(JClass.java:114)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createDescriptor(DescriptorSourceFactory.java:380)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createSource(DescriptorSourceFactory.java:269)
at org.exolab.castor.builder.SingleClassGenerator.processClassDescriptor(SingleClassGenerator.java:397)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:376)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:314)
at org.exolab.castor.builder.SourceGenerator.createClasses(SourceGenerator.java:944)
at org.exolab.castor.builder.SourceGenerator.generateAllClassFiles(SourceGenerator.java:797)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:752)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:696)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:593)
at org.codehaus.mojo.castor.GenerateMojo.processFile(GenerateMojo.java:438)
... 19 more



Thomas Dreyer added a comment - 09/Mar/09 05:34 AM

This issue refer on CASTOR-2638 !


Thomas Dreyer added a comment - 10/Mar/09 08:13 AM

If you run the supplied codegen tests with the option
"org.exolab.castor.builder.classdescfieldnames=true"
the same exception occur:

-------------------------------------------------------------------------------
Test set: org.exolab.castor.builder.appInfo.AppInfoProcessingTest
-------------------------------------------------------------------------------
Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.109 sec <<< FAILURE!
testAppInfoProcessingWithSimpleSchema(org.exolab.castor.builder.appInfo.AppInfoProcessingTest) Time elapsed: 0.015 sec <<< ERROR!
java.lang.IllegalArgumentException: Cannot add JMember 'org.exolab.javasource.JConstant' to JClass, unrecognized type.
at org.exolab.javasource.JClass.addMember(JClass.java:114)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createDescriptor(DescriptorSourceFactory.java:381)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createSource(DescriptorSourceFactory.java:269)
at org.exolab.castor.builder.SingleClassGenerator.processClassDescriptor(SingleClassGenerator.java:397)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:376)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:314)
at org.exolab.castor.builder.SourceGenerator.createClasses(SourceGenerator.java:946)
at org.exolab.castor.builder.SourceGenerator.generateAllClassFiles(SourceGenerator.java:797)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:752)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:696)
at org.exolab.castor.builder.appInfo.AppInfoProcessingTest.testAppInfoProcessingWithSimpleSchema(AppInfoProcessingTest.java:82)


Werner Guttmann added a comment - 10/Mar/09 04:36 PM

Please checkout SVN trunk to get access to this new code.


Thomas Dreyer added a comment - 24/Mar/09 05:46 AM

Hi Werner,

now the JClass.addMember() method never runs in the first "else if" because both "JField" and "JConstant" extend from "AbstractJField".
And else, the "main.vm" velocity template needs a "CONSTANDS" block, equivalent to the "MEMBERS", to print out the constants.

Is it possible to configure one of the JUnit test generating with decriptors?

Regards Thomas Dreyer


Werner Guttmann added a comment - 24/Mar/09 07:50 AM

now the JClass.addMember() method never runs in the first "else if" because both "JField" and "JConstant" extend from "AbstractJField"

Sorry, but somehow I cannot follow you here. Mind rephrasing your observation ?

And else, the "main.vm" velocity template needs a "CONSTANDS" block, equivalent to the "MEMBERS", to print out the constants.

Yes, indeed <being slightly embarrassed>.

Is it possible to configure one of the JUnit test generating with decriptors?

Sorry, but again, what is it you wanted to achieve ?


Thomas Dreyer added a comment - 24/Mar/09 08:36 AM

If you run the codegen tests with "org.exolab.castor.builder.classdescfieldnames=true" you get the folowing ClassCastException.
If it is possible to run the tests with generating descriptors, this exception occurs at buildtime.

Regards Thomas

-------------------------------------------------------------------------------
Test set: org.exolab.castor.builder.appInfo.AppInfoProcessingTest
-------------------------------------------------------------------------------
Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.156 sec <<< FAILURE!
testAppInfoProcessingWithSimpleSchema(org.exolab.castor.builder.appInfo.AppInfoProcessingTest) Time elapsed: 0.047 sec <<< ERROR!
java.lang.ClassCastException: org.exolab.javasource.JConstant
at org.exolab.javasource.JClass.addMember(JClass.java:103)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createDescriptor(DescriptorSourceFactory.java:380)
at org.exolab.castor.builder.descriptors.DescriptorSourceFactory.createSource(DescriptorSourceFactory.java:269)
at org.exolab.castor.builder.SingleClassGenerator.processClassDescriptor(SingleClassGenerator.java:397)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:376)
at org.exolab.castor.builder.SingleClassGenerator.process(SingleClassGenerator.java:314)
at org.exolab.castor.builder.SourceGenerator.createClasses(SourceGenerator.java:946)
at org.exolab.castor.builder.SourceGenerator.generateAllClassFiles(SourceGenerator.java:797)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:752)
at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:696)
at org.exolab.castor.builder.appInfo.AppInfoProcessingTest.testAppInfoProcessingWithSimpleSchema(AppInfoProcessingTest.java:82)


Thomas Dreyer added a comment - 28/May/09 04:17 AM

Add patch