sbt / sbt-xjc

SBT plugin to compile an XML Schema with XJC
Other
15 stars 14 forks source link

'file' access is not allowed due to restriction set by the accessExternalDTD property #31

Closed mirelon closed 4 years ago

mirelon commented 4 years ago

Using version 0.10, I get an error when parsing a XJB file:

[ERROR] External Entity: Failed to read external document ***, because 'file' access is not allowed due to restriction set by the accessExternalDTD property.

I have tried solutions from https://stackoverflow.com/questions/23011547/webservice-client-generation-error-with-jdk8, but the error still shows up.

I have also tried adding

xjcJvmOpts += "-Djavax.xml.accessExternalDTD=all"
xjcJvmOpts += "-Djavax.xml.accessExternalSchema=all"

to build.sbt

mirelon commented 4 years ago

Not sure which step helped, but this was the solution:


val `collection-setter-injector` = "net.java.dev.vcc.thirdparty" % "collection-setter-injector" % "0.5.0-1"

val `jaxb2-basics` = "org.jvnet.jaxb2_commons" % "jaxb2-basics" % "0.9.4"

val `jaxb2-basics-annotate` = "org.jvnet.jaxb2_commons" % "jaxb2-basics-annotate" % "1.0.1"

val `jaxb2-default-value` = "org.jvnet.jaxb2_commons" % "jaxb2-default-value" % "1.1"

val `jaxb2-namespace-prefix` = "org.jvnet.jaxb2_commons" % "jaxb2-namespace-prefix" % "1.1"

val `jaxb2-commons-lang` = "org.jvnet.jaxb2_commons" % "jaxb2-commons-lang" % "2.3"

val `jaxb-xjc` = "org.glassfish.jaxb" % "jaxb-xjc" % "2.2.10"

val `jaxb-impl` = "com.sun.xml.bind" % "jaxb-impl" % "2.2.10"

xjcPlugins := Seq(
  `collection-setter-injector`,
  `jaxb2-basics`,
  `jaxb2-basics-annotate`,
  `jaxb2-default-value`,
  `jaxb2-namespace-prefix`,
  `jaxb2-commons-lang`
)

xjcLibs := Seq(
  `jaxb-xjc`,
  `jaxb-impl`
)

xjcJvmOpts := Seq(
  "-Djavax.xml.accessExternalSchema=all",
  "-Djavax.xml.accessExternalDTD=all"
)

xjcCommandLine := Seq(
  "-Xcollection-setter-injector",
  "-Xinheritance",
  "-Xinject-code",
  "-Xnamespace-prefix",
  "-Xdefault-value",
  "-Xannotate",
  "-extension",
  "-encoding", "utf-8",
  "-verbose"
)