Caros,
Estou tendo problemas com XML Beans de um sistema legado e não sei o que fazer…vou tentar ser claro pois isso está me deixando muito irritado:
erro:
java.lang.AssertionError
at org.apache.xmlbeans.impl.values.XmlObjectBase.build_text(XmlObjectBase.java:868)
at org.apache.xmlbeans.impl.store.Xobj.ensureOccupancy(Xobj.java:1706)
at org.apache.xmlbeans.impl.store.Cur.next(Cur.java:1447)
at org.apache.xmlbeans.impl.store.Saver$FragSaveCur.next(Saver.java:4040)
at org.apache.xmlbeans.impl.store.Saver$PrettySaveCur.next(Saver.java:4232)
at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:326)
at org.apache.xmlbeans.impl.store.Saver.<init>(Saver.java:123)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.<init>(Saver.java:896)
at org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
at org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
at org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1486)
at org.apache.xmlbeans.impl.values.XmlObjectBase.toString(XmlObjectBase.java:1471)
at java.lang.String.valueOf(String.java:2827)
at java.io.PrintStream.println(PrintStream.java:771)
[b] restante suprimido[/b]
lógica maluca onde ocorre o erro:
public ClienteType getClientQuestionnaire(PedidoType order) {
log.debug("populateQuestionarioCliente start...");
ClienteType client = order.getCliente();
if (client.getListaQuestao() != null) {
client.unsetListaQuestao();
}
ListaQuestaoType questions = client.addNewListaQuestao();
HashMap<String, String> respostasAtuais = new HashMap<String, String>();
String naturezaCliente = null;
ResultSet rs = null;
Connection cn = null;
PreparedStatement ps = null;
try {
naturezaCliente = StringHelper.formatarNaturezaCodigo(client.getNatureza());
log.debug("##### Natureza: " + naturezaCliente + " - pedido: " + order.getDataPedido());
log.debug("pegando as respostas do questionário atual do cliente - begin");
cn = getConnection();
ps = cn.prepareStatement(QUERY_RESPOSTAS_ATUAIS_DO_CLIENTE);
ps.setLong(1, order.getCliente().getClienteMainID());
ps.setString(2, naturezaCliente);
ps.setString(3, order.getDataPedido());
ps.setString(4, order.getDataPedido());
rs = ps.executeQuery();
String chave = "";
String vaActualAnswer = "";
while (rs.next()) {
chave = rs.getString("idScoreQuestion") + "|" + rs.getString("idScoreQuestionAnswer");
vaActualAnswer = rs.getString("va_actual_answer");
respostasAtuais.put(chave, vaActualAnswer);
}
log.debug("pegando as respostas do questionário atual do cliente - end");
log.debug("carregando questionário - begin");
ps = cn.prepareStatement(QUERY_PERGUNTAS_RESPOSTAS_QUESTIONARIO);
ps.setString(1, naturezaCliente);
ps.setString(2, order.getDataPedido());
ps.setString(3, order.getDataPedido());
rs = ps.executeQuery();
int idScoreQuestion = 0;
int idScoreQuestionAtual = 0;
int idScoreQuestionnaire = 0;
QuestaoType questionType = null;
String keyResposta = "0";
while (rs.next()) {
idScoreQuestion = rs.getInt("idScoreQuestion");
if (idScoreQuestion != idScoreQuestionAtual) {
idScoreQuestionAtual = idScoreQuestion;
questionType = questions.addNewQuestao();
questionType.addNewListaResposta();
questionType.setResposta(0);
}
idScoreQuestionnaire = rs.getInt("idScoreQuestionnaire");
questionType.setDescricao(rs.getString("deScoreQuestion"));
questionType.setOrdem(rs.getInt("sqScoreQuestion"));
questionType.setQuestaoID(idScoreQuestion);
questionType.setQuestionarioID(idScoreQuestionnaire);
questionType.setFgAutomaticAnswer(rs.getString("fgAutomaticAnswer"));
questionType.setFgAnswerRequired(rs.getString("fgScoreQuestionRequired"));
questionType.setMask(rs.getString("deMaskStandard"));
keyResposta = rs.getString("idScoreQuestionAnswer").trim();
RespostaType answer = questionType.getListaResposta().addNewResposta();
answer.setDescricao(rs.getString("deScoreQuestionAnswer"));
answer.setOrdem(rs.getInt("sqScoreQuestionAnswer"));
answer.setRespostaID(Integer.parseInt(keyResposta));
answer.setValor(rs.getInt("vaScoreQuestionAnswer"));
answer.setVaInitialRange(rs.getString("vaInitialRange"));
answer.setVaEndRange(rs.getString("vaEndRange"));
/*
* se o hash das respostas atuais do cliente contém o key da
* resposta corrente, seta para deixar selecionado no combo da
* tela de crédito!
*/
chave = idScoreQuestion + "|" + keyResposta;
if (respostasAtuais.containsKey(chave)) {
questionType.setResposta(Integer.parseInt(keyResposta));
/*
* CREDIT LIMIT FASE II - populando outros dados de resposta
* do cliente
*/
questionType.setRespostaBase(respostasAtuais.get(chave) == null ? "" : respostasAtuais.get(chave).toString().trim());
}
System.out.println(questions);//utilizado para análise do erro: em um determinado momento, o erro é lançado...
}
log.debug("carregando questionário - end");
} catch (SQLException e) {
log.error(e);
throw new EJBException(e);
} finally {
close(cn, ps, rs);
}
log.debug("populateQuestionarioCliente end...");
return client;
}
mapeamento maluco:
xs:complexType name="ClienteType">
<xs:sequence>
<xs:element name="ClienteID" type="xs:long" />
<xs:element name="ClienteFamiliaID" type="xs:long">
<xs:annotation>
<xs:documentation>
id_customer_family (chave primaria)
(obrigatorio)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ClienteMainID" type="xs:long">
<xs:annotation>
<xs:documentation>
id_customer_main (foreign key) (obrigatorio)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ClienteContatoID" type="xs:long" />
<xs:element name="CodigoRazaoContato" type="xs:int" />
<xs:element name="DataHistorico" type="xs:string"
minOccurs="0" />
<xs:element name="Nome" type="xs:string" />
<xs:element name="DocumentoFiscal" type="xs:string" />
<xs:element name="Departamento" type="xs:string" />
<xs:element name="Cargo" type="xs:string" />
<xs:element name="CodigoCliente" type="xs:string" />
<xs:element name="Nivel" type="xs:string" />
<xs:element name="Telefone" type="xs:string" minOccurs="0" />
<xs:element name="Email" type="xs:string" minOccurs="0" />
<xs:element name="EnderecoFaturamento" type="EnderecoType"
minOccurs="0" />
<xs:element name="EnderecoCobranca" type="EnderecoType"
minOccurs="0" />
<xs:element name="ListaEnderecoEntrega"
type="ListaEnderecoType" minOccurs="0" />
<xs:element name="EnderecoEntregaId" type="xs:string">
<xs:annotation>
<xs:documentation>
ID unico para o endereco = Id_customer_address +
"|" + dt_history da tabela
tbgn_customer_address_h
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ListaQuestao" type="ListaQuestaoType"
minOccurs="0" />
<xs:element name="CargoSocio" type="CargoType" />
<xs:element name="ListaCargoSocio" type="ListaCargoType"
minOccurs="0" />
<xs:element name="ListaSocio" type="ListaSocioType"
minOccurs="0" />
<xs:element name="ListaReferenciaComercial"
type="ListaReferenciaComercialType" minOccurs="0" />
<xs:element name="NomeFantasia" type="xs:string" />
<xs:element name="PaymentResponsable" type="xs:string" />
<xs:element name="Mercado" type="xs:string" />
<xs:element name="Natureza" type="xs:string" />
<xs:element name="GroupIden" type="xs:string" />
<xs:element name="DocumentoEstadual" type="xs:string" />
<xs:element name="Segmento" type="xs:string" />
<xs:element name="SegmentoFgColor" type="xs:string" />
<xs:element name="SegmentoBgColor" type="xs:string" />
<xs:element name="Classificacao" type="xs:string" />
<xs:element name="ClassificacaoFgColor" type="xs:string" />
<xs:element name="ClassificacaoBgColor" type="xs:string" />
<xs:element name="Score" type="xs:string" />
<xs:element name="CodigoAntigo" type="xs:string" />
<xs:element name="RamoAtividade" type="xs:string" />
<xs:element name="TipoEmpresa" type="xs:string" />
<xs:element name="IndiceLoyalty" type="xs:string" />
<xs:element name="TipoEmpresaID" type="xs:int" />
<xs:element name="LimiteAtual" type="xs:double"/>
<xs:element name="CreditLimitChange" type="xs:double"/>
<xs:element name="LimitAvailable" type="xs:double"/>
<xs:element name="SaldoDisponivel" type="xs:double"/>
<xs:element name="DataLimite" type="xs:string"/>
<xs:element name="NovoLimite" type="xs:boolean"/>
<xs:element name="bloqueiolimite" type="xs:boolean"/>
<xs:element name="ScoreAtual" type="xs:double"/>
<xs:element name="ClassificacaoScoreAtual" type="xs:string" />
<xs:element name="NumeroAlteracoesScore" type="xs:int" />
<xs:element name="FleetPropria" type="xs:boolean" />
<xs:element name="ListaFleet" type="ListaFleetType"
minOccurs="0" />
<xs:element name="ListaDepartamento"
type="ListaDepartamentoType" minOccurs="0" />
<xs:element name="ClienteDesde" type="xs:string" />
<xs:element name="EstaNaBlackList" type="xs:boolean" />
<xs:element name="NumeroCartao" type="xs:string" />
<xs:element name="CodigoCartao" type="xs:string" />
<xs:element name="ValidadeCartao" type="xs:string" />
<xs:element name="BandeiraCartao" type="xs:string" />
<xs:element name="RegraAdicao" type="RegraAdicaoType" />
<xs:element name="ProfissaoConsultado" type="xs:string">
<xs:annotation>
<xs:documentation>
Campo necessário para as consultas ao WS Interface.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ListaQuestaoType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Questao" type="QuestaoType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="QuestaoType">
<xs:sequence>
<xs:element name="QuestionarioID" type="xs:int" />
<xs:element name="QuestaoID" type="xs:int" />
<xs:element name="Descricao" type="xs:string" />
<xs:element name="Ordem" type="xs:int" />
<xs:element name="Resposta" type="xs:int" />
<xs:element name="Valor" type="xs:int" />
<xs:element name="Mask" type="xs:string" />
<xs:element name="FgAutomaticAnswer" type="xs:string" />
<xs:element name="FgAnswerRequired" type="xs:string" />
<xs:element name="RespostaBase" type="xs:string" />
<xs:element name="ListaResposta" type="ListaRespostaType"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ListaRespostaType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Resposta" type="RespostaType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="RespostaType">
<xs:sequence>
<xs:element name="RespostaID" type="xs:int" />
<xs:element name="Descricao" type="xs:string" />
<xs:element name="Ordem" type="xs:int" />
<xs:element name="Valor" type="xs:int" />
<xs:element name="VaInitialRange" type="xs:string" />
<xs:element name="VaEndRange" type="xs:string" />
</xs:sequence>
</xs:complexType>
SOCORRO!!
um abraço.