[RESOLVIDO] Problemas com xml

3 respostas
D

Estou tendo o seguinte erro quando executo meu parse de xml:

com.thoughtworks.xstream.converters.ConversionException: Element acessos of type teste.Acessos is not defined as field in type teste.Painel
---- Debugging information ----
class               : teste.CanalSonda
required-type       : teste.Painel
path                : /canal_sonda/perfis/perfil/painel/acessos
line number         : 16
-------------------------------
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.writeValueToImplicitCollection(AbstractReflectionConverter.java:283)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:236)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
	at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:225)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
	at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
	at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:68)
	at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
	at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:246)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:218)
	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
	at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
	at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137)
	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
	at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923)
	at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909)
	at com.thoughtworks.xstream.XStream.fromXML(XStream.java:861)
	at teste.TesteLerXML.main(TesteLerXML.java:23)
Segue tambem a classe principal...
public static void main(String[] args) {
		XStream x = new XStream();
		try {
			// carrega o arquivo xml
			FileInputStream input = new FileInputStream("/home/david/CANAL_SONDA.xml");
			// informa o nome do nó raiz do xml
			x.alias("canal_sonda", CanalSonda.class);
			// informa o nome do nó perfil do xml
			x.alias("perfils", CanalSonda.class);
			x.alias("perfil", Perfil.class);
			x.alias("painel", Painel.class);
			x.alias("acessos", Acessos.class);
			x.alias("acesso", Acesso.class);
			// cria um objeto de CanalSonda, contendo os dados lidos no xml
			CanalSonda a = (CanalSonda) x.fromXML(input);
			// Perfil p = (Perfil) x.fromXML(input);
			// imprime os dados
			System.out.println("Perfil: " + a.getPerfis());
			System.out.println("Painel: " + a.getPainel());
			System.out.println("Acesso: " + a.getAcessos());
//			System.out.println("Acesso: " + a.getAcesso());

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

3 Respostas

R

mas exatamente o que vc está querendo fazer?

D

Acabei resolvendo rafael… Mais estava querendo ler os dados de um xml !
O erro estava no mapeamento que estava fazendo.

R

tendeu… :smiley:

Criado 14 de junho de 2013
Ultima resposta 17 de jun. de 2013
Respostas 3
Participantes 2