For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 7 replies, 2 voices, and was last updated 18 years, 10 months ago by
Riyad Kalla.
-
AuthorPosts
-
menneiMemberHi!
I’m using Jboss4 and MyEclipse 4.1.
When I’m trying to start the server MyEclipse open the debug mode.
No messages are printing to the console.
I “stack” in this mode in never ending loop.
When I stop the server I get the right message in the console. (“The server shutdown succssefuly…”).
This problem is new, and I don’t know what I did worng.
Please Help!
mennei.September 27, 2006 at 12:03 pm #259377
Riyad KallaMemberMennei,
Can you go to your Breakpoints view under the Debug perspective, right click in it and do a “Remove All” and click yes. Then shut down MyEclipse and restart it using the -clean command line argument on the command line as explained here:
http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-10280.htmlOctober 2, 2006 at 4:40 pm #259705
menneiMemberHi!
I did what you said but now i can’t open the web application in debug mode.
Mennei.October 2, 2006 at 4:46 pm #259711
Riyad KallaMemberWas this resolved?
October 2, 2006 at 5:15 pm #259717
menneiMemberHi!
I am tring to map Message object with hibernate.
a) I have the follow Message.java file in package hello:package hello;
public class Message {
private Long id;
private String text;
private Message nextMessage;// Ctors.
public Message() {}
public Message (String text){
this.text = text;
}
// Setter and Getter methodes.
public Long getId(){
return id;
}
public void setId (Long id){
this.id = id;
}
public String getText(){
return text;
}
public void setText (String text){
this.text = text;
}
public Message getNextMessage(){
return nextMessage;
}
public void setNextMessage (Message nextMessage){
this.nextMessage = nextMessage;
}
}b) I have the Message.hbm.xml file in the same package as the Message.java file.
This is Message.hbm.xml:<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
<hibernate-mapping>
<class
name=”hello.Message”
table=”MESSAGE”>
<id
name=”id”
column=”MESSAGE_ID”>
<generator class=”increment”/>
</id>
<property
name=”text”
column=”MESSAGE_TEXT”/>
<many-to-one
name=”nextMessage”
cascade=”all”
column=”NEXT_MESSAGE_ID”/>
</class>
</hibernate-mapping>c) I’m using hibernate.cfg.xml file
<?xml version=’1.0′ encoding=’UTF-8′?>
<!DOCTYPE hibernate-configuration PUBLIC
“-//Hibernate/Hibernate Configuration DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”><!– Generated by MyEclipse Hibernate Tools. –>
<hibernate-configuration><session-factory>
<property name=”connection.username”>root</property>
<property name=”connection.url”>jdbc:mysql://localhost/test</property>
<property name=”dialect”>org.hibernate.dialect.MySQLDialect</property>
<property name=”myeclipse.connection.profile”>MySql profile</property>
<property name=”connection.password”>1</property>
<property name=”connection.driver_class”>com.mysql.jdbc.Driver</property><!– JDBC connection pool (use the built-in) –>
<property name=”connection.pool_size”>1</property><mapping resource=”hello/Message.hbm.xml” />
</session-factory>
</hibernate-configuration>
d) I put a manager class name HelloWorld.java
package hello;
import org.hibernate.Session;
import org.hibernate.*;
import org.hibernate.cfg.*;public class HelloWorld {
public HelloWorld(){}
/**
* @param args
*/
public void go()
{ // Adding configure method to read the properties from hibernate.cfg.xml
SessionFactory ses = new Configuration()
.addClass(Message.class)
.configure()
.buildSessionFactory();
Session session = ses.openSession();
Transaction tx = session.beginTransaction();
Message message = new Message(“Hi to everybody”);
session.save(message);
tx.commit();
session.close();
}
}I have jsp file that exeucate all. This is the code:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<%@ page import=”hello.HelloWorld” %>
<%@ page import=”java.sql.*” %>
<html>
<head>
<title>Searcher starting page</title>
</head>
<% java.util.Date date = new java.util.Date();
System.out.println(“The time now is:” + date);Connection conn = null;
try
{
String userName = “root”;
String password = “1”;
String url = “jdbc:mysql://localhost/test”;
Class.forName (“com.mysql.jdbc.Driver”).newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println (“Database connection established”);
}
catch (Exception e)
{
System.err.println (“Cannot connect to database server”);
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println (“Database connection terminated”);
}
catch (Exception e) { /* ignore close errors */ }
}
}HelloWorld hi = new HelloWorld();
hi.go();
%>
</body>
</html>but i get the next console:
23:47:38,670 INFO [STDOUT] The time now is:Mon Oct 02 23:47:38 IST 2006
23:47:38,701 INFO [STDOUT] Database connection established
23:47:38,701 INFO [STDOUT] Database connection terminated
23:47:38,701 INFO [Configuration] Reading mappings from resource: hello/Message.hbm.xml
23:47:38,717 INFO [HbmBinder] Mapping class: hello.Message -> MESSAGE
23:47:38,717 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
23:47:38,717 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
23:47:38,717 INFO [Configuration] Reading mappings from resource: hello/Message.hbm.xml
23:47:38,732 INFO [Mappings] duplicate import: hello.Message->hello.Message
23:47:38,732 INFO [Mappings] duplicate import: hello.Message->Message
23:47:38,732 INFO [HbmBinder] Mapping class: hello.Message -> MESSAGE
23:47:38,732 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.hibernate.MappingException: Could not read mappings from resource: hello/Message.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:489)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1469)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1437)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1418)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1394)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1314)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1300)
at hello.HelloWorld.go(HelloWorld.java:17)
at org.apache.jsp.GetName_jsp._jspService(GetName_jsp.java:99)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping hello.Message
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154)
at org.hibernate.cfg.Configuration.add(Configuration.java:390)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:431)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:486)
… 33 moreCan someone tell me what I did worng???
Mennei.October 2, 2006 at 7:36 pm #259742
Riyad KallaMemberWhere did you put your hbm.xml mapping file? If you look at the exception, that is the problem, Hibernate cannot find it.
October 3, 2006 at 6:08 am #259773
menneiMemberHi!
Thanks for your help.
I put the Message.hbm.xml in the same package as Message.java, the hello directory. After the deployment i can see the Message.hbm.xml in the WEB-INF/classes folder.I’m still can’t open my web application in debug mode.
Mennei.October 4, 2006 at 4:24 pm #259868
Riyad KallaMemberAre you generating your mappings to the default package, or into an actual package? Meaning, are your classes and hbm.xml files actually directly in the WEB-INF/classes directory and in your hibernate.cfg.xml file it just refers to them as /Message.hbm.xml or something like that? That is most likely the problem, please try using a full package, like com.test to generate your information into.
It’s a bad idea to use the default package for classes.
-
AuthorPosts