Results 1 to 10 of 10
  1. #1
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Exclamation Problem using object from hibernate class in a bean class

    Hi forum
    This is my first web application with a backend that uses hibernate
    I ve been stuck on this problem for a while and i need your help
    ive been creating a web application(JSF2.0) with a back end that uses hibernate annotations to interact with the database(mysql 5.1) anyway the problem is every time i use an object from my backend in bean class of the frontend(weather it be in a method or private variable) it doesnt work eg
    Java Code:
    public class aBean
    {
    
      HibernateManager hm = new HibernateManager();//object from backend
      List<Hibernate> alist = hm.getHibernateList();
    
    }
    it absolutely hates it
    but if i take away the backend objects away it comes up with no errors
    why does this happen???????
    Is there something im missing
    what im a doing wrong
    has this problem occur to you
    any help would be much appreciated and thank you in adavance
    Last edited by ShinTec; 12-14-2010 at 07:49 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,950
    Rep Power
    19

    Default

    What is it complaining about?
    What exceptions etc do you get?

  3. #3
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default

    This is the error it gives me
    Java Code:
    java.lang.NoClassDefFoundError: org/hibernate/Session
    i checked the api on NOClassDefFoundError it said this
    Java Code:
    Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
    
    The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
    so it saying that when i complied the class the definition was there but when it executes it cant find it is that what it saying or am i totally off course
    :confused:

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,950
    Rep Power
    19

    Default

    That's because your front end does not have those classes.
    Which isn't too surprising I suppose since the front end isn't supposed to be doing connections to the db.

  5. #5
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default

    how do i get round this problem what do you suggest
    Last edited by ShinTec; 12-13-2010 at 06:11 AM.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,950
    Rep Power
    19

    Default

    Why does your front end need access to Hibernate?
    Surely that's you db access layer.

    I'd ensure you have the resonsibilities laid out correctly for your various layers.

  7. #7
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default

    Yes i have a data access layer

    because it has a login screen and the username and passwords are stored in the database
    should i be passing variables from the frontend to the backend and not vice versa?????

  8. #8
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default

    okay now im getting this new error
    Java Code:
    javax.faces.application.ViewExpiredException: viewId:/login.xhtml - View /login.xhtml could not be restored.
    	at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:212)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)
    i read somewhere that ViewExpiredException is usually only thrown when you send a HTTP POST request to the server while the HTTP session is expired.
    ref:java - JSF: Cannot catch ViewExpiredException - Stack Overflow
    is this true and how do i get around it. oh i forgot to mention that im using Tomcat 6.0 as the server.
    Last edited by ShinTec; 12-14-2010 at 07:51 AM.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,950
    Rep Power
    19

    Default

    Quote Originally Posted by ShinTec View Post
    Yes i have a data access layer

    because it has a login screen and the username and passwords are stored in the database
    should i be passing variables from the frontend to the backend and not vice versa?????
    No.
    The things you pass between the layers should be your model. Your model should not contain layer-specific data. So it should not contain things that are purely to do with your dao layer. It also should not contain stuff to do with your display layer.

    No idea about your exception I'm afraid. Java Faces is not something I'm terribly familiar with.

  10. #10
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Default

    Alright i try try and keep that in mind when creating classes thanks for the help

Similar Threads

  1. substract Parent class object from child class
    By nikosv in forum New To Java
    Replies: 0
    Last Post: 12-08-2010, 12:30 AM
  2. Cast object to custom class problem
    By trader5050 in forum New To Java
    Replies: 7
    Last Post: 11-15-2010, 10:47 AM
  3. Replies: 2
    Last Post: 10-28-2010, 02:33 PM
  4. Problem with class Object
    By marak in forum New To Java
    Replies: 9
    Last Post: 07-24-2010, 03:40 PM
  5. Replies: 1
    Last Post: 01-29-2009, 09:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •