java - Moxy classpath issue -


i have implemented moxy classes in project. dont want moxy default existing classes. problem facing moxy being used other existing classes. how can avoid this?

i have made sure jaxb.properties in same package classes want used for, , there no other class in that. package structure this:

package :com.entity.a com.entity.b com.entity.c com.entity.d com.entity.d.moxy.

jaxb.properties present in com.entity.d.moxy , classes in com.entity.d.moxy should use it. classes picking moxy , causing exceptions.

could help?

the jaxbcontext returned come single provider. below demonstrate how provider determined example.

package #1 - forum17649220.foo

jaxb.properties

this package contains jaxb.properties file following entry indicating moxy jaxb provider (see: http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html).

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.jaxbcontextfactory 

foo

foo contains reference bar. means no matter how jaxbcontext created when foo processed metadata created bar.

package forum17649220.foo;  import forum17649220.bar.bar;  public class foo {      public bar bar;  } 

jaxb.index

jaxb implementations not package scanning. jaxb.index file can used enable creation of jaxbcontext package name.

foo 

package #2 - forum17649220.bar

bar

bar contains reference foo. means no matter how jaxbcontext created when bar processed metadata created foo.

package forum17649220.bar;  import forum17649220.foo.foo;  public class bar {      public foo foo;  } 

jaxb.index

bar 

demo code

we create instances of jaxbcontext few different ways see picked jaxb provider. note since foo , bar have references each other metadata both classes processed regardless of jaxb provider used.

demo

package forum17649220;  import javax.xml.bind.jaxbcontext; import forum17649220.bar.bar; import forum17649220.foo.foo;  public class demo {      public static void main(string[] args) throws exception {         system.out.println(jaxbcontext.newinstance("forum17649220.foo").getclass());         system.out.println(jaxbcontext.newinstance("forum17649220.foo:forum17649220.bar").getclass());         system.out.println(jaxbcontext.newinstance("forum17649220.bar").getclass());          system.out.println(jaxbcontext.newinstance(foo.class).getclass());         system.out.println(jaxbcontext.newinstance(foo.class, bar.class).getclass());         system.out.println(jaxbcontext.newinstance(bar.class).getclass());     }  } 

output

we can see input whenever forum17649220.foo package or class package included when creating jaxbcontext moxy provider because of jaxb.properties file.

class org.eclipse.persistence.jaxb.jaxbcontext class org.eclipse.persistence.jaxb.jaxbcontext class com.sun.xml.bind.v2.runtime.jaxbcontextimpl class org.eclipse.persistence.jaxb.jaxbcontext class org.eclipse.persistence.jaxb.jaxbcontext class com.sun.xml.bind.v2.runtime.jaxbcontextimpl 

Comments