myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard W. Smith, Jr." <smithh032...@gmail.com>
Subject Re: MyFaces 2.1.9 / Glassfish 3.1.2.2: Migrating to CDI Managed Beans
Date Sat, 17 Nov 2012 14:47:54 GMT
Thanks Jose (a.k.a. maxtorzito <maxtorzito@gmail.com>, I know you from
PrimeFaces forums).

TomEE is next on the to-do list. :)


On Sat, Nov 17, 2012 at 9:00 AM, José Luis Cetina <maxtorzito@gmail.com>wrote:

> Hi let me tell you my experience.
> I migrate from managedbeans + mojarra + glassfish to myfaces + WELD + TomEE
> and now I'm so happy to did so.
>
> Now my app use:
> -Apache TomEE 1.5
> -Apache MyFaces
> -Apache CODI
> -Primefaces 3.4.2
> -Primefaces Mobile
> -Primefaces Extensions 0.6.1
> -PrettyFaces  3.3.3
> -OpenJPA 2.2
> -EJB
> -JdbcRealm for login (my own query for login using any tables in my mysql
> database).
> -WELD
> -And all the excellent Apache stuff
> Etc...
>
> And I'm so happy with this change, the this are more easy to config, use
> more standards, is very very fast, use myfaces and with this you can forget
> speed issues.
>
> This project is a maven project, in netbeans 7.2.
>
> If you need some example project I can send you a simple example.
>
> I enhance my jpa entities so easy with maven plugin, run in every IDE and
> other stuff that are excellents
>
> Seriously if have the opportunity and time to migrate do it now you will be
> happy.
>
> And one tip maybe you don't need CODI at the beginning. CODI can help in
> many things like type-safe navigations, security, validations,  prerenders
> events and so on.
>
> Al most forget to tell you the easy Way for drop your jars in lib folder
> and with this decrease your war size, I remember in glassfish sometimes it
> wasn't easy.
>
> I recommend you to be alert for changes and fixes in TomEE, because they
> fix issues and update in they trunk svn everyday.
>
> Please suscribe to TomEE mailing lists. Rommain is a great commiter guy who
> help immediately with other people.
>
> I hope this experience can help you.
>
> SCJA. Jose Luis Cetina
> maxtorzito
>  El 17/11/2012 06:06, "Mark Struberg" <struberg@yahoo.de> escribió:
>
> > Hi!
> >
> > If you look for docs, here they are:
> >
> > http://tomee.apache.org/documentation.html
> >
> > LieGrue,
> > strub
> >
> >
> >
> >
> >
> >
> >
> > >________________________________
> > > From: "Howard W. Smith, Jr." <smithh032772@gmail.com>
> > >To: Mark Struberg <struberg@yahoo.de>
> > >Cc: MyFaces Discussion <users@myfaces.apache.org>
> > >Sent: Saturday, November 17, 2012 1:02 PM
> > >Subject: Re: MyFaces 2.1.9 / Glassfish 3.1.2.2: Migrating to CDI
> Managed
> > Beans
> > >
> > >
> > >Great, thanks Mark. I did download TomEE, and looking at examples
> > (referenced on same page as TomEE downloads) and I'm looking at this
> guide
> > below to ensure I am injecting beans correctly.
> > >
> > >
> > >http://docs.jboss.org/weld/reference/1.0.0/en-US/html/injection.html
> > >
> > >
> > >
> > >On Sat, Nov 17, 2012 at 6:50 AM, Mark Struberg <struberg@yahoo.de>
> wrote:
> > >
> > >If you have troubles starting tomee then don't hesitate to ping us via
> > IRC on irc.freenode.net in channel #openejb (tomee s hosted there).
> > >>
> > >>LieGrue,
> > >>strub
> > >>
> > >>
> > >>
> > >>>________________________________
> > >>
> > >>> From: "Howard W. Smith, Jr." <smithh032772@gmail.com>
> > >>>To: MyFaces Discussion <users@myfaces.apache.org>; Mark Struberg
<
> > struberg@yahoo.de>
> > >>>Sent: Saturday, November 17, 2012 12:06 PM
> > >>>Subject: Re: MyFaces 2.1.9 / Glassfish 3.1.2.2: Migrating to CDI
> > Managed Beans
> > >>
> > >>>
> > >>>
> > >>>Mark,
> > >>>
> > >>>
> > >>>Thank you for the response.
> > >>>
> > >>>
> > >>>1. Yes, I did add an 'empty' beans.xml to WEB-INF as advised by many
> > places on the internet, and the app starts up successfully. I did 'not'
> > have beans.xml added to META-INF, since all of my code is in the web app
> (I
> > created no JARs of my own). I just added beans.xml to META-INF (while
> > beans.xhtml already exists in WEB-INF), attempted to start glassfish,
> and I
> > get the following error:
> > >>>
> > >>>
> > >>>INFO: WELD-000900 1.1.8 (Final)
> > >>>SEVERE: Exception while invoking class org.glassfish.weld.WeldDeployer
> > load method
> > >>>java.lang.NullPointerException
> > >>>at
> >
> org.glassfish.weld.BeanDeploymentArchiveImpl.handleEntry(BeanDeploymentArchiveImpl.java:504)
> > >>>at
> >
> org.glassfish.weld.BeanDeploymentArchiveImpl.collectJarInfo(BeanDeploymentArchiveImpl.java:482)
> > >>>at
> >
> org.glassfish.weld.BeanDeploymentArchiveImpl.populate(BeanDeploymentArchiveImpl.java:422)
> > >>>
> > >>>
> > >>>I'm sure the error above means that my web app does not need 'empty'
> > beans.xml in META-INF (and WEB-INF), so I will remove beans.xml from
> > META-INF.
> > >>>
> > >>>
> > >>>2. Yes, all CDI beans (accessed via EL) have @Named annotation, and
I
> > am using @Inject along with Qualifiers (for classes that extend ancestor
> > classes). Below are notes from what I did/completed yesterday for this
> > migration:
> > >>>
> > >>>
> > >>>Migrate from JSF Managed Beans to CDI Managed Beans
> > >>>
> > >>>
> > >>>Replace
> > >>>javax.faces.bean.ManagedBean
> > >>>with
> > >>>javax.inject.Named
> > >>>
> > >>>
> > >>>replace
> > >>>javax.faces.bean.ManagedProperty
> > >>>with
> > >>>javax.inject.Inject
> > >>>
> > >>>
> > >>>replace
> > >>>javax.faces.bean.SessionScoped
> > >>>with
> > >>>javax.enterprise.context.SessionScoped
> > >>>
> > >>>
> > >>>replace
> > >>>javax.faces.bean.ApplicationScoped
> > >>>with
> > >>>javax.enterprise.context.ApplicationScoped
> > >>>
> > >>>
> > >>>replace
> > >>>@ManagedBean(name =
> > >>>with
> > >>>@Named(
> > >>>
> > >>>
> > >>>replace
> > >>>@ManagedProperty("#{.*}")
> > >>>with
> > >>>@Inject
> > >>>
> > >>>
> > >>>Migrated applicationScopeBean from JSF ApplicationScoped managed bean
> > to EJB @Singleton with @Startup (please disregard this, since the last
> > thing I did with this was to migrate it to CDI applicationscoped instead
> of
> > EJB singleton and startup)
> > >>>
> > >>>
> > >>>Added CDI Qualifier called @Descendant for all descendants of Address,
> > EmailAddress, Phone, and PointOfContact controllers
> > >>>
> > >>>
> > >>>Replace
> > >>>FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
> > >>>
> > >>>
> > >>>with @Inject and private instance variable
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>3. Honestly, I was hoping not to have to migrate to another container
> > like Tomcat or TomEE, since I only have little/limited experience with
> > those containers (as I attempted to migrate to Tomcat 7.0.32, 1 or 2
> weeks
> > ago, but too much was involved and I couldn't even get the web app to
> > start). I am open to trying TomEE, hopefully, as a last-and-final
> option. :)
> > >>>
> > >>>
> > >>>
> > >>>On Sat, Nov 17, 2012 at 5:04 AM, Mark Struberg <struberg@yahoo.de>
> > wrote:
> > >>>
> > >>>Hi Howard!
> > >>>>
> > >>>>
> > >>>>JUEL is an Expression Language implementation. It has nothing to
do
> > with CDI apart from CDI providing an ELResolver. JUEL is much faster than
> > the EL interpreter in glassfish, so this is fine.
> > >>>>
> > >>>>For your beans getting recognized in EL expressions:
> > >>>>
> > >>>>1.) Do you have a META-INF/beans.xml in all your jars/classpaths
> which
> > contain CDI beans? This files can be empty, they just act as marker
> files.
> > For the webapp you might add one to WEB-INF/beans.xml.
> > >>>>
> > >>>>
> > >>>>2.) Do your CDI beans you access via EL have a @Named annotation?
> > >>>>This is needed to make them available for ELResolvers.
> > >>>>
> > >>>>3.) glassfish has a few nasty integration issues when it comes to
> > pluggin in different container parts. Can you try your app on tomee-1.5?
> > [1]. It comes with the latest MyFaces out of the box!
> > >>>>
> > >>>>LieGrue,
> > >>>>strub
> > >>>>
> > >>>>
> > >>>>[1] http://tomee.apache.org/downloads.html
> > >>>>
> > >>>>
> > >>>>
> > >>>>----- Original Message -----
> > >>>>> From: "Howard W. Smith, Jr." <smithh032772@gmail.com>
> > >>>>> To: MyFaces Discussion <users@myfaces.apache.org>
> > >>>>> Cc:
> > >>>>> Sent: Saturday, November 17, 2012 10:35 AM
> > >>>>> Subject: MyFaces 2.1.9 / Glassfish 3.1.2.2: Migrating to CDI
> > Managed Beans
> > >>>>>
> > >>>>> Web application details:
> > >>>>> JSF 2.1, MyFaces 2.1.9, PrimeFaces 3.4.1 (or 3.5-SNAPSHOT),
> Glassfish
> > >>>>> 3.1.2.2 (build 5), JUEL 2.2.5
> > >>>>>
> > >>>>> From server log:
> > >>>>> INFO: WELD-000900 1.1.8 (Final)
> > >>>>>
> > >>>>> Yesterday, I started migrating from JSF Managed Beans to CDI
> Managed
> > Beans.
> > >>>>> I referred to Chapter 28 (CDI) of Oracle's Java EE 6
> > >>>>> Tutorial<http://docs.oracle.com/javaee/6/tutorial/doc/giwhb.html
> >as
> > >>>>
> > >>>>> well as many other pages I found on the internet.
> > >>>>>
> > >>>>> Finally, the app starts, as I think I completed most steps
> necessary
> > to
> > >>>>> migrate to CDI managed beans, but now it seems as though my
beans
> > are not
> > >>>>> accessible from facelets. As per
> > >>>>> MYFACES-3104<https://issues.apache.org/jira/browse/MYFACES-3104>,
> > >>>>> I am already using *JUEL 2.2.5* (that is working well with
JSF
> > Managed
> > >>>>> Beans in production), so I already had *
> > >>>>> org.apache.myfaces.EXPRESSION_FACTORY* set in web.xml, as well
as
> > >>>>> *org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL
> > >>>>> *to *false*, and the last thing I did was add the following
to
> > web.xml:
> > >>>>
> > >>>>>
> > >>>>>     <context-param>
> > >>>>>
> > >>>>>
> <param-name>org.apache.myfaces.annotation.SCAN_PACKAGES</param-name>
> > >>>>>         <param-value>pf,jsf.users,jsf.orders</param-value>
> > >>>>>     </context-param>
> > >>>>>
> > >>>>> Which are just a 'few' of the packages that contained beans
> > referenced
> > >>>>> by
> > >>>>> the initial page of the app (login.xhtml).
> > >>>>>
> > >>>>> My questions:
> > >>>>>
> > >>>>>    1. Can someone please advise me of blog/tutorials that list
> > any/all
> > >>>>
> > >>>>>    steps necessary to migrate MyFaces 2.1.9 / Glassfish 3.1.2.2
web
> > app from
> > >>>>>    JSF Managed Beans to CDI?
> > >>>>>    2. I am not using MyFaces CODI or OpenWebBeans (yet). I've
seen
> > >>>>
> > >>>>>    OpenWebBeans recommended with MyFaces Core (2.1.7+) for
> > performance
> > >>>>>    reasons, and in PrimeFaces forum, I've seen MyFaces Core
and
> > MyFaces CODI
> > >>>>>    used together by some people. If I should use MyFaces CODI
or
> > OpenWebBeans,
> > >>>>>    please reply with blog/tutorial/instruction URLs.
> > >>>>>
> > >>>>> My next steps will probably be any/all of the following:
> > >>>>>
> > >>>>>    1. Remove JUEL 2.2.5 from the project, and see if I can
> > successfully get
> > >>>>
> > >>>>>    my pages to render via CDI
> > >>>>>    2. Add MyFaces CODI (need to search for a good set of
> > instructions on
> > >>>>>    how to do so)
> > >>>>>    3. Add OpenWebBeans (same as above, need good set of
> instructions)
> > >>>>
> > >>>>>
> > >>>>> Please confirm/advise. If you need any more details from me
(for
> > example,
> > >>>>> for me to reply with my web.xml), then please let me know.
> > >>>>>
> > >>>>> Thanks,
> > >>>>> Howard
> > >>>>>
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>
> > >
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message