1 2 3 4 Previous Next 59 Replies Latest reply on Oct 15, 2012 6:43 AM by chrisharris Go to original post
      • 30. Re: How do I get a JPA EntityManager reference in Weld?
        nickarls

        I don't think that everything will be released as a chunk - most probably some of the more core modules will be bundles for the first release (perhaps JPA-stuff, navigation enhancements, security, exception handling (although JSF 2 is OK OOTB)). Stuff like RSS might not be ported at all.


        But most importantly - since stuff can be better modularized, people can develop stuff without cluttering code of other modules (mainly, the old core). I believe that if



        1. People need it and

        2. The Java language and related specs support it



        a module fulfilling the need will emerge.

        • 31. Re: How do I get a JPA EntityManager reference in Weld?
          gavin.king

          With "Weld shop", I didn't mean anything commercial - I was referring to a small workshop where welders work ;-)

          Doesn't come through in English. But Welders workshop does.

          • 32. Re: How do I get a JPA EntityManager reference in Weld?
            sboscarine

            Nicklas Karlsson wrote on Nov 19, 2009 20:53:


            With Weld shop, I didn't mean anything commercial - I was referring to a small workshop where welders work ;-)


            I fully understood what you meant.  In the US, when you say that, people will likely thinking shop as in workshop and shop class.  I was actually thinking you wanted the weld workshop to to potentially evolve to the the apple app store or future Java Store.  (Obviously many steps exist between what you were suggesting and what the iPhone app store is at now.) 


            To your point, Weld would benefit if there was an easy means of locating exotic extensions. 

            • 33. Re: How do I get a JPA EntityManager reference in Weld?

              Gavin King wrote on Nov 19, 2009 20:58:


              I'm more or less in agreement with Francisco on this one.


              Happy to read that!



              All these extra features should be independent modules, independently installable. And we should release them as the become ready.


              Exactly!



              (However, we should probably not call them GA until we are ready to release the entire Seam3 platform as GA.)


              Well, I remember reading somewhere that nothing in JBoss was going to be GA anymore... I think the new posfix was FISH? no? ;-)


              I do think there should be a way to know when an extension is generally stable on its own vs. stable and integrated with the other Seam extensions


              • 34. Re: How do I get a JPA EntityManager reference in Weld?
                asookazian

                Francisco Peredo wrote on Nov 19, 2009 19:03:


                I think one thing that is very important to keep in mind is that if Seam 3 is release monolitically that IMO will hurt adoption.

                Seam 2 does too many things (here are most of them in no particular order):


                1. Integration with JSF

                2. Integration with JPA

                3. Integration with JBPM

                4. Integration with EJBs

                5. Remoting with JavaScript

                6. Integration with Wicket

                7. Integratoin with JBoss Rules

                8. Security Management (JAAS/Authorization/Authentication/Catpchas/OpenId,etc)

                9. Internationalization

                10. WikiText

                11. PDF generation

                12. Excel generation

                13. RSS support

                14. Asynchronicity and messaging

                15. Caching

                16. WebServices Support

                17. GWT support

                18. Integration with Spring

                19. Integration with Guice

                20. Email sending support



                Now I can see how, if we are told we are going to have to wait for all of this to be released as part of Seam 3 that gives us an uneasy feeling... I mean: why do I need to wait for RSS support or Security Management if all I want is JPA support? Why do I need to wait for JSF support if all I want is GWT Support?

                That is why I think that why this extensions should belong to the Seam 3 project, they should not be released as a single monolithic thing. They should be released incrementally, perhaps following an order that the team knows is the one that fits their target audience the most.

                If some people feel that the priority is wrong, they should be given the chance to explain their reasons, if after explaining them Jboss still feels that it shouldnt change its priorities, then, since this is opensource, those that want to change the path have the power to do so, they have to step up and decide that they are going to help port XXXX from Seam 2 to Seam 3.

                Of course, this is going to be a tough test on Jboss, because when one creates an ecosystem, it gets a life of its own, and it can grown in unexpected ways... if they are not careful they could asphyxiate it by exercising too much control, but if they offer no guidance, they risk becoming a forgotten piece of the ecosystem (like Sun and the Java ecosystem)

                They need to find the Middle Way



                We've gone for a totally modular approach for Seam 3, in fact there is no Seam core any more, although some modules may optionally depend on functionality from other modules. To see the direction that we're heading I recommend you take a look at SVN:

                http://anonsvn.jboss.org/repos/seam/modules/trunk/

                http://seamframework.org/Community/ModularizingSeamALaSpring#comment89343


                The lack of core?  I thought Weld was core for Seam3?

                • 35. Re: How do I get a JPA EntityManager reference in Weld?

                  I think it is right to say that Weld is the core of Seam, of course while Weld is the core, Weld also is another project.


                  Mmmmm....


                  One interesting question here is for example if Seam 3 will be built so that it works on top of any other JSR-299 implementation... if that is true, then that means that Seam will potentially have many cores because any implementation of JSR-299 could act as the core of Seam. Or you can interpret it as Seam having no core until you plug-in the one you like...

                  • 36. Re: How do I get a JPA EntityManager reference in Weld?
                    nickarls

                    OKOK, I'll let you the native speakers call ad authoritae on this one although google does find common usage for the term ;-)

                    • 37. Re: How do I get a JPA EntityManager reference in Weld?
                      nickarls

                      Of course, the Weld core might be tweaked a bit to fit better as the One Seam Core as long as the TCK passes. For example, make stuff configurable that isn't configurable in all implementations.

                      • 38. Re: How do I get a JPA EntityManager reference in Weld?
                        sboscarine

                        I know this was asked earlier before we got into the what is Seam vs what is Weld tangent, but I think I'm not unique in wanting to know...



                        I want to write a useful, typical webapp in CDI, one that uses JSF, JPA, JNDI variables, etc.  My employer has Tomcat installed.  How can I do so? 


                        Is JBoss5 the only non-beta container that works with CDI, JPA, and JTA right now?



                        Gavin submitted some code above and otherwise said wait for Seam3.  Is that the intention?  Use JBoss 5, do it yourself, or wait for Seam3?  I heard mention of releasing Seam incrementally.  If the plan is simply, wait for Seam3, how long before there's a beta that'll enable JavaSE and Tomcat/Jetty users to use JPA and JTA? 


                        The vast majority of your potential users are not running JBoss 5 and need to deploy it on a production-ready container.  Anyone who wants to write a proof of concept of CDI in a corporate environment is going to have a hard time getting their company to deploy a new server platform to test out Weld. 


                        In my employer's case, we actually cannot deploy to JBoss 5 because we deployed a Seam application to JBoss 4.2 and it won't run on JBoss 5.  We'd have to port our legacy apps to get them ready for JBoss 5.  I am sure I am not the only user who is in a corporate scenario where they cannot create a whole new container environment to use CDI. 


                        I'd like to replace Spring with Weld, but as someone who needs JPA, is it even possible without installing JBoss 5? 


                        It's a hard sell to management that CDI is a good idea if they see a lot of manual JPA and transaction code.  I apologize if I am begin pushy.  I am no trying to be a troll.  I am sincerely trying to figure out how a typical user, like myself, can adopt Weld.  

                        • 39. Re: How do I get a JPA EntityManager reference in Weld?

                          Steven... Maybe that post is a better fit for this other thread?


                          • 40. Re: How do I get a JPA EntityManager reference in Weld?
                            sboscarine

                            Gavin King wrote on Nov 19, 2009 10:03:


                            Steven,

                            Here is a portable extension that will create a managed JPA persistence context of any scope if you declare a producer field like this:

                            @Produces @ApplicationScoped 
                            @PersistenceContext(unitName="foo")
                            EntityManager em;



                            In one of your beans. (As long as you have a META-INF/persistence.xml file with a persistence unit named "foo".)



                            Thanks again for making this.  I believe I followed your instructions explicitly and it is not yet working.  How can I troubleshoot?  I created each class you specified and added the producer field to the BeanService I submitted above.  I still get null.  I can confirm that CDI is working fine.  I can still create the EntityManager manually. 



                            I looked at the documentation, but didn't find much there.  Are there examples of other classes that implement javax.enterprise.inject.spi.Extension?  I found a few in tests, but couldn't figure out from their comments what they are meant to do.


                            I created a constructor for PersistenceContextExtension with a println statement and it is never called. 


                            Once you write an extension, how does CDI know to call it? 


                            For a regular bean, I understand how adding a scope annotation tells the container that it is to be managed by CDI.  How does the CDI container know that PersistenceContextExtension is an extension?






                            • 41. Re: How do I get a JPA EntityManager reference in Weld?
                              gavin.king

                              You need to put the class in a jar with a file named META-INF/services/javax.enterprise.inject.spi.Extension with the following line of text:


                              org.seamframework.PersistenceContextExtension




                              That's enough for the CDI container to discover the portable extension.

                              • 42. Re: How do I get a JPA EntityManager reference in Weld?
                                sboscarine

                                Thank you.  That worked.


                                If anyone else is trying this at home.  The package in the code sample above is different than above.  org.seamframework.PersistenceContextExtension should be org.seamframework.persistence.PersistenceContextExtension


                                Now you can write:



                                   @Inject
                                   EntityManager em;



                                • 43. Re: How do I get a JPA EntityManager reference in Weld?
                                  asookazian

                                  Steven Boscarine wrote on Nov 21, 2009 16:27:


                                  I want to write a useful, typical webapp in CDI, one that uses JSF, JPA, JNDI variables, etc.  My employer has Tomcat installed.  How can I do so? 

                                  Is JBoss5 the only non-beta container that works with CDI, JPA, and JTA right now?


                                  I think you've asked this how can I use Tomcat with Weld question in this thread several times.  It's a good question for obvious reasons but maybe you should give up temporarily with the Tomcat/Weld route.  GKing provided some sample code to provide managed JPA context in a non-EE container (like Tomcat).  He has already stated that you should probably wait for Seam3 for the PC and tx mgmt.  CDI is a sub-spec in EE 6, so it makes sense to use a EE 6 certified (100% pass TCK) app server like JBoss 6 or Glassfish V3.  You're literally living on the bleeding edge.



                                  I'd like to replace Spring with Weld, but as someone who needs JPA, is it even possible without installing JBoss 5? 

                                  It's a hard sell to management that CDI is a good idea if they see a lot of manual JPA and transaction code.  I apologize if I am begin pushy.  I am no trying to be a troll.  I am sincerely trying to figure out how a typical user, like myself, can adopt Weld.  


                                  You can think about Seam/Spring integration, as outlined in detail in SiA book.  And yes, it's difficult to sell CDI w/o even a JPA example in the distro to demo.  CRUD apps is the bread-and-butter of web development these days (and yes, flashy/ajaxy stuff too).


                                  Also, I think the idea that someone raised about providing pre-made portable extensions
                                  out-of-the-box is a really good idea!


                                  And let's not forget this:



                                  The CDI spec has nothing to say about connecting to databases. You're mixing up CDI (a bean container) with Seam (an application platform).

                                  The community needs to start thinking about CDI as a core extendable system (via SPI/PE) for DI, contexts, event observation, decoration, interception, stereotypes, etc., not an all-inclusive stack like Spring or Seam.


                                  It's getting to the point for me that it makes sense to wait for Seam3 but I will continue to learn concepts and play around with examples, etc. in Weld.


                                  I think a good diagram of Weld and SPI/PEs would be very appropriate.


                                  Why can't you guys add figures/pics in the spec?  or the ref doc?  it would help a lot.  the pics in SiA book helped me a lot (esp. the one regarding the conversation-scoped SMPC vs. tx- or component-scoped container-managed PC).

                                  • 44. Re: How do I get a JPA EntityManager reference in Weld?
                                    asookazian

                                    from ref doc:



                                    There is a major limitation to using a servlet container. Weld doesn't support deploying session
                                    beans, injection using @EJB or @PersistenceContext, or using transactional events in servlet
                                    containers. For enterprise features such as these, you should really be looking at a Java EE
                                    application server.