Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARNING: Unable to get @MinOccurs annotation from type com.sun.xml.bind.v2.model.impl.TypeRefImpl@667de82c #23

Closed
maprohu opened this issue Jan 9, 2015 · 1 comment

Comments

@maprohu
Copy link

maprohu commented Jan 9, 2015

Hello,

I am using the jaxb2-maven-plugin to generate XML Schema from annotated Java classes. Everything seems to work fine so far, except that I get tons of warnings in the Maven logs during the build.

The Java class:

package jaxb.factets.sandbox;

import javax.xml.bind.annotation.Facets;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

@XmlType(namespace="jaxb-sandbox")
@XmlAccessorType(XmlAccessType.FIELD)
public class Boo {

    @Facets(minInclusive="100")
    int someNumber;

}

The pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>jaxb-facets</groupId>
    <artifactId>jaxb-facets-sandbox</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>7</source>
                    <target>7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.2.6-facets-1.3.0</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.2.7-facets-1.0.5</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>2.2.6</version>
                        <exclusions>
                            <exclusion>
                                <groupId>javax.xml.bind</groupId>
                                <artifactId>jaxb-api</artifactId>
                            </exclusion>
                            <exclusion>
                                <groupId>com.sun.xml.bind</groupId>
                                <artifactId>jaxb-impl</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>schemagen</id>
                        <goals>
                            <goal>schemagen</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.7-facets-1.0.5</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>github-repo-releases</id>
            <url>https://raw.github.com/whummer/jaxb-facets/master/releases</url>
        </repository>
    </repositories>

</project>

The output log:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building jaxb-facets-sandbox 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jaxb-facets-sandbox ---
[INFO] 
[INFO] --- jaxb2-maven-plugin:1.6:schemagen (schemagen) @ jaxb-facets-sandbox ---
Jan 09, 2015 5:34:12 PM at.ac.tuwien.infosys.jaxb.XmlSchemaEnhancer writeCustomOccurs
WARNING: Unable to get @MinOccurs annotation from type com.sun.xml.bind.v2.model.impl.TypeRefImpl@667de82c
java.lang.ClassCastException: com.sun.tools.javac.code.Type$ClassType cannot be cast to java.lang.Class
    at at.ac.tuwien.infosys.jaxb.XmlSchemaEnhancer.getAnnotationOfProperty(XmlSchemaEnhancer.java:908)
    at at.ac.tuwien.infosys.jaxb.XmlSchemaEnhancer.writeCustomOccurs(XmlSchemaEnhancer.java:466)
    at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace$2.write(XmlSchemaGenerator.java:1178)
    at com.sun.xml.bind.v2.schemagen.TreeWrapper.write(TreeWrapper.java:90)
    at com.sun.xml.bind.v2.schemagen.Tree$Group.write(Tree.java:255)
    at com.sun.xml.bind.v2.schemagen.Tree.write(Tree.java:138)
    at com.sun.xml.bind.v2.schemagen.Tree.write(Tree.java:141)
    at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeClass(XmlSchemaGenerator.java:1039)
    at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:721)
    at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$800(XmlSchemaGenerator.java:519)
    at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:501)
    at com.sun.tools.xjc.api.impl.j2s.JAXBModelImpl.generateSchema(JAXBModelImpl.java:183)
    at com.sun.tools.jxc.ap.SchemaGenerator.process(SchemaGenerator.java:115)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
    at com.sun.tools.jxc.SchemaGenerator$Runner.compile(SchemaGenerator.java:240)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.tools.jxc.SchemaGenerator.run(SchemaGenerator.java:171)
    at com.sun.tools.jxc.SchemaGenerator.run(SchemaGenerator.java:86)
    at org.codehaus.mojo.jaxb2.AbstractSchemagenMojo.execute(AbstractSchemagenMojo.java:215)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxb-facets-sandbox ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jaxb-facets-sandbox ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\dev\grails\ws\jaxb-facets-sandbox\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxb-facets-sandbox ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ jaxb-facets-sandbox ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jaxb-facets-sandbox ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ jaxb-facets-sandbox ---
[INFO] Building jar: D:\dev\grails\ws\jaxb-facets-sandbox\target\jaxb-facets-sandbox-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ jaxb-facets-sandbox ---
[INFO] Installing D:\dev\grails\ws\jaxb-facets-sandbox\target\jaxb-facets-sandbox-0.0.1-SNAPSHOT.jar to C:\Users\pappmar\.m2\repository\jaxb-facets\jaxb-facets-sandbox\0.0.1-SNAPSHOT\jaxb-facets-sandbox-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\dev\grails\ws\jaxb-facets-sandbox\pom.xml to C:\Users\pappmar\.m2\repository\jaxb-facets\jaxb-facets-sandbox\0.0.1-SNAPSHOT\jaxb-facets-sandbox-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.218 s
[INFO] Finished at: 2015-01-09T17:34:13+00:00
[INFO] Final Memory: 20M/226M
[INFO] ------------------------------------------------------------------------

The number of log messages depends on the number of domain classes.

The generated XML schema is fine:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="jaxb-sandbox" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:complexType name="boo">
    <xs:sequence>
      <xs:element name="someNumber">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="100"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

It is not a blocking issue, I would just like to get rid of the warnings in the build logs. Is that possible?

Regards,
Marton

@whummer
Copy link
Owner

whummer commented Jan 16, 2015

Thanks for reporting. Fixed in commit 9b83ec4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants