JAXB: Nested Type hides an Enclosing Type.

C

chicagoandy

I'm having a problem where I'm getting compile errors on files
generated by Jaxb.

One of my Type Interfaces and TypeImpl classes are generating an error:
"Nested Type XXX hides an Enclosing Type."

First, I'm not terribly sure I understand what this means.

Second, Why won't generated classes compile?

Any pointers appreciated,

_Am
 
I

iksrazal

I'm having a problem where I'm getting compile errors on files
generated by Jaxb.

One of my Type Interfaces and TypeImpl classes are generating an error:
"Nested Type XXX hides an Enclosing Type."

First, I'm not terribly sure I understand what this means.

Second, Why won't generated classes compile?

Any pointers appreciated,

_Am

The only time I've ever got compile errors with JAXB - and I don't
remember the stacktrace - was when something got generated like:

statement;;

With two semi-colons. You didn't show the line it complained about,
but in my case I just edited the extra semi-colon and it compiled. Its
pretty amazing what jaxb does considering its based on a complex
schema spec, but there is a small wart here and there from what I've
seen.

You also don't say if you have successfully compiled JAXB generated
classes before. I use ant myself. There's a couple jaxb articles on
onjava.com if youŕe just starting.

iksrazal
http://www.braziloutsource.com/
 
C

chicagoandy

Thanks for the tip, but that didn't help.

I did try using ANT, and the results are the same.

On line 8, I get eaweb.jaxb.DataSetType.DataSetType cannot be resolved
or is not a valid superinterface
On line 15, I get Nested Type DataSetType hides an Enclosing Type.

I've included the schema below.

Here's the class:

1 package eaweb.jaxb;
2
3
4
5 public interface DataSetType {
6
7 java.util.List getDataSet();
8 public interface DataSet extends javax.xml.bind.Element,
eaweb.jaxb.DataSetType.DataSetType
10 {
11
12 }
13
14
15 public interface DataSetType {
16
17 java.lang.String getDOCTYPE();
18 void setDOCTYPE(java.lang.String value);
19 int getVSDOCID();
20 void setVSDOCID(int value);
21 short getVSVULEV();
22 void setVSVULEV(short value);
23 int getVSPARENT();
24 void setVSPARENT(int value);
25 java.lang.String getDOCTIME();
26 void setDOCTIME(java.lang.String value);
27 java.lang.String getLPART();
28 void setLPART(java.lang.String value);
29 short getVSLINK();
30 void setVSLINK(short value);
31 short getVSUPDLEV();
32 void setVSUPDLEV(short value);
33 short getVSDEL();
34 void setVSDEL(short value);
35 short getVSARCH();
36 void setVSARCH(short value);
37 java.lang.String getDOCDESC();
38 void setDOCDESC(java.lang.String value);
39 java.lang.String getDOCDATE();
40 void setDOCDATE(java.lang.String value);
41 int getVSPTABLE();
42 void setVSPTABLE(int value);
43 short getVSBRWSLEV();
44 void setVSBRWSLEV(short value);
45 int getVSABSID();
46 void setVSABSID(int value);
47 java.lang.String getUSERID();
48 void setUSERID(java.lang.String value);
49 java.lang.String getSECURE();
50 void setSECURE(java.lang.String value);
51 int getEMPNUM();
52 void setEMPNUM(int value);
53 int getVSFORM();
54 void setVSFORM(int value);
55 java.lang.String getSSNUM();
56 void setSSNUM(java.lang.String value);
57 java.lang.String getAREA();
58 void setAREA(java.lang.String value);
59 java.lang.String getVSQRN();
60 void setVSQRN(java.lang.String value);
61 int getVSEXPAND();
62 void setVSEXPAND(int value);
63
64 }
65
66 }

Here's the schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" id="DataSet"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element msdata:IsDataSet="true" msprop:Type=""
msprop:DBName="DataSet" msprop:ServerName="Server1" name="DataSet">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="DataSet">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="VS_DOCID" type="xs:int"
/>
<xs:element minOccurs="0" name="VS_EXPAND" type="xs:int"
/>
<xs:element minOccurs="0" name="VS_PARENT" type="xs:int"
/>
<xs:element minOccurs="0" name="VS_PTABLE" type="xs:int"
/>
<xs:element minOccurs="0" name="VS_FORM" type="xs:int" />
<xs:element minOccurs="0" name="VS_ABSID" type="xs:int"
/>
<xs:element minOccurs="0" name="VS_BRWSLEV"
type="xs:short" />
<xs:element minOccurs="0" name="VS_UPDLEV"
type="xs:short" />
<xs:element minOccurs="0" name="VS_VULEV" type="xs:short"
/>
<xs:element minOccurs="0" name="VS_DEL" type="xs:short"
/>
<xs:element minOccurs="0" name="VS_LINK" type="xs:short"
/>
<xs:element minOccurs="0" name="VS_ARCH" type="xs:short"
/>
<xs:element minOccurs="0" name="VS_QRN" type="xs:string"
/>
<xs:element minOccurs="0" name="SSNUM" type="xs:string"
/>
<xs:element minOccurs="0" name="EMPNUM" type="xs:int" />
<xs:element minOccurs="0" name="DOCDATE" type="xs:string"
/>
<xs:element minOccurs="0" name="DOCTIME" type="xs:string"
/>
<xs:element minOccurs="0" name="DOCTYPE" type="xs:string"
/>
<xs:element minOccurs="0" name="DOCDESC" type="xs:string"
/>
<xs:element minOccurs="0" name="AREA" type="xs:string" />
<xs:element minOccurs="0" name="USERID" type="xs:string"
/>
<xs:element minOccurs="0" name="SECURE" type="xs:string"
/>
<xs:element minOccurs="0" name="LPART" type="xs:string"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
 
I

iksrazal

Thanks for the tip, but that didn't help.

I did try using ANT, and the results are the same.

On line 8, I get eaweb.jaxb.DataSetType.DataSetType cannot be resolved
or is not a valid superinterface
On line 15, I get Nested Type DataSetType hides an Enclosing Type.

I've included the schema below.

<snip>

Since JAXB is one of my favorite technologies, I imported your schema
into my environment and found the problem. I got a few tips for you
.... more below.

The problem is a naming conflict - DataSet is a reserved name. I
changed the Schema and it worked:

<xs:element msdata:IsDataSet="true" msprop:Type=""
msprop:DBName="DataSetMS" msprop:ServerName="Server1" name="DataSet">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="DataSetMS">

The error I got was less cryptic I think - it lead to the JAXB FAQ:

http://java.sun.com/xml/jaxb/faq.html

[echo] Compiling JAXB generated classes from XML schemas
[javac] Compiling 340 source files to
/home/crissilva/dump/code/jax_play/build/classes
[javac] /home/crissilva/dump/code/jax_play/src/java/gov/infoseg/mr/xtrans/schemas/google_help/DataSetType.java:173:
gov.infoseg.mr.xtrans.schemas.google_help.DataSetType is already
defined ingov.infoseg.mr.xtrans.schemas.google_help
[javac] public interface DataSetType {
[javac] ^
[javac] /home/crissilva/dump/code/jax_play/src/java/gov/infoseg/mr/xtrans/schemas/google_help/impl/DataSetTypeImpl.java:513:
gov.infoseg.mr.xtrans.schemas.google_help.impl.DataSetTypeImpl is
already defined in gov.infoseg.mr.xtrans.schemas.google_help.impl
[javac] public static class DataSetTypeImpl implements
gov.infoseg.mr.xtrans.schemas.google_help.DataSetType.DataSetType,
com.sun.xml.bind.JAXBObject,
gov.infoseg.mr.xtrans.schemas.google_help.impl.runtime.UnmarshallableObject,
gov.infoseg.mr.xtrans.schemas.google_help.impl.runtime.XMLSerializable,
gov.infoseg.mr.xtrans.schemas.google_help.impl.runtime.ValidatableObject
[javac] ^
[javac] 2 errors

My tip for you - where I got this error - was for my ant task
'jaxb-jar' , which takes the classes and puts them into jars, which I
have found avoids a lot of little problems.

<target name="jaxb-jar" depends="schemas">
<mkdir dir="${dist.dest}" />
<jar jarfile="${build.lib.thirdparty}/google_help.jar">
<fileset dir="${build.dest.classes}"
includes="gov/infoseg/mr/xtrans/schemas/google_help/**/*" />
</jar>

<target>

target 'schemas' just does the schema to class conversion. I might be
able to create a simple ant build if you get stuck.

HTH,
iksrazal
http://www.braziloutsource.com/
 
C

chicagoandy

I'm stuck.

After changing the element names, I still get the same errors.

Perhaps I should mention that I'm using Eclipse, and the errors I'm
describing are being presented through the Eclipse GUI.

I did try your suggestion of using the jaxb-jar target, and strangely
that worked fine for me without generating errors - both with the old
and the new element names. It even built the JAR.

<target name="jaxb-jar" depends="jaxb">
<mkdir dir="${dist.dest}" />
<jar jarfile="${basedir}/lib/myNewJarFile.jar">
<fileset dir="${basedir}/src" includes="eaweb/jaxb/**/*" />
</jar>
</target>
 
I

iksrazal

I'm stuck.

After changing the element names, I still get the same errors.

Perhaps I should mention that I'm using Eclipse, and the errors I'm
describing are being presented through the Eclipse GUI.

I did try your suggestion of using the jaxb-jar target, and strangely
that worked fine for me without generating errors - both with the old
and the new element names. It even built the JAR.

<target name="jaxb-jar" depends="jaxb">
<mkdir dir="${dist.dest}" />
<jar jarfile="${basedir}/lib/myNewJarFile.jar">
<fileset dir="${basedir}/src" includes="eaweb/jaxb/**/*" />
</jar>
</target>

You're stuck but you're classes compile? Does your code work with the
jar? I use ant inside eclipse via the built-in plugin. Worth
considering. Its great for passing code to other GUI's. If for some
non-technical reason you need to use the straight eclipse GUI - you
could use the eclipse ant task just to generate the jar.

iksrazal
http://www.braziloutsource.com/
 
C

chicagoandy

No, it didn't work... Even though the jar's build I'm getting
'ClassNotFound' exceptions in the same classes that were generating
errors through the Eclipse GUI.

I think I've spent too much of my time trying to get this work, and
I'll just move on and try a different solution. Thanks for your
help...

_Am
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top