Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jaxb.properties missing at runtime when built with Maven

Tags:

java

maven

jaxb

I have a project where I want to work with a set of Classes generated by JAXB from an XSD. With these classes I would like to marshall/unmarshall from XML and JSON.

I've figured out I would need Moxy Eclipselink to do what I need. I tested my classes and process as an Ant project, then I decided to move it over to Maven for better management.

However, the jaxb.properties file does not seem to be recognized at runtime.

My project has a Maven artifact for the objects, and another artifact for the logic/processing. I've been pulling my hair out trying to figure out where to put the jaxb.properties so it could be read.

I have tried

Objects Project

/src/main/resources/jaxb.properties
/src/main/java/[namespace]/jaxb.properties

Logic Project

/src/main/resources/jaxb.properties
/src/main/java/[namespace]/jaxb.properties

However, when I try to get the classname of my JAXBContext I still get:

class com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl

If I modify my run settings by specifying a JVM option of:

-Djavax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

I get:

class org.eclipse.persistence.jaxb.JAXBContext

In both projects I have specified this in the pom.xml

<build>
      <resources>
          <resource>
              <directory>src/main/resources</directory>
              <includes>
                  <include>**/*.properties</include>
              </includes>
          </resource>
      </resources>
</build>

If I look at the JAR, I see jaxb.properties in there.

Root of JAR Now I'm confused.

like image 475
Israel Lopez Avatar asked Sep 22 '13 14:09

Israel Lopez


1 Answers

Example, in maven the java class

 src\main\java\com\example\sitemap\generate\domain

and the file jaxb.properties

 src\main\resources\com\example\sitemap\generate\domain\jaxb.properties
like image 72
jhon_maldonado Avatar answered Oct 07 '22 12:10

jhon_maldonado