Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8025

Re: JSF/JPA problem

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: JSF/JPA problem
Date Wed, 14 Sep 2011 10:36:25 -0700
Organization A noiseless patient Spider
Lines 57
Message-ID <j4qomr$ci6$1@dont-email.me> (permalink)
References <j4nvr9$4ld$1@dont-email.me> <VZObq.20744$oz6.19581@newsfe11.iad> <XcPbq.17471$CQ4.165@newsfe09.iad> <j4om1r$a40$1@dont-email.me> <EWRbq.10526$EP3.6864@newsfe05.iad> <j4or6k$ctb$1@dont-email.me> <MqTbq.18258$YA4.3466@newsfe14.iad>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 14 Sep 2011 17:36:27 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="12870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19laWC9n4yLfzOTwRfRTzX2CrxvkMAee5c="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2
In-Reply-To <MqTbq.18258$YA4.3466@newsfe14.iad>
Cancel-Lock sha1:FoXJsD+usJBsYNxjfvUVxOumuro=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8025

Show key headers only | View raw


On 9/13/2011 6:28 PM, Arved Sandstrom wrote:

> When I call my session bean from my JSF managed bean, I inject it with
> @EJB. You're not doing that


Yes, that was it exactly.  I was pretty confused by all the different 
types of injection.  There's @ManagedProperty, @EJB, @Resource and 
@Inject at least, off the top of my head.  Looks like I'm going to have 
to study up and make certain I understand when it's appropriate to use each.

FYI, I was confused because one of my texts does a sneaky thing.  They 
annotate a class like this (not syntax checked):


@Named("user")
@SessionScoped
@Stateful
public class UserBean {

   @PersitenceContext
   private EntityManager em;

   public String getName() {...} // called from JSF view

   ... // other methods also called from JSF view
   ... // uses container manged transactions herein too

}

Which was kinda confusing how they set up this class.  However, the 
source listing, which occurs later, has an important detail.


import javax.ejb.Stateful;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named("user")
@SessionScoped
@Stateful
public class UserBean { ...

Yeah, after 518 pages of using javax.faces.bean.SessionScoped, they 
switch to the javax.enterprise.context one without calling out the 
change.  I probably should have caught that, but it's a lot to digest 
all at once.


I think we can declare this problem solved (and also PEBCAK).  @EJB for 
injection worked.  Incidentally, I also removed the em.flush() from my 
bean and the data was persisted anyway, which is what should have been 
happening all along.  Data should be persisted on a commit(), which 
happens at the end of any container manged transaction, so I was 
confused about that too.  So actually that's two mysteries solved.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

JSF/JPA problem markspace <-@.> - 2011-09-13 09:19 -0700
  Re: JSF/JPA problem Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-13 17:24 -0300
    Re: JSF/JPA problem Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-13 17:40 -0300
      Re: JSF/JPA problem markspace <-@.> - 2011-09-13 15:38 -0700
        Re: JSF/JPA problem markspace <-@.> - 2011-09-13 17:06 -0700
          Re: JSF/JPA problem Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-13 22:28 -0300
            Re: JSF/JPA problem Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-13 22:31 -0300
              Re: JSF/JPA problem markspace <-@.> - 2011-09-13 19:27 -0700
                Re: JSF/JPA problem Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-14 05:59 -0300
            Re: JSF/JPA problem markspace <-@.> - 2011-09-14 10:36 -0700
              Re: JSF/JPA problem Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-14 17:51 -0300
      Re: JSF/JPA problem markspace <-@.> - 2011-09-13 16:12 -0700

csiph-web