This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes SecurityException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "SecurityException" Watch "SecurityException" New topic
Author

SecurityException

Maria Lepschy
Ranch Hand

Joined: Jan 12, 2004
Posts: 78
Hi all,
I am now by implementing the locking.
My instructions:
// Releases the lock on a record. Cookie must be the cookie
// returned when the record was locked; otherwise throws SecurityException.
public void unlock(long recNo, long cookie)throws SecurityException;
My problem is that by testing with multiple clients, I receive SecurityException ( I have not prevented deadlocks yet) Hwo can help me?
My lock method:

[Andrew: put the source code between [code] and [/code] UBB tags (not that it really helped :roll: )]
[ April 05, 2004: Message edited by: Andrew Monkhouse ]
[ April 05, 2004: Message edited by: Andrew Monkhouse ]
Maria Lepschy
Ranch Hand

Joined: Jan 12, 2004
Posts: 78
[Andrew: Removed the code from this section]
[ April 05, 2004: Message edited by: Andrew Monkhouse ]
[ April 06, 2004: Message edited by: Maria Lepschy ]
Don Wood
Ranch Hand

Joined: Dec 05, 2003
Posts: 65
Hi Maria,
Please remove one of these methods from this post since we should not be posting this much code. The locking portion of the evaluation is worth too many points to be putting it all out for everyone to see.
I suspect that the setLockCookie and getLockCookie methods are the problem. The cookie is in the lockedRecords. Why is it also being put somewhere else? How does getlockCookie know what value is to be returned since it has no parameters? My suggestions are:
  • In the lock method, remove the line

  • In the unlock method, replace if(cookie == getLockCookie()){

  • with something like this:
  • Remove the getLockCookie() and setLockCookie() methods from your code.


  • In the future, please use the UBB buttons to place you code in code blocks to make it more readable.
    Also, I think you should take a look at the
    Sun coding conventions. I know that some people disagree with some of the coding convention choices that Sun has made but for the purposes of this exam it is probably a good idea to follow them closely. The General Considerations portion of the score will be affected by your coding style.
    [ April 04, 2004: Message edited by: Don Wood ]
    Maria Lepschy
    Ranch Hand

    Joined: Jan 12, 2004
    Posts: 78
    Hi Don,
    Yes, you are rigth. I will try with your suggestion.
    Many, many thanks,
    Maria
    Maria Lepschy
    Ranch Hand

    Joined: Jan 12, 2004
    Posts: 78
    Hi Don,
    Can you tell me how I can remove the code? Or can you please remove it?
    Now I am going to work, so that if it is one possibility to remove it, I can remove it after 10 hours.
    Sorry for this inconvenience.
    Regards,
    Maria
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11432
        
      85

    Hi Maria,
    Can you tell me how I can remove the code? Or can you please remove it?

    I have edited your post to put the code between [code] and [/code] UBB tags. Doing this ensures that indenting is preserved, which makes the code easier to read.
    When you are writing your post, there are a number of buttons just below the edit pane, which will insert the tags for you, so you don't have to remember what they are.
    If you would like to edit your original post so that you can see what I have done, you can click on the button that is just above your post.
    (That is also how you can remove your code - by editing your previous posts).
    I have also removed some of your posted code, as we do not allow major sections of the assignment to be posted in this forum (as Don mentioned). The locking code is worth 20% of the assignment, and this is far too much to post in total.
    There are multiple reasons for this policy:
  • Sun do not allow you to share your assignment or a solution to the assignment with others.
  • You have spent time and effort getting your solution right. It would not be right for someone else to just copy your solution without working it out for themselves.
  • If someone did get awarded the SCJD certification after copying your code, and were then given employment because they had that certification, the employer would probably find that the employee cannot actually do the work. Which makes the perceived value of this certificate decrease.
  • If people post too much code, then Sun may, in the future, request that we do not allow any SCJD code to be posted.

  • This policy is described in the question "What is the policy on posting questions I saw on the exam / details of how to do the assignment?" in the JavaRanch SCJD FAQ.
    Regards, Andrew
    [ April 05, 2004: Message edited by: Andrew Monkhouse ]

    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Maria Lepschy
    Ranch Hand

    Joined: Jan 12, 2004
    Posts: 78
    Hi Andrew,
    Thank you for the explication, I haven't seen how I can change my original post- it is very helpful.
    Thank you also for doing this.
    Regards,
    Maria
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: SecurityException