Session problem in LazyFetch

Hi all,
I have two entities: User and InfoUser in my website.
User has much "InfoUser".
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<InfoUser> infos = new LinkedList();
// Code..
public List<InfoUser> getInfos(){
      return infos;
}When I use the userFacade.findAll(), it return all the users in a List. All ok.
When I call the getInfos() from a User I receive an error message:
org.apache.jasper.JasperException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.ianaz.bean.User.InfoUser, no session or session was closedI won't use EAGER type for performance.
Anyone has a solution?
Thanks in advance

Ok.
I have Categoria. It has more Documento
    @OneToMany(mappedBy="categoria", cascade=CascadeType.ALL)
    private List<Documento> documenti = new LinkedList();Then I have a Stateless class named CategoriaFacade
It has some metods
    @PersistenceContext
    private EntityManager em;
    public void create(Categoria categoria) {
        em.persist(categoria);
    public List findAll() {
        return em.createQuery("select object(o) from Categoria as o").getResultList();
...I will call the findAll() method from a JSP page.
If I call from a Servlet it's easy with the code:
public class NewServlet extends HttpServlet {
    @EJB
    private CategoriaFacadeLocal categoriaFacade;
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        categoriaFacade.METHOD_FROM_CATEGORIAFACADECLASS();
}But I don't know how to call methods from a jsp... Understand? :-)
Thanks in advance

Similar Messages

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • Session problem in jsp application

    I face a session problem. I setting everything in a session and when pass back to a main page, the value is not display in the screen. But after refresh the value will display in the screen and this kind of problem only come out very few time and i dun knw how to solve this...
    Anyone here can give me some idea and suggestion or the way to solve this kind of problem!!!

    define "2 different clients"
    1) You have 2 different PCs and it's using the same session ID for both? I doubt this. I think the server is advanced enough not to use give a session ID that's already been created.
    2) You have 1 PC and are using IE or Netscape and using File > New Window to open a new window and connect again. This you can't fix without using only URL rewriting to manage session, because the different windows will share the same session cookies.

  • Session problem in a new window created by window.open()

    hello,
    I have a drugsearch.jsp page, I sessioned an durgCollection object on this jsp page using session.setAttribute("drugCollection",drugCollection);
    there is a link on this jsp which will call a javascript to open a new window .
    here is the javascript to open another new window:
    function openReportWindow()
    window.open("/drug/Report.jsp","report", "toolbar,scrollbars,width=800,height=800,left=100,top=10");
    but in the Report.jsp, I won't be able to get the same session object as in the calling jsp ( drugsearch.jsp) by calling session.getAttribute("drugCollection").
    if I change the link on drugsearch.jsp to link to the Report.jsp directly instead of opening a new window, then I can get the same session object from the Report.jsp.
    what's the problem? can someone give me an advice?
    thanks

    A session is assosiated with one client(browser).
    when you open a new browser, a new session is created. In order to have common place for both the browsers, try storing the data in the 'Servlet Context'

  • Session problem in ADF BC

    We have an application developed in Jdev 10.1.3.4 (JSP, Struts, ADF BC) and running on OAS. Now we have a big problem with session, hope somebody can help with some ideas.
    We set session time to 45 min in the web.xml. The problem is that sometimes some user work on a page with form,for instance performing some edit activity. If he/she leave the page open inactive for more than 45 minutes and come back from lunch, press the ’save’ button, the application would then commit the change to the wrong row in database, most probably the top row in the View Object(VO) instance. This is because the application module actually does a rollback when session expires, it loses all user data.(e.g. row currency in VO instance).
    To avoid saving wrong data to the wrong place, we implemented a session Filter(see att. Below: ApplicationSessionExpiryFilter.java) to catch session time-out and forward request to an error page alerting user that their session has expired due to long time of inactivity. The Filter works as it should but it gives another problem. If user already has one of our application page open for very long time and open another page in a new browser (e.g. click a link from an email), he/she will get session-expire error immediately in the new browser. I guess it is because the session in the first browser already expires and the newly opened the browser shares the same session with the first one. That is how browsers works, we can do nothing about it.
    But our users are of course not very happy about getting the session errors in a newly opened browser. So we tried implementing a heartbeat funtion in AJAX(see att. Below: Heartheat.html and Template.jsp) to keep the session alive until the page is closed. Basically what we do is adding an invisible div tag in every jsp page and invoke AJAX funtion to periodically update the div tag with a small html page. In this way, a request is being sent to the server every 5 minutes thus the session should be kept alive until the page/browser is closed.
    It sounds to us like a very logical solution but it doesn’t work very properly. We sometimes still get the session error page immediately after opening a new page while we have another page open for long time.
    Could anyone please help to look at our Filter and heatbeat funtion? Is there anything wrong with our Filter or the heartbeat? Why does the session still expire before we close the page?
    All we do here is to try to avoid the initial probelm with saving data after session and the application module expires. If anyone has a better solution to this problem, we would very much like to try. Appreciate if anyone can share some ideas!
    Thanks in advance!
    *1. ApplicationSessionExpiryFilter.java*
    public class ApplicationSessionExpiryFilter implements Filter {
    private FilterConfig _filterConfig = null;
    public void init(FilterConfig filterConfig) throws ServletException {
    _filterConfig = filterConfig;
    public void destroy() {
    _filterConfig = null;
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest)request;
    boolean sessionInvalid = false;
    if(httpRequest.getRequestedSessionId() != null) {
    if(!httpRequest.isRequestedSessionIdValid()) {
    if (!httpRequest.getRequestURI().endsWith("sessionExpired.do")) {
    sessionInvalid = true;
    if (sessionInvalid) {
    ((HttpServletResponse) response).sendRedirect(_filterConfig.getInitParameter("SessionTimeoutRedirect"));
    else {
    chain.doFilter(request, response);
    *2. Heartheat.html* (A small html page to be invoked by template.jsp periodically)
    <html>
    <head>
    <META Http-Equiv="Cache-Control" Content="no-cache, must-revalidate">
    <META Http-Equiv="Pragma" Content="no-cache">
    <META Http-Equiv="Expires" Content="Expires: Mon, 26 Jul 1997 05:00:00 GMT">
    </head>
    <body>
    heartbeat to keep session alive!
    </body>
    </html>
    *3. Template.jsp* (Template page to be extended by all jsp pages, invoke heart.html every 5 min)
    <Html>
    <body>
    <div id="heartbeat" style="display:none">
    </div>
    <script type="text/javascript" language="javascript">
    new Ajax.PeriodicalUpdater('heartbeat','jsp/template/heartbeat.html',{ method: 'post', frequency: 300, decay: 1 }); // update heartbeat.html every 300 sec(5min)
    </script>
    </body></html>

    Hi Shay,
    Reviewing ADFContex methods it seems that this object shouldn't be accessible from BC. Example:
    public static ADFContext initADFContext(java.lang.Object context,
                                            java.lang.Object session,
                                            java.lang.Object request,
                                            java.lang.Object response)
        Initializes the ADFContext for the environment of the specified context.
        Parameters:
            context - the ServletContext or PortletContext of the current execution environment.
            session - the HttpSession or PortletSession of the current execution environment. OPTIONAL.
            request - the HttpServletRequest or PortletRequest of the current execution environment. OPTIONAL.
            response - the HttpServletResponse or PortletResponse of the current execution environment. OPTIONAL.
        Returns:
            the ADFContext that was current when init was invoked. Should be passed back to resetADFContext after the block requiring the ADFContext has completed.Kuba

  • Urgent: Sessions problem pls help me

    Hi all,
    Its already late to post this problem.pls help me urgently.
    I have a servlet & two jsp's. first i request servlet, it processes something and forwards request to my first jsp. In that jsp on a button click, i'm displaying a new popup by calling showModalDialog. this dialog gets data from the same servlet but it forwards to my second jsp.(second jsp can be seen in dialog)
    Now if i submit form from my second(dialog) jsp, the servlet reports that session has expired. I tried a lot but invain. any one who helps me is appreciated well by all of our forum.
    waiting 4 u r reply,

    It could be that you have cookies turned off and you're not using URL Rewriting.
    In J2EE, the first time your browser makes a request to the server, the server responds and appends a SESSION_ID parameter to the request as well as storing a cookie with the SESSION_ID.
    The second time your browser makes a request, the server checks for the cookie. If it doesn't exist it checks for the parameter. If neither exist the server assumes its the first time your browser has made a request and behaves as describe in the previous paragraph.
    In your case when you submit the form if you have disabled cookies and the action attribute doesn't have the SESSION_ID paramter appended to the url, the browser will assume it's a first request. The user will not be logged in, hence your session has expired error.
    To fix this you need to encode the URL in your JSP. You can use the struts html:rewrite tag or the HttpServletReponse.encodeURL method, or if you're using JSP 2.0 the JSTL c:url tag.

  • Session problems in tomcat 5.0.28

    Even I shutdown the tomcat 5.0.28 server the session variable is still existing and it is showing the old values. What I have to do to disable the old values? Is it the problem with tomcat 5.0.28 or with JSP coding!

    Tomcat serializes sessions to the hard drive when it shutsdown. If you don't want this you have three choices:
    1: you can disable this functionality in the server.xml. Check the documentation.
    2: you could just delete the session.ser file when you shut down tomcat. This file is under work/standalone/{webapp name}
    3: you could close and re-open the browser so that the old jsessionid will not be sent and a new session will be created. The old session will eventually time out.
    The third option is probably the easiest.

  • JSP Session Problems

    Hi, i am facing a problem of the Object set into a session not being visible to the others pages. what did i done wrongly?
    here is the code:
    in login.jsp (currently hardcode cos i haven recieve that part):
    <%@page import="fantasy.team.*,java.util.Vector" session="true"%>
    <%
    Team t = new Team("Kacheek FC");
    session.setAttribute("team",t);
    if( session.getAttribute("team") ==null){
         out.write("how come null");
    }else{
         out.write("not null");
    %>
    Select
    //End of coding
    not null will be printed
    Following code belong to selectPlayer.jsp:
    if( session.getAttribute("team") == null){          
              out.write("i am null");               }else{
              out.write("i am not null");
    i am null is printed
    what is wrong with my coding?
    thanks.

    i do a
    if(session.isNew())
    out.write("New");
    and the result is new.
    meaning that my session is invalidate.
    that explain my value from "gone" rite?
    how to solve this?
    thanks.

  • Session Problems(ConcurrentModificationException)

    Hi,
    I am facing some problems with session here.
    I get a java.util.ConcurrentModificationException whenever i try to empty the shopping cart.
    Could somebody pls kindly advise?
    Thanks in advance
    below is the code:
    <% String item = request.getParameter("itemName");
    if(item != null && item.equals("emptyCart")) {
    java.util.Enumeration attributeNames = session.getAttributeNames();
    while(attributeNames.hasMoreElements()) {
    String attributeName = (String)attributeNames.nextElement();
    session.removeAttribute(attributeName);
    } else if(item != null) {
    String attributeName = item + "CD";
    session.setAttribute(attributeName, item);
    %>

    Similar qus answered int his forum ..
    refer
    http://forum.java.sun.com/thread.jsp?thread=244532&forum=45&message=897268

  • Session problems on wls6.1

    We have two domains with an identical application but one can pass out login
    credential through the session without any problems and the other just
    cannot retrieve the reference from the session. Both have the same session
    settings. Can any one point me a direction to look at? Thank you.
    Jack Shieh

    We found out what the problem was. Turned out the domain name we used on the
    client side didn't match the one on the host, and therefore the session is
    recreated for every request.
    "Jack Shieh" <[email protected]> wrote in message
    news:41e5acba$1@mail...
    We have two domains with an identical application but one can pass out
    login credential through the session without any problems and the other
    just cannot retrieve the reference from the session. Both have the same
    session settings. Can any one point me a direction to look at? Thank you.
    Jack Shieh

  • Session Problems

    Hi,
    I have a PHP site that uses frames. The frameset loads
    another site (both on
    the
    same server) in the lower frame window. Every time the page
    changes in the
    lower frame the session id changes, how can I stop this
    happening?
    Thanks for your help

    Thanks for the instructions, but now I'm wondering that this isn't even my problem. My problem is extremely strange. Let me explain...
    I'm building a website called Project Squared. As of right now, we're using SSL certificates (maybe this has something to do with the problem). Anyway, I try to login with my correct user information, and it works. But then, if I just close the Safari window without actually exiting Safari, if I open a new window and try to login again, I have to enter either incorrect information, or no information at all, to login. I can only login with correct information again if I exit Safari completely. Is this common, or do you know a fix? Thanks a lot.

  • JSP Session problem in HTML frames????

    Hi everybody;
    I have a problem with session I think. My index page is created with 4 diffrent jsp's in 4 diffrent frames.After a while lets say 15 minutes when my session is expired.When I click one of my button ..The frames which linked with that button is show Http 500 error page.When I refreshes the web page they all gone.(and my web page goes normal again)
    I want to ask you how can I handle this problem.How can I solve this error page showing and stop showing that error page instead of in each frame,to refresh the index page again??
    Thanks for your consideration.....

    The first step is to decide whether 15 minutes is a suitable timeout for sessions.
    If it isn't then simply increase it in web.xml. You may also decide that session persistence is worth enabling (if your Servlet container supports it).
    If it's not then your pages will need to handle a null (or at least new) session slightly more elegantly. You're probably just getting a null pointer exception because something your pages is relying on is missing (a session attribute of some sort). Sometimes it's sufficient just to redirect the topmost window to the index page - not the greatest user experience in the world but at least consistent.
    Hope this helps.

  • Session problem in one out of two jsp

    Dear java guru's
    I have got jsp page A.jsp.User select few option and this jsp calls
    B.servlet this takes user input and pass to
    C.bean which returns vector to B.servlet
    This servlet put vector in session and dispatch to new jsp
    D.jsp which calls
    E.jsp in it for Image generation.
    This E.jsp retrieve vector from session and generate a image and reurn to D.jsp
    Now my problem is that session in B.servlet and D.jsp are same but a new session in created in E.jsp so image is null as it could get data from vector which is null.
    I put System.out.println(session.getId()) in each servlet and jsp so to get thier ID's.
    This is working fine in my system with Tomcat 3.2 but on web the new session is created for E.jsp
    I am calling E.jsp like this
    <img src=<%=response.encodeURL("/iscap/report/jspChart.jsp")%> alt="generation image" width="400" height="350" border="1">
    I am making page session=true in each jsp and also puttting request.getSession(false);
    but still E.jsp is getting new session.I tried eliminating each one and made all combination that could be possible but not effect.
    How Can I solve this problem on the web where I have to load this?
    Do I have to make setting in context .
    payal sharma

    Hi,
    If you have been using jspChart v 1.00 :
    As shown in the modified , attached PPT :
    I will be displaying a bar chart. The length of bar chart is obatined from Sybase database. This chart should be dynamically created depending on the value on
    the database and x -axis is exponential.
    This will be displayed on a HTML page.
    1. I want to know whether,the values can be obtained the values from Sybase database ?
    If so, what are the changes.
    2. can you tell me the steps to install and run the jspchart v 1.00 on Jrun or any server please.
    Any thing else, I need to install like SAX , JCLARK. I am getting errors in this. PL HELP.
    3. Is it possible to plot "Exponential values" in the Y-axis. like 0 - 100- 1000 - 10000 - 100000
    and the length of the Bar should automaticall be coloured till that Point as shown in the Power point attached.
    If not, any suggestions to use any other software.
    Thanks in advance.
    [email protected]

  • Sessions problem when deploying to AS 10g (10.1.2.0.2)

    Hello,
    I have a very simple Web Application where I have isolated an issue I have found. The application works fine when executed in JDeveloper 10g (10.1.2.2) but it does not work when deployed in the AS 10g (10.1.2.0.2). My Platform is Windows XP Professional x64.
    The application has been created in JDeveloper (New &gt;&gt; Web Project) and contains:
    - a simple jsp page (main.jsp) displaying a dummy message,
    - a simple filter class (authFilter.java) which only has the following code in the doFilter method:
    HttpServletRequest hreq = (HttpServletRequest)request;
    System.out.println("*** session id = " + hreq.getSession().getId());
    System.out.println("*** requested session id = " + hreq.getRequestedSessionId());
    - a web deployment descriptor (web.xml) where the reference to the filter has been added:
    &lt;filter&gt;
    &lt;filter-name&gt;Filter1&lt;/filter-name&gt;
    &lt;filter-class&gt;myfilters.authFilter&lt;/filter-class&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
    &lt;filter-name&gt;Filter1&lt;/filter-name&gt;
    &lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
    When running this inside JDeveloper, the output is the following:
    08/12/09 17:54:03 *** session id = ac1663b9231c2936edded7df423f9161c223ee0d4246
    08/12/09 17:54:03 *** requested session id = null
    08/12/09 17:54:08 *** session id = ac1663b9231c2936edded7df423f9161c223ee0d4246
    08/12/09 17:54:08 *** requested session id = ac1663b9231c2936edded7df423f9161c223ee0d4246
    08/12/09 17:54:10 *** session id = ac1663b9231c2936edded7df423f9161c223ee0d4246
    08/12/09 17:54:10 *** requested session id = ac1663b9231c2936edded7df423f9161c223ee0d4246
    Each time I reload the page in the browser I get two messages where the session id and the requested session id are equal and the same.
    However, when running the application inside the AS, the output is the following (taken from the opmn/logs/OC4J~my_component~default_island~1):
    08/12/09 17:56:58 *** session id = ac16322030d6da9410e6348449449a4cf1f0e65956cf
    08/12/09 17:56:58 *** requested session id = null
    08/12/09 17:57:01 *** session id = ac16322030d6bc42fa22332e41818aa6ece1fd371361
    08/12/09 17:57:01 *** requested session id = null
    08/12/09 17:57:02 *** session id = ac16322030d60895af4c8cc44aef9ff6e6e3b3fd2e04
    08/12/09 17:57:02 *** requested session id = null
    That is, each time the page is reloaded, a new session is created.
    This problem is actually blocking me since I would like to use the session to store some data used for authentication in the filter (dynamic credentials). As a new session is being created for each access, the data stored in the session is lost and users cannot log on the application.
    Thank you in advance,
    Jorge.
    Edited by: Jorge Pacios on 10-dic-2008 0:31
    Platform information added.

    It couldn't be such difficult.
    I have the jar's, the drivers in, the jdbc url connection as
    url="jdbc:oracle:thin:[USERNAME/PASSWORD]@IP:PORT:SID"/>
    Also I can connect via sqlplus with this string conn.
    The main error I get is
    "Cannot lookup jdbc datasource.
    The process domain was unable to lookup the TX datasource "jdbc/BPELServerDataSource"."

  • Session problem on clustered sun fire with SP6.1

    Hi All,
    I am having a problem with a webapplication on a clustered system.
    In the following I describe the current system setup.
    I will then describe the setup of the web application.
    Following this, I explain the trouble I'm having with sharing sessions in this environment.
    Finally, I pose the key question.
    SYSTEM SETUP:
    Our group has a clustered server setup. I believe the two machines are Sun Fire systems running Solaris 9. Let me know if you need more information concerning the HW.
    To manage the cluster, we use Sun Cluster software. Let me know if you need to know the version number. I do not have it handy. We just recently setup the system (in the past 6 months).
    Also, we have the newest Sun Web Server installed 6.1. We used the default installation. The only thing we changed was the dynamicreloadinterval variable from "-1" to "60".
    WEB APPLICATION:
    We have a fairly simple MVC web application setup, which works well on a single-server system. Essentially, the web application (1) asks for a certain input via a webform, (2) takes this input, and uses it to get information from a database, (3) puts this information into a httpsession attribute, (4) redirects the response to a JSP. The JSP gets the httpsession attribute (populated in step 3) and prints it out.
    So, HTML with form posts to Servlet, Servlet gets data from database and populates a session attribute, JSP gets that session attribute and prints it out.
    Between each transition from HTML, Servlet and JSP, the currently processing server may switch. I.e. the HTML may be served, for instance, by ClusterServer1, the Servlet may be handled, for instance, by ClusterServer2, and the JSP may be served at random by either.
    THE TROUBLE I'M HAVING
    Sometimes, my JSP is able to find the session attribute and print out whatever I put into the session during the Servlet step. However, sometimes, the JSP will print out "null" (the session attribute isn't available to the JSP).
    For the HTML and the JSP, I have the page print out what server it is being served from. Thus, I can tell that the HTML is served from, for instance, ClusterServer1 while JSP is served from, for instance, ClusterServer2. Sometimes, the same server serves both.
    KEY QUESTIONS:
    Why would this be happening?
    How can I have a session stick to the user and be shared across both servers?
    What other information would you need to provide an answer concerning this issue?
    I appreciate your efforts very much!
    Matthias Edrich
    dailysun

    Hi All,
    Hi Elving,
    I read through the documentation and have the following questions:
    (1) It seems that I can share sessions amongst both servers if I
    configure the web server to store sessions in a persistant manner such as in a file or in a database. Is this correct?
    (2) To enable this persistent storage of a session, I would need to change the Session Manager used. Is this correct?
    (3) If yes, I have the choice between the following managers. Please correct me if I have misunderstood the options.
    - PersistentManager: Instead of securing session information
    in memory, this manager saves session information within
    a file on the server in a directory, which I specify within
    sun-web.xml
    - IWSSessionManager: With this manager, I can store sessions
    in a defined database or file on the server.
    - MMapSessionManager: This manager also stores sessions in
    a file on the server
    (4) What is the difference between PersistentManager and
    MMapSessionManager if my web server is running in
    single-process mode?
    (5) If MMapSessionManager is a file-based manager, where do I
    specify to what directory the related file is stored to as I
    do in PersistentManager?
    (6) What are the advantages and disadvantages of
    Persistent/IWS/MMap managers?
    (7) In looking at SessionManagers, am I even barking up
    the right tree? It seems like these would help me share
    sessions across clustered servers.
    (8) Finally, I guess my plan of action would be the following:
    -> Identify what session manager to use
    -> Include a sun-web.xml file in /WEB-INF containing
    the manager-specific info
    -> Reload my web application
    -> done...
    Is this correct?
    Elving, I appreciate your help. Thanks!
    dailysun

Maybe you are looking for

  • Using PS Elements 11 on stand alone pc.

    Hi I have just purchased a boxed copy of PS Elements 11 & Premier Elements 11, to be used on a pc which has no internet connectivity. There is a solid reason why this PC cannot be connected to the internet, it is used by vulnerable adults with autism

  • Visual C++ 6.0 Developer's Studio

    I am taking an on-line class and part of the class is creating C++ programs. The text book and I would assume the class assumes that the user has Windows and can download a version of Visual C++ is there a version for Mac? I have been searching the I

  • How do I change who Notes are "from" in Mail?

    It still lists my new notes as being from the previous owner. I'm new to Macs, so please humor me.

  • Assign Script to Call List Business Context

    Hi, I am battling to find a method to assign an Interactive Script to a call list programatically. the standard method of achiving this is: 1. Transaction CRMD_TM_CLDIST 2. Expand the desired Call List in the left pane 3. Click on the "Business Conte

  • Simple JSP question (newbie)

    Hi all, firstly I hope this is the right place to post this question, if not, please accept my apologies, I am putting together my first set of JSP pages with Tomcat, and so far everything is going very well, but I am having one small problem. I have