facebook

Hibernate tutorial -> IllegalStateException

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #232968 Reply

    agenturs
    Member

    After working through the hibernate tutorial I deployed the project to the JBOSS 4 folder and get the following exception:

    Java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.IdentNode
    \-[IDENT] IdentNode: ‘Vipdata’ {originalText=Vipdata}

    org.hibernate.hql.ast.SelectClause.initializeExplicitSelectClause(SelectClause.java:136)
    org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:440)
    org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:351)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.afterQuery(HqlSqlBaseWalker.java:126)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:471)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
    org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
    org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
    org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
    org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
    org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
    org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
    org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
    org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
    com.nscorp.VipService.getVipdataList(VipService.java:333)
    org.apache.jsp.AddVipData_jsp._jspService(org.apache.jsp.AddVipData_jsp:129)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

    I also have two warnings in eclipse:

    The serializable class Vipdata does not declare a static final serialVersionUID field of type long Vipdata.java BasicDB/src/com/nscorp

    The serializable class VipdataForm does not declare a static final serialVersionUID field of type long VipdataForm.java BasicDB/src/com/nscorp/formbean

    Are they related or what am I missing? I’m still to new to Java to understand the relations within the framework, so it’s difficult to know where to start looking for the problem.

    Does anyone have an idea where to look?

    Jean-Marie

    #232974 Reply

    Riyad Kalla
    Member

    com.nscorp.VipService.getVipdataList(VipService.java:333)

    What does the code aruond this line look like?

    Also the SerialID warnings are from Eclipse, it’s a compiler setting but likely wouldn’t hurt to add the IDs.

    #232986 Reply

    agenturs
    Member

    Here is the method:

    public List getVipdataList()
    {
    Session session = null;
    try
    {
    session = HibernateSessionFactory.currentSession();
    Query query =
    session.createQuery(
    “select Vipdata from com.nscorp.hibernate.Vipdata Vipdata order by Vipdata.vipName”);
    333 return query.list();
    }
    catch (HibernateException e)
    {
    System.err.println(“Hibernate Exception” + e.getMessage());
    throw new RuntimeException(e);
    }
    finally
    {
    if (session != null)
    {
    try
    {
    session.close();
    }
    catch (HibernateException e)
    {
    System.err.println(“Hibernate Exception” + e.getMessage());
    throw new RuntimeException(e);
    }
    }
    }
    }

    ————-

    I’m reading up on who to add the IDs (hope I find some info on that), thanks.

    Jean-Marie

    #232988 Reply

    agenturs
    Member

    Ups, didn’t copy the spaces. Just to make sure… the 333 on the line ‘return query.list();’ is not in the actuall code but just there to point out the line from the error message.

    #232991 Reply

    agenturs
    Member

    Regarding: Serialization

    They way I understand it from javadoc I’m supposed to set a UID. So I put

    static final long serialVersionUID = 42L;

    in both classes. Both warnings are gone.

    Does its value have to be different in each class? Is there a preference to how the value should look like?

    Since this seems to be a requirement you might want to add it to the sample code of the hibernate tutorial, project BasicDB to com.nscopr.formbean.Vipdataform.java and com.nscorp.hibernate.Vipdata.java

    Jean-Marie

    #232992 Reply

    Riyad Kalla
    Member

    You should use the quick fix by Eclipse to generate one for you, the UID helps to identify revisions of classes between serialization states.

    Also your query:

    “select Vipdata from com.nscorp.hibernate.Vipdata Vipdata order by Vipdata.vipName”

    Doesn’t make sense to me. This should be something like:
    SELECT name FROM VIPData ORDER BY VIPData.id

    where “name” and “id” are fields of the VIPData class. Your query as it is written is like saying this in SQL:
    SELECT USER_TABLE FROM USER_TABLE ORDER BY USER_TABLE.ID

    the first part doesn’t make sense.

    #232996 Reply

    agenturs
    Member

    Riyad,

    the quick fix worked, thanks…

    And you were right, by changing the statement to “SELECT vipName FROM Vipdata ORDER BY vipId” according to the mapping in Vipdata.hbm.xml it worked once but as soon as I wanted to add any data it didn’t work anymore even if I redeployed and started over. The message I get now is

    org.apache.jasper.JasperException: java.lang.String
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    root cause

    java.lang.ClassCastException: java.lang.String
    org.apache.jsp.AddVipData_jsp._jspService(org.apache.jsp.AddVipData_jsp:153)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

    Maybe I should choose a different approach than trying to work with the tutorial?

    Jean-Marie

    #232997 Reply

    Riyad Kalla
    Member

    The tutorial works fine but the devil is in the details, as you found simply changing the capitalization is the difference between a freak exception and not having one. Your new error should be easier to find (ClassCastException). Loosk like you are doing something in your AddVipData.jsp page that isn’t healthy.

    #233006 Reply

    agenturs
    Member

    I guess I’ll have to start all over again because it seems to me that I have to fix to much on the sample code that I just copied as is in order for it to work.

    If you’re saying that the tutorial works fine I must have done something wrong along the way (similar to choosing hibernate 3 instead of 2.x).

    Thanks anyway.

    Jean-Marie

    #257817 Reply

    my client program is.

    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

    //Open Session
    Session session = sessionFactory.openSession();
    try{
    //Query using Hibernate Query Language
    String SQL_STRING = “select TRAINEE_NAME FROM RMG_FEEDBACK”;
    Query query = session.createQuery(SQL_STRING);
    for (Iterator it = query.iterate(); it.hasNext();) {
    Feedback feedback = (Feedback) it.next();
    System.out.println(“User name ” + feedback.getTrainee_name() );
    System.out.println(“User Email ” + feedback.getUser_id() );
    }

    i am getting a exception like this.

    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    Exceptionjava.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.IdentNode
    \-[IDENT] IdentNode: ‘TRAINEE_NAME’ {originalText=TRAINEE_NAME}

    plz help

    #257827 Reply

    Riyad Kalla
    Member

    There is a problem mapping your property (Trainee_name) to your table. This is actually a vague error as outlined in this bug here:
    http://opensource.atlassian.com/projects/hibernate/browse/ANN-380

    The trick is to figure out what you should label the property.

    #288553 Reply

    duardito
    Member

    hi, I am searching this tutorial, I have lost link, please somebody can post it here)
    thanks.

    #288567 Reply

    Loyal Water
    Member

    The Hibernate tutorials are available on the Educational Material site.
    http://www.myeclipseide.com/module-htmlpages-display-pid-7.html

Viewing 13 posts - 1 through 13 (of 13 total)
Reply To: Hibernate tutorial -> IllegalStateException

You must be logged in to post in the forum log in