XMLBeans - gerando java do schema

5 respostas
L

Pessoal… preciso de uma ajuda com o XMLBeans.

Quero gerar o .java a partir do schema, mas acontece isso:

C:\XMLParser>scomp BookStore.xsd

Time to build schema type system: 1.39 seconds

Time to generate code: 0.141 seconds

java.io.IOException: CreateProcess: C:\XMLParser\javac @C:\DOCUME~1\Usuario\CONFIG~1\Temp\javac15296 error=2

null

java.io.IOException: CreateProcess: C:\XMLParser\javac @C:\DOCUME~1\Usuario\CONFIG~1\Temp\javac15296 error=2

at java.lang.ProcessImpl.create(Native Method)

at java.lang.ProcessImpl.(Unknown Source)

at java.lang.ProcessImpl.start(Unknown Source)

at java.lang.ProcessBuilder.start(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at org.apache.xmlbeans.impl.tool.CodeGenUtil.externalCompile(CodeGenUtil.java:231)

at org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.java:1126)

at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:368)

BUILD FAILED

Mesmo assim, vejo que ele cria os .java.

Criei a classe Validate, que só tem um main contendo o seguinte:

String path = “C:\XMLParser\BookStore.xml”;
BookStoreDocument bookStore = (BookStoreDocument) parseXml(path, null);

Mas, na chamada do parser acima, acontece isso:

Exception in thread “main” java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlAnyTypeImpl
at Validate.main(Validate.java:24)

Alguém pode ajudar?? Obrigado!

5 Respostas

C

O jdk\bin está configurado no seu path ? (se vc digita no console: javac o que parece ?)
E qual o conteudo do metodo parseXml ?

L

Descobri o problema… ele tava procurando o javac no diretório do JRE, e não no JDK… se alguém tiver o mesmo problema, aqui está o que fazer:

[i]On Windows, some users have reported that the scomp program fails when trying to run javac on the generated java source. First, be sure you have a JDK installed. The JRE doesn’t have the javac program so you won’t be able to compile the generated java source. If you have both a JDK and a JRE installed, the JRE’s java is being found before the JDK’s java. Since scomp uses the ‘java.home’ property to find the javac program, but javac is only available in the JDK, finding javac will fail.

The solution is to move the JDK higher up on the PATH in the environment. An alternate solution is to set JAVA_HOME and edit the scomp script to run %JAVA_HOME%\bin\java instead of relying on the PATH. [/i]

Fonte: http://wiki.apache.org/xmlbeans/XmlBeansFaq#scompFindingJavac

danieldestro

Com que finalidade você está usando os beans gerados com o XML Beans?

louds

Provalmente a mesma finalidade que todo mundo, consumir e produzir documentos XML definidos pelo schema em questão.

danieldestro

Certo… mas o meu caso é este aqui: http://www.guj.com.br/posts/list/0/33914.java
Por isso acho que eu não preciso desta coisa.

Criado 21 de maio de 2006
Ultima resposta 29 de mai. de 2006
Respostas 5
Participantes 4