REP-51018 -- cookie method is not working :(

Trying to invoke a simple report from a simple form by using web.show_document()
if I pass the userid=x/y@z then it work fine
if I try to use the cookie method as defined in the OTN whitepaper "Secure Web.Show_Document() calls to Oracle Reports", I am bumping to the REP-51018 error.
Tried the metalink and found primarily 2 documents, one (note#279938) is suggesting using
SYNCHRONIZE; prior to invoking the WEB.SHOW_DOCUMENT(...), which I did - not worked,
then I read the document (#309652.1) which tells that the cookie method will not work if not using fully qualified domain name -- I have a fully qualified domain name and I can see in the browser cookie settings that the domain is set correctly.
I also edited the basejini.htm and basejpi.htm files and added the suggested entries as shown in the same OTN whitepaper (page #9). And recycled the entire iAS server after all the editing (reports.sh, formsweb.cfg, etc).
I can see the cookie is saved on the client browser and the userid is displayed in the JInitiator control window.
FrmReportsInteg0: Debugging true
FrmReportsInteg0: Adding new userid string "zafer/mutlu@jtls5"
FrmReportsInteg0: Default cookie domain: .rolands.com
FrmReportsInteg0: set RW_AUTH10g
FrmReportsInteg0: Arguments: encryptionKey=reports9i; Reports version=RW10g
FrmReportsInteg0: Cookie value for RW10g is: zafer/mutlu@jtls5;1135302256455:30
FrmReportsInteg0: Encoded cookie value is: W3zbSs88ClXKCO9kxqPbyQiyd120sKakxxmhtfgtZoUe4Q==
FrmReportsInteg0: Complete cookie string is: userid=W3zbSs88ClXKCO9kxqPbyQiyd120sKakxxmhtfgtZoUe4Q==
FrmReportsInteg0: Added domain ".rolands.com" to cookie
FrmReportsInteg0: Generated Cookie String: userid=W3zbSs88ClXKCO9kxqPbyQiyd120sKakxxmhtfgtZoUe4Q==; domain=.rolands.com; path=/
liveconnect: JSObject::eval(document.cookie="userid=W3zbSs88ClXKCO9kxqPbyQiyd120sKakxxmhtfgtZoUe4Q==; domain=.rolands.com; path=/")
liveconnect: the url of the applet is http://raptus.rolands.com:7778 and the permission is = false
FrmReportsInteg0: NS Cookie Set
network: Connecting http://raptus.rolands.com:7778/forms/lservlet;jsessionid=0a0a0a2230d8a457f8e558fe43b4b3e5a9b908500738.e38Oc3aQc3ySci0TbheLaNuSah50n6jAmljGr5XDqQLvpAe with proxy=DIRECT
network: Connecting http://raptus.rolands.com:7778/forms/lservlet;jsessionid=0a0a0a2230d8a457f8e558fe43b4b3e5a9b908500738.e38Oc3aQc3ySci0TbheLaNuSah50n6jAmljGr5XDqQLvpAe with cookie "userid=W3zbSs88ClXKCO9kxqPbyQiyd120sKakxxmhtfgtZoUe4Q=="
network: Connecting http://raptus.rolands.com:7778/forms/lservlet;jsessionid=0a0a0a2230d8a457f8e558fe43b4b3e5a9b908500738.e38Oc3aQc3ySci0TbheLaNuSah50n6jAmljGr5XDqQLvpAe with proxy=DIRECT
network: Connecting http://raptus.rolands.com:7778/forms/lservlet;jsessionid=0a0a0a2230d8a457f8e558fe43b4b3e5a9b908500738.e38Oc3aQc3ySci0TbheLaNuSah50n6jAmljGr5XDqQLvpAe with cookie "userid=W3zbSs88ClXKCO9kxqPbyQiyd120sKakxxmhtfgtZoUe4Q=="
The only thing I can see is this line:
liveconnect: the url of the applet is http://raptus.rolands.com:7778 and the permission is = false
if this is the problem how can I fix it?
What is wrong with this cookie method? What I am doing wrong?
Any input is appreciated very much.
Zaf.

Here is the code I am using in a when-button-pressed trigger in the form to invoke the report.
And yes, the javabean USERID_BEAN is created/defined under the CONTROL block, with all the properties as explained in the OTN whitepaper.
thank you.
=================================================
message('Invoking the related report...', ACKNOWLEDGE);
message(' ', NO_ACKNOWLEDGE);
DECLARE
rep_url varchar2(2000);     
user_name varchar2(40);
passwd varchar2(40) ;
connectstring varchar2(20) ;
BEGIN
user_name := LOWER(get_application_property(username));
passwd := LOWER(get_application_property(password));
connectstring := LOWER(get_application_property(connect_string));
rep_url:='/reports/rwservlet?&envid=jtlsDDS&&report=readme.rdf'
||'&desformat=htmlcss&destype=cache&userid=';
-- Write log messages to the Forms JInitiator console. The next line must
-- be disabled before running this code in any production environment
set_custom_property('CONTROL.USERID_BEAN',1,'WRITE_LOGOUTPUT','true');
-- set userid in encrypted cookie before calling Web.Show_Document()
set_custom_property('CONTROL.USERID_BEAN',1,'ADD_USERID',
user_name||'/'||passwd||'@'||connectstring);
-- writing the cookie
set_custom_property('CONTROL.USERID_BEAN',1,'WRITE_USERID_COOKIE','10g');
-- Add the next line to correct REP 51018 error
SYNCHRONIZE;
WEB.SHOW_DOCUMENT(rep_url,'_blank');
END;

Similar Messages

  • HT1677 In safari browser cookies is working fine. But when I add the browser url to the screen then the cookies concept is not working. In safari setting cookies is always open only. Can you please provide any information regarding to this?

    In safari browser cookies is working fine. But when I add the browser url to the screen then the cookies concept is not working. In safari setting cookies is always open only. Can you please provide any information regarding to this?

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings and disables most add-ons (extensions and themes).
    ''(If you're using an added theme, switch to the Default theme.)''
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu by clicking on the '''Restart with Add-ons Disabled...''' menu item:<br>
    [[Image:FirefoxSafeMode|width=520]]<br><br>
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.
    Thank you.

  • ExportAsFDF javascript method is not working with Reader 10.1.1

    Hi,
    I have pdf document in which I have applied all Extendend Reader Rights. And now when I am trying to exports alll annotation in fdf with Reader 10.1.1 then it is faling to export. However it is working fine with Reader 10.0.0. Looks like this is broken in later version of 10.0.0.
    Please let me know if any alternative solution is there to export all annotation in fdf file thru code.
    Regards,
    Arvind

    I would open a formal support ticket with our developer support folks.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Sun, 27 Nov 2011 22:48:35 -0800
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: exportAsFDF javascript method is not working with Reader 10.1.1
    exportAsFDF javascript method is not working with Reader 10.1.1
    created by arvindg007<http://forums.adobe.com/people/arvindg007> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4049525#4049525

  • How do I print in B&W now that I have lion? The whole "open in preview" method is not working. Thanks

    Subject says it all.....The whole "open in preview" method is not working. Any ideas or solutions would be appreciated. Thanks

    What kind of printer do you have? Have you looked at their PDEs to see if there are any settings for color/b&w?
    How is the "open in Preview" not working? Please provide some details.

  • Instance Dependent Public Method is not working for Workflow

    Hello Experts,
    I have made Custom class for  a workflow. This class is triggering the WF fine but the problem is while trying to execute a WF task which contains a Instance Dependent & Public  method its not working , the WF task is not processing though I'm passing the instance of the class  properly from WF to WF task . When I'm changing the method to Static & Public then the workitem is executing perfectly. Can you please help & suggest the way to find the problem ?
    Thanks & Regards ,
    Jeet

    Are you absolutely sure that you have the instance of the object in the workflow container? Open the technical log the see if the object instance is there - or is the container element initial (or "not set")?
    yes it is instantiated properly no error over there.
    What about if you test the method directly in SE24 (as an instance method)? Is it working then? If you can make it work in SE24 as an instance method and you are sure that the instance exists in the workflow,
    I have checked the class in a stand alone run in this case also it runs fine as before.
    The obvious question of course is that have you implemented the IF_WORKFLOW interface methods (the two first ones).
    it is coded like below
    BI_PERSISTENT~FIND_BY_LPOR
      create object result
          type
            (lpor-typeid)
          exporting
            ip_key = lpor-instid.
    CONSTRUCTOR
       me->m_KEY    = ip_key.
       me->m_por-catid = 'CL'.
       me->m_por-typeid = CL_ZZZ'.
       me->m_por-instid = me->m_key
    BI_PERSISTENT~LPOR
    result =  me->m_por.
    Main confusion is Method is working only if declared STATIC & PUBLIC  but not for the INSTANCE DEPENDENT & PUBLIC.

  • Auto tab focus method is not working in iOS devices please share the ideas why its not working?

    Auto tab focus method is not working in iOS devices. Please share the idear i am facing this issue while developing code for devices.

    Hi there,
    I can confirm this bug.
    Not sure if this info is relevant, but this is my experience:
    I am on the FIDO network, and so are two other people I know.
    We all tried blocking numbers, and calls ring right through. Text messages are blocked successfully. (never tried facetime)
    I also tried a ROGERS device running IOS7, and was successfully able to block my phone call from ringing through. HOWEVER, my call was forwarded to their voicemail, I was able to leave a voicemail for the person, and they did get an alert that they had a new voicemail.
    I have not yet had a chance to test this on Bell, Telus, or any other carriers.
    Spoke to Apple, and they advised me to do a hard reset (hold both buttons to shut off and reboot the phone), and if that fails to do an iOS restore.
    I have yet to try this, but hopefully someone will have a better solution.

  • Repaint() method is not working in MAC IE

    Hi All
    why repaint method is not working in MAC IE ? What i am doing is in one class which is inheriting Canvas class getting the keybord input then adding it to main applet.
    Please help me i am trying it for whole week and i couldn't find any solution. I didn't put my code but if anyone is willing to help me i can post it.
    Thanks in advancs
    Shan

    Hi
    Thanks for your reply. Actually i wrote simple applets and those are working well.
    So i did debug the code and i found that when i am running the following code in Apple MAC IE, nothing is happening in handleEvent method. Especially it is not going into the if statement (if (evt.id==401)). here i am checking for KEY_PRESS. I also tried with keyDown method but same problem in MAC IE.
    I am pasting the code that is giving me problem.
    import java.awt.*;
    import java.applet.*;
    public class testApplet extends Applet
    public void init()
    setLayout(new BorderLayout());
    editableArea = new EditableArea();
    editableArea.setBackground(Color.yellow);
    add("Center", editableArea);
    EditableArea editableArea;
    import java.awt.*;
    public class EditableArea extends Canvas
    String s = "";
    public boolean handleEvent(Event evt)
    if (evt.id==401)
    if(evt.key >= 32 && evt.key <= 255)
    char c = (char)evt.key;
    s = s + c;
    repaint();
    return super.handleEvent(evt);
    public void paint( Graphics g )
    g.setColor(Color.blue);
    g.drawString( s,5,15);
    --------------------------------------------------------------------

  • Draw method is not working

    Why the drawLine() is working only inside the paint method??
    BufferedImage image = new BufferedImage(800,500,BufferedImage.TYPE_INT_ARGB);
         Graphics2D g = (Graphics2D)image.getGraphics();
    public void paint(Graphics g)
                   g.setColor(Color.black);
                             //Here, the drawLine() method works
                   g.drawLine(50,0,50,150);
    public void paintX(Graphics g,Point c)
                        //Here, the drawLine() method does not work
                        g.setColor(Color.black);
                   g.drawLine(0-e,0-e,50-e,50-e);
                   g.drawLine(0-e,50-e,50-e,0-e);
                   repaint();
         }

    er, unless you're using JDK 1.5 and it introduces methods I know nothing about, as far as I know
    public void paintX(..) is not a AWT or Swing method. Thus it will never be invoked unless you call it.

  • Method "show_doc_meta_data" not working for me in "cl_gui_ecl_2dviewer "

    Hello all,
    I want to show the meta-data within an image, when showed with the ECL-Viewer.
    I performed the following steps in my ABAP-Code, but it is not working.
    Creating an object of the class "cl_gui_docking_container"
    Creating an object of the class "cl_gui_ecl_2dviewer" with a refernece of the container
    Calling method "create_toolbar"
    Calling method "open_document" with the path to the file and the file_type
    Up to this point everything works without any problem.
    But now I want to show my created META-DATA of the image, which I have added with the method "set_doc_meta_data".
    After calling the method "show_doc_meta_data" the appended data is not visible on my image.
    What going wrong in the method of my coding?
    I am grateful for any help.
    Best regards
    Christian

    Hi Christian
    Did you solve this issue?
    I'm trying to use Badi  DOCUMENT_ECL01 to insert watermarks on some DMS documents but it's not working, maybe you could give me some advice.
    Regards
    Daniel

  • Secondary method is not working

    Hello,
    I have a problem with my secondary method. I created a method Z_Call_ME23N for my purchase order release workflow and added it as a secondary method to my user decision step.
    In testing in swo1 is no problem. Also the authorization test in SU53 are ok.
    But when I try to open my workitem a message box comes up: 'Error when starting submethod'.
    How can I check it what I have done wrong?
    Thanks for your help,
    Christoph

    Hi Martin,
    thanks for your answer.
    I have BUS2012 in my WF container, and it is delegated to ZBUS2012 (so I was wrong to say it is ZBUS2012).
    I also have the BO in the decision step (wondered if I was wrong - I made a copy of the standard decision task to add my own container element in the copy - this is the task I am now using).
    So actually my bindings for this step is:
    BUS2012 (delegated to ZBUS2012)  -->  BUS2012
    is that right?
    Unfortunatly it is still not working.
    I also tried to clear the buffer (as it says so in others posts), checked the authorizations,etc.
    Thanks a lot for you ideas, it is still my first workflow and I don´t know where else I could take a look to get some help.
    Christoph
    Edited by: Christoph on Jan 30, 2008 3:23 AM

  • 'NAVIGATE_ABSOLUTE' method is not working in UWL

    We are working on Portal 7.0.
    Recently We have upgraded from SP 13-0 To 13-5.
    After this upgradation We are facing some problems, following is the scenario:
    1.     We have a ABAP Web DynPro Application say 'A', which has button "View Details".
    2.     On Clicking of "View_Details"  We navigate to other ABAP Web DynPro Application say 'B' .
         This was done using the 'NAVIGATE_ABSOLUTE' method of the 'IF_WD_PORTAL_INTEGRATION'.
    3.     Now The Same Application 'A' is being send as the Workitem to Approver's inbox.
    4.     Approver also was able to click on 'View_Details' button and  Application 'B' used to call using 'NAVIGATE_ABSOLUTE'.
    5.     After upgradation, Point 2 is working fine. but point 4 is not working i.e. 'NAVIGATE_ABSOLUTE' functionality is not working when the application is send as workitem.
    Please guide us for the above problem. Points assured for best solution.

    Hi
    Thanks for your reply. Actually i wrote simple applets and those are working well.
    So i did debug the code and i found that when i am running the following code in Apple MAC IE, nothing is happening in handleEvent method. Especially it is not going into the if statement (if (evt.id==401)). here i am checking for KEY_PRESS. I also tried with keyDown method but same problem in MAC IE.
    I am pasting the code that is giving me problem.
    import java.awt.*;
    import java.applet.*;
    public class testApplet extends Applet
    public void init()
    setLayout(new BorderLayout());
    editableArea = new EditableArea();
    editableArea.setBackground(Color.yellow);
    add("Center", editableArea);
    EditableArea editableArea;
    import java.awt.*;
    public class EditableArea extends Canvas
    String s = "";
    public boolean handleEvent(Event evt)
    if (evt.id==401)
    if(evt.key >= 32 && evt.key <= 255)
    char c = (char)evt.key;
    s = s + c;
    repaint();
    return super.handleEvent(evt);
    public void paint( Graphics g )
    g.setColor(Color.blue);
    g.drawString( s,5,15);
    --------------------------------------------------------------------

  • LSMW Recording method is not working for transaction code FBL5N

    Hi Experts,
    I am trying to prepare LSMW to create dispute cases for customer line items through LSMW Recording method. When i was trying to do through SHDB Recording its working properly through Program. But its not working through LSMW Recording method means its not executing to next screen, immediately its displaying session completed screen.
    Please do let me know any soution for this.
    thanks,
    Sriram.

    Hi Sriram,
    If my memory serves me correctly, a BDC will not work correctly with a list. This is mentioned somewhere in the SAP help pages.
    Now I am not familiar on how to create dispute cases but using FBL5N does not sound to me the way to go.  I assume that you use FBL5N in order to determine to which documents to link the dispute to, however you should be able to get the requested info from the BSID/BSAD tables.
    Also in case you want to change the customer line item in the accounting document, check the data transfer workbench (SXDA) as SAP delivers a standard program for this.
    Kind regards,
    Robert
    Edited by: RJ. Schamhart on Jan 14, 2011 12:35 AM
    Edited by: RJ. Schamhart on Jan 14, 2011 12:43 AM

  • PortletBackingContext.SetVisible() method is not working in case of wsrp

    Hi ,
    I have a porlet and associated a backfile to that portlet and based on some conditions,
    I set the portletBackingContext.setVisible(false) in the prerender method and its working fine on local.
    Now i consumed the portlet and while rendering , i got the below error.
    java.lang.UnsupportedOperationException: The method [setVisible] is not supported. at com.bea.wsrp.producer.adapter.context.backing.SimplePortletBackingContext.setVisible(SimplePortletBackingContext.java:462) at com.pge.csis.myenergy.backing.RecommendProgPortletBacking.preRender(RecommendProgPortletBacking.java:49) at com.bea.wsrp.producer.adapter.context.backing.BackingFileAdapter.prepareBackingFiles(BackingFileAdapter.java:67) at com.bea.wsrp.producer.adapter.context.PortalContextAdapter.preInvokeRender(PortalContextAdapter.java:239) at com.bea.wsrp.producer.handlers.markup.MarkupServiceHandler.doGetMarkup(MarkupServiceHandler.java:366) at com.bea.wsrp.producer.handlers.markup.MarkupServiceHandler.doService(MarkupServiceHandler.java:228) at com.bea.wsrp.producer.handlers.AbstractServiceHandler.service(AbstractServiceHandler.java:68) at com.bea.wsrp.producer.container.ProducerEndPoint.processNow(ProducerEndPoint.java:243) at com.bea.wsrp.producer.wsee.ProducerEntryPoint.handleResponse(ProducerEntryPoint.java:87) at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:287) at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator.java:271) at weblogic.wsee.ws.dispatch.server.ServerDispatcher.callHandleResponse(ServerDispatcher.java:341) at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:189) at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80) at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66) at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44) at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:285) at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:169) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.bea.portal.tools.servlet.http.HttpContextFilter.doFilter(HttpContextFilter.java:60) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.bea.wsrp.producer.WsrpLocalProxyFilter.doFilter(WsrpLocalProxyFilter.java:72) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilter.java:336) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3502) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2186) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2092) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    So I have the following code in the postInvoke of a markup and and blocking internaction interceptors:
         @Override
         public PostInvoke postInvoke(IGetMarkupRequestContext requestContext,
                   IGetMarkupResponseContext responseContext) {
              BookBackingContext bpContext = BookBackingContext.getBookBackingContext(requestContext.getHttpServletRequest());
              PageBackingContext pbContext = PageBackingContext.getPageBackingContext(requestContext.getHttpServletRequest());
              PortletBackingContext porBackContext = PortletBackingContext.getPortletBackingContext(requestContext.getHttpServletRequest());
              return PostInvoke.CONTINUE_CHAIN;
         @Override
         public PostInvoke postInvoke(IBlockingInteractionRequestContext requestContext,
                   IBlockingInteractionResponseContext responseContext) {
              BookBackingContext bpContext = BookBackingContext.getBookBackingContext(requestContext.getHttpServletRequest());
              PageBackingContext pbContext = bpContext.getActivePageBackingContext();
    PortletBackingContext porBackContext = PortletBackingContext.getPortletBackingContext(requestContext.getHttpServletRequest());
              return PostInvoke.CONTINUE_CHAIN;
    and in debug the bpContext, pbContext, and porBackContext are all null no matter which Interceptor is firing. Based on this, I am unclear about your comment that "The WLP WSRP interceptors actually do have the same context as a proxy portlet's backing file for the performBlockingInteraction, handleEvents and getMarkup WSRP operations". Am I implementing the wrong phase? Please advise. If I can get a handle on this, it will really help us out with our issues.

  • Finalize method is not working

    class Abc
         protected void finalize() throws Throwable
              System.out.println("Inside finalize");
            super.finalize();
    public class Finalize1
         public static void main(String args[])
              Abc a=new Abc();
              System.gc();
    }"Inside finalize" inside the finalize method is not getting printed.When the code ends won't the objects get garbage collected when the program ends.So shouldn't that statement get printed?

    a=null will workAs the API for System.gc() states:
    Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.
    Note the language: "suggests", "a best effort". This is not the same as a guarantee that the object will be collected and its finalize run.

  • Repaint() method 's not work but paint(getGraphics()) does, why?

    I've just read the following code ( in the Core Java 2 advance features vol 2 book):
      import java.awt.*;
      import java.awt.event.*;
       import java.awt.geom.*;
       import java.util.*;
       import javax.swing.*;
          Shows an animated bouncing ball.
      public class Bounce
         public static void main(String[] args)
            JFrame frame = new BounceFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.show();
         The frame with canvas and buttons.
      class BounceFrame extends JFrame
            Constructs the frame with the canvas for showing the
            bouncing ball and Start and Close buttons
         public BounceFrame()
            setSize(WIDTH, HEIGHT);
            setTitle("Bounce");
            Container contentPane = getContentPane();
            canvas = new BallCanvas();
            contentPane.add(canvas, BorderLayout.CENTER);
            JPanel buttonPanel = new JPanel();
            addButton(buttonPanel, "Start",
               new ActionListener()
                     public void actionPerformed(ActionEvent evt)
                        addBall();
            addButton(buttonPanel, "Close",
               new ActionListener()
                     public void actionPerformed(ActionEvent evt)
                       System.exit(0);
            contentPane.add(buttonPanel, BorderLayout.SOUTH);
            Adds a button to a container.
            @param c the container
            @param title the button title
            @param listener the action listener for the button
         public void addButton(Container c, String title,
            ActionListener listener)
            JButton button = new JButton(title);
            c.add(button);
            button.addActionListener(listener);
            Adds a bouncing ball to the canvas and makes
            it bounce 1,000 times.
         public void addBall()
            try
               Ball b = new Ball(canvas);
               canvas.add(b);
               for (int i = 1; i <= 1000; i++)
                  b.move();
                  Thread.sleep(5);
            catch (InterruptedException exception)
         private BallCanvas canvas;
         public static final int WIDTH = 450;
         public static final int HEIGHT = 350;
        The canvas that draws the balls.
    class BallCanvas extends JPanel
            Add a ball to the canvas.
            @param b the ball to add
       public void add(Ball b)
           balls.add(b);
        public void update(Graphics g) {
             super.update(g);
             System.out.println("Test");
        public void paintComponent(Graphics g)
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D)g;
          for (int i = 0; i < balls.size(); i++)
             Ball b = (Ball)balls.get(i);
             b.draw(g2);
            // System.out.println("Test");
        private ArrayList balls = new ArrayList();
        A ball that moves and bounces off the edges of a
       component
    class Ball
            Constructs a ball in the upper left corner
            @c the component in which the ball bounces
        public Ball(Component c) { canvas = c; }
           Draws the ball at its current position
           @param g2 the graphics context
        public void draw(Graphics2D g2)
           g2.fill(new Ellipse2D.Double(x, y, XSIZE, YSIZE));
          Moves the ball to the next position, reversing direction
          if it hits one of the edges
       public void move()
          x += dx;
          y += dy;
           if (x < 0)
              x = 0;
              dx = -dx;
         if (x + XSIZE >= canvas.getWidth())
             x = canvas.getWidth() - XSIZE;
              dx = -dx;
           if (y < 0)
             y = 0;
              dy = -dy;
           if (y + YSIZE >= canvas.getHeight())
              y = canvas.getHeight() - YSIZE;
              dy = -dy;
           //canvas.paint(canvas.getGraphics());//this would OK.
           canvas.repaint();//This not work, please tell me why?
        private Component canvas;
        private static final int XSIZE = 15;
       private static final int YSIZE = 15;
       private int x = 0;
       private int y = 0;
       private int dx = 2;
       private int dy = 2;
    }this program create a GUI containing a "add ball" button to creat a ball and make it bounce inside the window. ( this seems to be stupid example but it is just an example of why we should use Thread for the purpose ).
    Note: in the move() method, if i use canvas.repaint() then the ball is not redrawn after each movement. but if i use canvas.paint(canvas.getGraphics()) then everythings seem to be OK.
    Another question: Still the above programe, but If I create the ball and let it bounce in a separate thread, then canvas.repaint() in the move method work OK.
    Any one can tell me why? Thanks alot !!!

    I don't know why the one method works. Based on my Swing knowledge neither method should work. Did you notice that the JButton wasn't repainted until after the ball stopped bouncing. That is because of the following code:
    for (int i = 1; i <= 1000; i++)
        b.move();
        Thread.sleep(5);
    }This code is attempting to move the ball and then sleep for 5 milliseconds. The problem with this code is that you are telling the Event Thread to sleep. Normally painting events are added to the end of the Event Thread to allow for multiple painting requests to be combined into one for painting efficiency. When you tell the Thread to sleep then the GUI doesn't get a chance to repaint itself.
    More details about the EventThread can be found in the Swing tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
    This explains why the button isn't repainted, but it doesn't explain why the ball bounces. I don't know the answer to this for sure, but I do know that there is a method called paintImmediately(...) which causes the painting to be performed immediately without being added to the end of the Event Thread. This means the painting can be done before the Thread sleeps. Maybe the canvas.paint(....) is somehow invoking this method.
    When you click on the button this code is executed in the EvWell in Swing, all GUI painting is done on the Event Thread

Maybe you are looking for

  • Unable to Deploy a Webservice.

    Hello All, I created a java bean and put the implemented code in some of the methods etc. ( By the way the code is generated using a WSDL using the SAP Netweaver libraries ) Now when I attempt to actually create the webservice out of the implemented

  • Is it possible to start a recording from source code?

    Hi everybody! I'm currently using JProfiler in combination with JUnit tests to collect resource consumption metrics of features in our product. A homemade JUnit runner starts and stops the JProfiler recording and parses the recorded data. It then com

  • Bad update ?!?

    I just installed iphoto on my mac mini and it was working okay until I've installed the new update (5.0.4). Now it's impossible to view my photos fullscreen. There is a black frame everywhere around my photos and the photos don't look good anymore. I

  • Unable to update - Download error (49)

    Indesign and Bridge happily update, but Photoshop and Premiere continually get this error. Connected to the internet and no issues on any other site or transferring large files.. Any ideas?

  • View this link and solve my issue PLS!

    Since no one has answered my question, I am providing a link that may shed some light on my issue. When the link opens the four panels will animate. What I don't want is for them to animate at the same time. What I do want is to animate in a sequence