<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Últimas mensagens do tópico "Erro Hibernate  org.hibernate.InvalidMappingException: Could not parse mapping document from resourc"]]></title>
		<link>http://www.guj.com.br/posts/list/22.java</link>
		<description><![CDATA[Últimas mensagens enviadas no tópico "Erro Hibernate  org.hibernate.InvalidMappingException: Could not parse mapping document from resourc"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Erro Hibernate  org.hibernate.InvalidMappingException: Could not parse mapping document from resourc</title>
				<description><![CDATA[ Olá pessoal, to iniciando os estudos em hibernate e to com o seguinte problema.<br /> <br /> vamos do ínicio estou usando as seguintes bibliotecas<br /> <br /> hibernate3<br /> jta-1.1<br /> antlr-2.7.6<br /> commons-collections-3.1<br /> dom4j-1.6.1<br /> javassist-3.9.0.GA<br /> c3p0-0.9.1<br /> ehcache-1.2.3<br /> slf4j-simple-1.5.2<br /> slf4j-api-1.5.2<br /> postgresql-8.4-701.jdbc4.jar<br /> <br /> tenho 2 documento xml e 2 classe java<br /> <br /> Aluno.java<br /> <br /> [code]<br />     public class Aluno  <br />     {  <br />         private int alu_codigo;  <br />         private String alu_nome;  <br />         private String alu_cidade;  <br />         private String alu_telefone;  <br />         private String alu_curso;  <br />       <br />         public Aluno()  //metódo construtor  <br />        {   }  <br />          <br />        public String getAlu_cidade()  <br />        {  <br />            return alu_cidade;  <br />        }  <br />      <br />        public void setAlu_cidade(String alu_cidade)  <br />        {  <br />            this.alu_cidade = alu_cidade;  <br />        }  <br />      <br />        public int getAlu_codigo()  <br />        {  <br />            return alu_codigo;  <br />        }  <br />      <br />        public void setAlu_codigo(int alu_codigo)  <br />        {  <br />            this.alu_codigo = alu_codigo;  <br />        }  <br />      <br />        public String getAlu_curso()  <br />        {  <br />            return alu_curso;  <br />        }  <br />      <br />        public void setAlu_curso(String alu_curso)  <br />        {  <br />            this.alu_curso = alu_curso;  <br />        }  <br />      <br />        public String getAlu_nome()  <br />        {  <br />            return alu_nome;  <br />        }  <br />      <br />        public void setAlu_nome(String alu_nome)  <br />        {  <br />            this.alu_nome = alu_nome;  <br />        }  <br />      <br />        public String getAlu_telefone()  <br />        {  <br />            return alu_telefone;  <br />        }  <br />      <br />        public void setAlu_telefone(String alu_telefone)  <br />        {  <br />            this.alu_telefone = alu_telefone;  <br />        }  <br />    }  <br /> [/code]<br /> <br /> <br /> GravaAluno.java<br /> <br /> <br /> [code]   import javax.swing.JOptionPane;  <br />    import org.hibernate.*;  <br />    import org.hibernate.cfg.*;  <br />      <br />    public class GravaAluno  <br />    {  <br />        public static void main(String []args)  <br />        {  <br />            try  <br />            {  <br />                SessionFactory fabrica = new Configuration().configure().buildSessionFactory();  <br />                Session sessao =  fabrica.openSession();  <br />                Aluno aluno = new Aluno();  <br />                aluno.setAlu_codigo(1);  <br />                aluno.setAlu_nome("Renato");  <br />                aluno.setAlu_curso("Hibernate");  <br />                aluno.setAlu_telefone("222222222");  <br />                aluno.setAlu_cidade("Belo Horizonte");  <br />                Transaction transacao_aluno = sessao.beginTransaction();  <br />                sessao.save(aluno);  <br />                transacao_aluno.commit();  <br />                sessao.close();  <br />            }  <br />            catch(Exception e)  <br />            {  <br />                JOptionPane.showMessageDialog(null,"Erro na inserção : "+e);  <br />            }  <br />        }  <br />    }  <br /> [/code]<br /> <br /> <br /> aluno.hbm.xml<br /> <br /> <br /> [code]   &lt;?xml version="1.0" encoding="UTF-8"?&gt;  <br />    &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  <br />    "http://hibernate.sourcerforge.net/hibernate-mapping-3.0.dtd"&gt;  <br />    &lt;hibernate-mapping&gt;  <br />        &lt;class name="Aluno" table="alunos"&gt;  <br />            &lt;id name="alu_codigo" type="int"/&gt;  <br />            &lt;property name="alu_nome" /&gt;  <br />            &lt;property name="alu_cidade" /&gt;  <br />            &lt;property name="alu_telefone" /&gt;  <br />            &lt;property name="alu_curso" /&gt;  <br />        &lt;/class&gt;  <br />    &lt;/hibernate-mapping&gt;  <br /> [/code]<br /> <br /> <br /> hibernate.cfg.xml<br /> <br /> [code]<br />    &lt;?xml version="1.0" encoding="UTF-8"?&gt;  <br />     &lt;!DOCTYPE hibernate-configuration PUBLIC  <br />               "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  <br />               "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;  <br />     &lt;hibernate-configuration&gt;  <br />         &lt;session-factory&gt;  <br />             &lt;property name="connection.url"&gt;  <br />                 jdbc:postgresql://localhost/JavaHibernate  <br />             &lt;/property&gt;  <br />            &lt;property name="connection.username"&gt;  <br />                postgres  <br />            &lt;/property&gt;  <br />            &lt;property name="connection.password"&gt;  <br />                xxxxxx  <br />            &lt;/property&gt;  <br />            &lt;property name="connection.driver_class"&gt;  <br />                org.postgresql.Driver  <br />            &lt;/property&gt;  <br />            &lt;property name="dialect"&gt;  <br />                org.hibernate.dialect.PostgreSQLDialect  <br />            &lt;/property&gt;  <br />            &lt;mapping resource="aluno.hbm.xml"/&gt;  <br />        &lt;/session-factory&gt;  <br />    &lt;/hibernate-configuration&gt;  <br /> [/code]<br /> <br /> <br /> quando executo a classe gravaAluno<br /> me retorna um erro<br /> Erro na inserção : org.hibernate.InvalidMappingException: Could not parse mapping document from resource aluno.hbm.xml<br /> <br /> Ja procurei, mas não consigo achar o erro.<br /> <br /> Para esclarecimento, este mesmo problema ja foi relatado aqui no forum, no seguinte link:<br /> <br /> [url]http://www.guj.com.br/posts/list/132888.java#715383[/url]<br /> <br /> So que o cara em questão estava usando o MySQL, aí mudou pro Postgre e o problema foi resolvido. Eu ja estou usando Postgre, por isso a "solução" que ele encontrou não vale pra mim.<br /> <br /> To usando Netbeans 6.8<br /> <br /> Alguém poderia ajudar?<br /> Desde já, agradeço a atenção.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/998874/erro-hibernate--orghibernateinvalidmappingexception-could-not-parse-mapping-document-from-resourc
</guid>
				<link>http://www.guj.com.br/prepost/198793/998874/erro-hibernate--orghibernateinvalidmappingexception-could-not-parse-mapping-document-from-resourc
</link>
				<pubDate><![CDATA[Sun, 21 Feb 2010 14:06:06]]> GMT</pubDate>
				<author><![CDATA[ renato1010]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException:</title>
				<description><![CDATA[ Tente cololocar a classe Aluno dentro de algum pacote como br.com.nomedesuaempresa.entity, se ainda não estiver.<br /> No mapeamento do hbm.xml, coloque em classe o nome inteiramente qualificado desta, ou seja, o pacote + classe. Exemplo:<br /> '&lt;class name="br.com.nomedesuaempresa.entity.Aluno '<br /> <br /> Mas de verdade mesmo, utilize anotações no lugar de arquivos .hbm.xml. É bem mais simples de escrever os mapeamentos.<br /> Estude também JPA.<br /> <br /> Um ótimo livro sobre utilização do hibernate e JPA é :<br /> <a class="snap_shots" href="http://www.manning.com/bauer2/" target="_blank" rel="nofollow">http://www.manning.com/bauer2/</a> (Java Persistence with Hibernate)<br /> <br /> Leitura indispensável.<br /> <br /> []s]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/998894/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/998894/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Sun, 21 Feb 2010 16:21:36]]> GMT</pubDate>
				<author><![CDATA[ Alessandro Lazarotti]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ Ola, bom a classe Aluno está dentro do pacote padrão, bem como a classe gravaAluno e os arquivos xml. Sendo assim, deveria conseguir mapear sem problemas. Quanto a utilizar anotações, estou começando a estudar hibernate e não sei como fazer ainda. Ja tentei colocar a classe aluno dentro de algum pacote e dpois coloquei no mapeamento do aluno.hbm.xml o caminho completo (pacote + classe). Mas o problema persiste.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/998917/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/998917/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Sun, 21 Feb 2010 17:45:21]]> GMT</pubDate>
				<author><![CDATA[ renato1010]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException: </title>
				<description><![CDATA[ Você pode copiar aqui a stack trace do erro?]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/998974/reerro-hibernate--orghibernateinvalidmappingexception-
</guid>
				<link>http://www.guj.com.br/prepost/198793/998974/reerro-hibernate--orghibernateinvalidmappingexception-
</link>
				<pubDate><![CDATA[Sun, 21 Feb 2010 22:52:41]]> GMT</pubDate>
				<author><![CDATA[ Alessandro Lazarotti]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ [quote=renato1010]Ola, bom a classe Aluno está dentro do pacote padrão, bem como a classe gravaAluno e os arquivos xml. Sendo assim, deveria conseguir mapear sem problemas. Quanto a utilizar anotações, estou começando a estudar hibernate e não sei como fazer ainda. Ja tentei colocar a classe aluno dentro de algum pacote e dpois coloquei no mapeamento do aluno.hbm.xml o caminho completo (pacote + classe). Mas o problema persiste.[/quote]<br /> <br /> Tipo.... a propriedade alu_codigo no banco de dados esta como primary key?<br /> <br /> Cola o script do banco aqui tb...]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/998981/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/998981/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Sun, 21 Feb 2010 23:12:19]]> GMT</pubDate>
				<author><![CDATA[ Requena]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException:(Resolvido)</title>
				<description><![CDATA[ Ola pessoal.<br /> <br /> Obrigado aí pela atenção. <br /> Consegui resolver o problema.<br /> Deixei o hibernate.cfg.xml dentro do pacote padrão e criei um pacote novo colocando dentro dele as classes Aluno e GravaAluno e o arquivo aluno.hbm.xml.<br /> <br /> No mapeamento coloquei nomedopacotenovo/aluno.hbm.xml (antes tinha tentado isso colocando nomedopacotenovo.aluno.hbm.xml), dessa forma funcionou.<br /> <br /> Agradeço a todos pela ajuda aí.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/998985/reerro-hibernate--orghibernateinvalidmappingexceptionresolvido
</guid>
				<link>http://www.guj.com.br/prepost/198793/998985/reerro-hibernate--orghibernateinvalidmappingexceptionresolvido
</link>
				<pubDate><![CDATA[Sun, 21 Feb 2010 23:36:40]]> GMT</pubDate>
				<author><![CDATA[ renato1010]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ Tudo o que eu quero é apenas estabelecer um mapeamento entre a classe intranet.Papel e a tabela Intranet.dbo.TB_PAPEL no servidor 192.1.1.13\Producao - SQL Server 2008. Meu maior suspeito é essa barra invertida que eu não sei como se comporta na string de conexão do hibernate.<br />  Segue abaixo os resources.<br /> <br /> <br /> [u][b]hibernate.cfg.xml[/b][/u]<br /> <br /> &lt;?xml version='1.0' encoding='utf-8'?&gt;<br /> &lt;!DOCTYPE hibernate-configuration PUBLIC<br />     "-//Hibernate/Hibernate Configuration DTD//EN"<br />     "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;<br /> &lt;hibernate-configuration&gt;<br />     &lt;session-factory&gt;<br />         &lt;property name="hibernate.connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt;<br />         &lt;property name="hibernate.connection.url"&gt;jdbc:sqlserver://192.1.1.13\PRODUCAO;DatabaseName=Intranet&lt;/property&gt;<br />         &lt;property name="hibernate.connection.username"&gt;usrIntra&lt;/property&gt;<br />         &lt;property name="hibernate.connection.password"&gt;intra&lt;/property&gt;<br />         &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;<br />         &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/property&gt;<br />         &lt;property name="hibernate.current_session_context_class"&gt;org.hibernate.context.ManagedSessionContext&lt;/property&gt;<br />         &lt;property name="hibernate.cache.use_second_level_cache"&gt;false&lt;/property&gt;<br />         &lt;property name="hibernate.cache.use_query_cache"&gt;false&lt;/property&gt;<br />         &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;        <br />         &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;<br />         <br />         &lt;mapping resource="intranet/Papel.hbm.xml"/&gt;<br />     &lt;/session-factory&gt;<br /> &lt;/hibernate-configuration&gt;<br /> <br /> <br /> [u][b]hibernate.properties[/b][/u]<br /> <br /> hibernate.dialect = org.hibernate.dialect.SQLServerDialect <br /> hibernate.connection.driver_class = com.microsoft.sqlserver.jdbc.SQLServerDriver <br /> hibernate.connection.url = jdbc:sqlserver://192.1.1.13\PRODUCAO;DatabaseName=Intranet <br /> hibernate.connection.username = usrIntra<br /> hibernate.connection.password = intra<br /> <br /> <br /> [u][b]Tentativa 1 - Com hibernate.cfg.xml[/b][/u]<br /> <br /> SessionFactory sessao = new Configuration().configure().buildSessionFactory();<br /> sessao.openSession();<br /> <br /> <br /> [b][u]Tentativa 2 - Com hibernate.properties[/u][/b]<br /> <br /> SessionFactory factory = new Configuration().addClass(Papel.class).buildSessionFactory();  <br /> Session session = factory.openSession();  <br /> session.flush();  <br /> session.close(); <br /> <br /> <br /> [b][u]Erro apresentado[/u][/b]<br /> <br /> org.hibernate.InvalidMappingException: Could not parse mapping document from resource intranet/Papel.hbm.xml<br /> <br /> <br /> Se alguém puder me ajudar, eu agradeceria muito. Obrigado.]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/1175596/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/1175596/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Thu, 6 Jan 2011 11:34:26]]> GMT</pubDate>
				<author><![CDATA[ klebernss]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ Segue também as classes para mapeamento.<br /> <br /> [u][b]intranet.Papel.java[/b][/u]<br /> <br /> package intranet;<br /> <br /> public class Papel {<br /> 	private String nome;<br /> 	private String descricao;<br /> 	public String getNome() {<br /> 		return nome;<br /> 	}<br /> 	public void setNome(String nome) {<br /> 		this.nome = nome;<br /> 	}<br /> 	public String getDescricao() {<br /> 		return descricao;<br /> 	}<br /> 	public void setDescricao(String descricao) {<br /> 		this.descricao = descricao;<br /> 	}<br /> 	<br /> }<br /> <br /> <br /> [u][b]Papel.hbm.xml[/b][/u]<br /> <br /> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br /> &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping.dtd"&gt;  <br /> &lt;hibernate-mapping&gt;  <br /> 	&lt;class name="Papel" table="dbo.TB_PAPEL"&gt;  <br />  		&lt;id name="nome" column="NOME" type="string"&gt;  <br /> 			&lt;generator class="assigned"/&gt;  <br /> 		&lt;/id&gt;  <br /> 		&lt;property name="descricao" column="DESCRICAO" type="string"/&gt;<br /> 	&lt;/class&gt;  <br /> &lt;/hibernate-mapping&gt;  <br /> <br /> ]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/1175601/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/1175601/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Thu, 6 Jan 2011 11:39:07]]> GMT</pubDate>
				<author><![CDATA[ klebernss]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ Aê, bando de pé de breque, consegui!<br /> <br /> [b]Mudei o cabeçalho do hbm.xml de:[/b]<br /> "-//Hibernate/Hibernate Mapping DTD//EN" <br /> "http://hibernate.sourceforge.net/hibernate-mapping.dtd"<br /> [b]Para:[/b]<br /> &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate Mapping DTD 3.0//EN"     <br /> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; <br /> <br /> Com o hibernate.cfg.xml funcionou normalmente.<br /> <br /> Com o hibernate.properties não. <br /> [b]Dá o erro com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.1.1.13PRODUCAO, port 1433 has failed.[/b]<br /> <br /> Não há nada de errado com o servidor, pois é a mesma string de conexão no cfg.xml e lá funciona normalmente.<br /> <br /> Alguém tem alguma sugestão?]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/1175672/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/1175672/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Thu, 6 Jan 2011 13:30:01]]> GMT</pubDate>
				<author><![CDATA[ klebernss]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ Pessoal, consegui denovo!<br /> <br /> Ao contrário do hibernate.cfg.xml, quando se está no hibernate.properties, ele trata a string de conexão como uma String mesmo. <br /> Ou seja, não se pode escrever: hibernate.connection.url = jdbc:sqlserver://192.1.1.13\PRODUCAO;DatabaseName=Intranet .<br /> Tem que ser: hibernate.connection.url = jdbc:sqlserver://192.1.1.13\\PRODUCAO;DatabaseName=Intranet .<br /> <br /> E pra saber disso, hein?! Puro tentative/error.<br /> <br /> Grande Java!!!]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/1175683/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/1175683/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Thu, 6 Jan 2011 13:45:14]]> GMT</pubDate>
				<author><![CDATA[ klebernss]]></author>
			</item>
			<item>
				<title>Re:Erro Hibernate  org.hibernate.InvalidMappingException</title>
				<description><![CDATA[ Pessoal, consegui denovo!<br /> <br /> Ao contrário do hibernate.cfg.xml, quando se está no hibernate.properties, ele trata a string de conexão como uma String mesmo. <br /> Ou seja, não se pode escrever: hibernate.connection.url = jdbc:sqlserver://192.1.1.13\PRODUCAO;DatabaseName=Intranet .<br /> Tem que ser: hibernate.connection.url = jdbc:sqlserver://192.1.1.13\\PRODUCAO;DatabaseName=Intranet .<br /> <br /> E pra saber disso, hein?! Puro tentative/error.<br /> <br /> Grande Java!!!]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/198793/1175687/reerro-hibernate--orghibernateinvalidmappingexception
</guid>
				<link>http://www.guj.com.br/prepost/198793/1175687/reerro-hibernate--orghibernateinvalidmappingexception
</link>
				<pubDate><![CDATA[Thu, 6 Jan 2011 13:45:49]]> GMT</pubDate>
				<author><![CDATA[ klebernss]]></author>
			</item>
	</channel>
</rss>
