Como deve sera minha estrutira para fazer o hibernate funcionar com o tomcat. Estou usando o hibernate 2.01. O meu hiber.jsp esta tentando fazer o include do package hiber mas ele diz que ele nao existe. O mapemento do tabela do banco esta dentro do pacote hiber.jar . Alguem pode dar uma força no pontapé inicial?
|–webapps
|-----hiber
|--------hiber.jsp
|--------WEB-INF
|------------web.xml
|------------classes
|----------------hibernate.properties
|----------------hiber.hbm.xml
|------------lib
|----------------hiber.jar
|----------------hibernate2.jar
|----------------driverdomssql.jar
TazPJ
Junho 6, 2005, 12:49pm
#2
Victor,
coloque o fonte do seu hiber.jsp e o conteúdo do seu hiber.jar. Talvez, dessa maneira fique mais fácil de responder.
Esse eh o Record.java que faz parte da hiber.jar
[code]public class Record {
private String name;
private Long id;
public Record()
{}
public Record( Long id, String name )
{
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}[/code]
esse eh o hiber.jsp
<%@ page import =" hiber.* , net.sf.hibernate.Session, net.sf.hibernate.SessionFactory, net.sf.hibernate.cfg.Configuration "%>
<html>
<head>
<title>Hibernate </title>
</head>
<body>
<%
Configuration configura = new Configuration().configure();
SessionFactory sf = configura.buildSessionFactory();
Session s = sf.openSession();
%>
</body>
</html>
Meu hibernate.cfg.xml
[code]<?xml version="1.0" ?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd ">
<!-- Hibernate configuration. -->
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.postgresql.Driver
</property>
<property name="connection.url">
jdbc:postgresql://192.168.0.108:5432/testedb
</property>
<property name="connection.username">teste</property>
<property name="connection.password">teste</property>
<property name="dialect">net.sf.hibernate.dialect.HSQLDialect
</property>
<property name="show_sql">false</property>
<property name="hbm2ddl.auto">update</property>
<property name="use_outer_join">true</property>
<property name="cglib.use_reflection_optimizer">true</property>
<mapping resource="Record.hbm.xml" />
</session-factory>
</hibernate-configuration>
e o por ultimo o meu Record.hbn.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd " >
<hibernate-mapping>
<class name="hiber.Record">
<id name="id">
<generator class="increment"/>
</id>
<version name="version"/>
<property name="name" not-null="true"/>
</class>
</hibernate-mapping>[/code]
e o erro que ta dando
exception
javax.servlet.ServletException: Could not find a getter for version in class hiber.Record
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.hiber_jsp._jspService(hiber_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Se alguem tiver alguma ideia
Li na api que isso quer dizer que ta falando um metodo get. Precisa ter algum get ou set a mais?
TazPJ
Junho 6, 2005, 5:16pm
#5
Provavelmente sim, repare q ele reclama do campo “version”, pq vc definiu:
Talvez vc tenha q implementar isso no Java Bean…
Eu não tenho um exemplo aki, mas sugiro q procure no Google e poste a solução para os próximos aventureiros…
Abraço.
Eu tinha reparado que isso tava sobrando. Ainda nao sei pra que isso serve mas sem ele realmente funcionou.