1 2 Previous Next 19 Replies Latest reply on Apr 13, 2011 3:11 AM by lvdberg Go to original post
      • 15. Re: RestEasy Put method - Unable to mark for rollback on PersistenceException:
        lvdberg

        Hi,


        .. and in addition, study on the use of the entitymanager and especially queries, because you're mixing up standard SQL with HQL. An update is just setting the right property and after that you merge/flush the object.


        Leo

        • 16. Re: RestEasy Put method - Unable to mark for rollback on PersistenceException:
          olasamuel
          <blockquote>
          _Leo van den Berg wrote on Apr 08, 2011 14:27:_<br/>

          Hi,

          .. and in addition, study on the use of the entitymanager and especially queries, because you're mixing up standard SQL with HQL. An update is just setting the right property and after that you merge/flush the object.

          Leo
          </blockquote>

          Thanks for the response Leo. I am sorry but I am still revolving round the same area. However, I need an answer to the question that I have been asking for many times now. I keep on getting the same error which is:

          HTTP Status 403 - Access to the requested resource has been denied

          type Status report

          message Access to the requested resource has been denied

          description Access to the specified resource (Access to the requested resource has been denied) has been forbidden.
          JBoss Web/2.1.3.GA


          The log file, JBoss or whatever responsible did not give me the error log or explain why I am getting this error. This makes life difficult to figure out where exactly the problem is. To me I feel like this has to do with any security module or that RestEasy cannot access something. Please, note, I am not sure and I don't know RestEasy myself. I have come a long way with Seam but the only thing that has given me more headache than anything is RestEasy. When there is an Error in normal seam, you get to know what causes the error, even if the explanation is not friendly at least you can Google that error message from the log and from there you will get a lead. In this case all you see is just "HTTP Status 403 - Access to the requested resource has been denied", which is not even in the body of Error log file that one can use to get a lead - Hence my assertion all these while and that is why I rely on the advice of an experienced person like you to tell me where exactly is the problem, but trying to implement all the advice you gave me I still get the same error. Please see below my code this time and kindly tell me what again I am doing that is wrong.


          The Interface

          @PUT
               @Path("/updateBalance/{msisdn}/{newBal}")  //I had the /{newBal} because I now want to put it as part of the path that I will put in my URI
               @Produces(MediaType.TEXT_HTML)
               @Transactional
               public SubscriberTopUp updateSubscriberTopUp(@PathParam("msisdn") Long msisdn, @PathParam("newBal") Long newBal);




          The Implementation

          @Transactional
               public SubscriberTopUp updateSubscriberTopUp(@PathParam("msisdn") Long msisdn, @PathParam("newBal") Long newBal) {
                    entityManager = subscriberTopUpHome.getEntityManager();
                    subscriberTopUpHome.clearInstance();
                    if (!checkExists(subscriberTopUp.getMsisdn(), entityManager)){
                         throw new WebApplicationException(Response.Status.NOT_FOUND);
                    }else {
                    //newBal = (long) 12000;
                    subscriberTopUp.setBalance((long) newBal);
                    entityManager.merge(subscriberTopUp);
                    System.out.println("I WAS ABLE TO GET HERE AND UPDATE WITH THE NEW BALANCE" + newBal);
                    entityManager.flush();
                  subscriberTopUpHome.setInstance(subscriberTopUp);
                  subscriberTopUpHome.update();
                  System.out.println("UPDATING...... PLEASE WAIT");
                    }
                    return subscriberTopUpHome.getInstance();


          }


          Thank you
          • 17. Re: RestEasy Put method - Unable to mark for rollback on PersistenceException:
            lvdberg

            Hi Sammy,


            I can't help you further if you stick to your own approach. I already stated that your code is not correct and that you need to study Rest an the peristsency thoroughly.


            I adviced you to take small steps and even suggested some code. As I see now, you're not doing that, so you can't tell me if even the smaller steps work.


            As mentioned by you, the call work, but it is a matter of accessing the DB- The error RestEsay returns is a feature of Rest (look in other thhreads) it should be a server error, but ok. It is basically an internal server error so  something gets wrong INSIDE the call (I expect it to be the Home-component and the way you handle the entityManager)


            Be aware, that Rest out-of-the-box doesn't have access to all of your Seam-context vars. It really is another Session (!!!) So you can't inject all of your conversation-scoped vars and hope that it works.That's the reason for the session annotation (it saves session state, but it's NOT the same session as your logged-in user)


            It is clear to me that you don't have much experience with this technology. Please try the smaller steps first, try to understand what happens and why and tell me what you see if there are any errors.


            Leo

            • 18. Re: RestEasy Put method - Unable to mark for rollback on PersistenceException:
              olasamuel

              Hi Leo,


              Thank you very much for your kind advise and most especially the patience you have taking me through this on a step by step basis making it to look as if you are my passionate teacher.


              I went through the conversation that exist between you and I on this thing again and I will like to inform you that this is now working. Morever, this experience made me to be well versed in RestEasy.


              Once again, thank you. You are a star

              • 19. Re: RestEasy Put method - Unable to mark for rollback on PersistenceException:
                lvdberg

                Hi Sammy,


                It is great that it works now and yes I am a passionate teacher. To help you get your application working what I like most in this job.


                You stated the following in the first entry:




                .... as I am begining to be skeptical about seam at this moment ...

                Hopefully I hava achieved also that you think differently about Seam now !


                Seam is very powerful and you need to know the basics of all the involved technology. That makes it hard to learn.



                I hope that from now on we have a very happy Seamer


                Leo



                1 2 Previous Next