http://java.dzone.com/articles/using-apache-openwebbeans is more or less what i suggested. Tomee needs dependencies you maybe dont want (now).
Le lundi 16 juin 2014, Felipe Pina <[email protected]> a écrit : > Romain, i already realized the memory tests and i found an economy larger memory using raw tomcat. > I do not understand the reason of a lookup using the BeanManager, works perfectly, including the injection of other beans returned by the lookup, > but when I need to use a simple injection in a servlet, simply does not work. > > I wonder what the listener and their dependencies, which takes place on raw tomcat, for the operation of the injection correctly in a servlet 3.0. > I have done the test and using raw tomcat with Weld CDI or only with Tomee and both solutions works perfectly, but that's not what I need right now. > > Due to all this trouble, the developer ends up prioritizing the use of CDI Weld that function properly for what the product is proposed. > I realized that there is a listener in Tomee server.xml > <- Tomee plugin for Tomcat -> > <Listener ClassName="org.apache.tomee.catalina.ServerListener"/> > And I tried to put the necessary for the functioning of the listener dependencies, but I had other errors to lift the server and number of dependancy just growing too. > ( Gray dependencies below ) > Could you help me in this matter and also detail more about me so scan.xml use and BTW? > Regards > Felipe Pina > My dependencies > <!-- **************************************************** OpenWebBeans Specifications --> > <!-- JSR-330 --> > <dependency> > <groupId>org.apache.geronimo.specs</groupId> > <artifactId>geronimo-atinject_1.0_spec</artifactId> > <version>1.0</version> > <scope>${owb.scoped}</scope> > </dependency> > > <!-- JSR-299 --> > <dependency> > <groupId>org.apache.geronimo.specs</groupId> > <artifactId>geronimo-jcdi_1.0_spec</artifactId> > <version>1.0</version> > <scope>${owb.scoped}</scope> > </dependency> > > <dependency> > <groupId>org.apache.geronimo.specs</groupId> > <artifactId>geronimo-interceptor_1.1_spec</artifactId> > <version>1.0</version> > <scope>${owb.scoped}</scope> > </dependency> > > <!-- native tomee libs > <dependency> > <groupId>org.apache.openejb</groupId> > <artifactId>tomee-catalina</artifactId> > <version>${tomee.version}</version> > </dependency> > <dependency> > <groupId>org.apache.openejb</groupId> > <artifactId>tomee-common</artifactId> > <version>${tomee.version}</version> > </dependency> > <dependency> > <groupId>org.apache.openejb.staticweb</groupId> > <artifactId>static-tomee-jquery</artifactId> > <version>${tomee.version}</version> > </dependency> > <dependency> > <groupId>org.apache.openejb.staticweb</groupId> > <artifactId>static-tomee-bootstrap</artifactId> > <version>${tomee.version}</version> > </dependency> > <dependency> > <groupId>org.apache.openejb</groupId> > <artifactId>tomee-jdbc</artifactId> > <version>${tomee.version}</version> > </dependency> > <dependency> > <groupId>org.apache.openejb</groupId> > <artifactId>tomee-loader</artifactId> > <version>${tomee.version}</version> > </dependency> > --> > > <!-- OpenWebBeans implementations --> > <dependency> > <groupId>org.apache.openwebbeans</groupId> > <artifactId>openwebbeans-impl</artifactId> > <version>${owb.version}</version> > <scope>${owb.scoped}</scope> > </dependency> > <dependency> > <groupId>org.apache.openwebbeans</groupId> > <artifactId>openwebbeans-web</artifactId> > <version>${owb.version}</version> > <scope>${owb.scoped}</scope> > </dependency> > > <!-- OpenWebBeans JSF --> > <dependency> > <groupId>org.apache.openwebbeans</groupId> > <artifactId>openwebbeans-jsf</artifactId> > <version>${owb.version}</version> > <scope>${owb.scoped}</scope> > </dependency> > > <!-- SPI (Service Provider Interface). --> > <dependency> > <groupId>org.apache.openwebbeans</groupId> > <artifactId>openwebbeans-spi</artifactId> > <version>${owb.version}</version> > <scope>${owb.scoped}</scope> > </dependency> > > > <!-- Add-on tomcat7 plugin --> > <dependency> > <groupId>org.apache.openwebbeans</groupId> > <artifactId>openwebbeans-tomcat7</artifactId> > <version>${owb.version}</version> > <scope>${owb.scoped}</scope> > </dependency> > > <!-- XBean Finder helps to find annotations in classes - [openwebbeans-impl,openwebbeans-web] dependency --> > <dependency> > <groupId>org.apache.xbean</groupId> > <artifactId>xbean-finder-shaded</artifactId> > <version>3.14</version> > <scope>${owb.scoped}</scope> > </dependency> > <!-- Others indirect specifications --> > <dependency> > <groupId>org.apache.geronimo.bundles</groupId> > <artifactId>scannotation</artifactId> > <version>1.0.2_1</version> > <scope>${owb.scoped}</scope> > </dependency> > <dependency> > <groupId>asm</groupId> > <artifactId>asm</artifactId> > <version>3.3.1</version> > <scope>${owb.scoped}</scope> > </dependency> > > <dependency> > <groupId>javax.inject</groupId> > <artifactId>javax.inject</artifactId> > <version>1</version> > <scope>${owb.scoped}</scope> > </dependency> > > > 2014-06-14 15:21 GMT-03:00 Romain Manni-Bucau <[email protected]>: >> >> Hi >> with tomee you can save more memory than with OpenWebBeans using a scan.xml file really limiting scanning. >> BTW OWB has a tomcat plugin to get what you want >> >> >> Romain Manni-Bucau >> Twitter: @rmannibucau >> Blog: http://rmannibucau.wordpress.com/ >> LinkedIn: http://fr.linkedin.com/in/rmannibucau >> Github: https://github.com/rmannibucau >> >> >> 2014-06-14 16:33 GMT+02:00 Felipe Pina <[email protected]>: >>> >>> Mark i used the TomEE, but i need to save memory, so when i customize the normal tomcat with owb libs, i realized a little memory economy. I really only need the injection. >>> >>> 1- My project is set with openwebbeans-tomcat7 module, but I wonder if it is equivalent to configuration of the listener below in web.xml instead server.xml file ? it makes no difference? >>> web.xml -> Can i setup this way ? This works too ? >>> <!-- OpenWebbeans tomcat plugin --> >>> <listener> >>> <listener-class>org.apache.webbeans.web.tomcat.ContextLifecycleListener</listener-class> >>> </listener> >>> or >>> setup.xml >>> <Listener className="org.apache.webbeans.web.tomcat.ContextLifecycleListener"/> >>> >>> 2- There is another configuration i need to do ? >>> >>> 2014-06-14 7:48 GMT-03:00 Mark Struberg <[email protected]>: >>>> >>>> it should if you use our openwebbeans-tomcat7 module. >>>> Or if you use Apache TomEE which comes pre-packaged and perfectly setup with OpenWebBeans as CDI container. In this case you can also leverage multiple other cool EE features like JTA, etc. This is kind of a perfectly integrated setup of MyFaces and OpenWebBeans into tomcat7. >>>> It comes with OpenJPA as well in case you need JPA. Of course you can optionally also use Hibernate and EclipseLink with TomEE as well. >>>> Might be easier for you than to setup all our internal container modules yourself. Of course you are welcome to do so and report back if you need more help. >>>> LieGrue, >>>> strub >>>> >>>> On Saturday, 14 June 2014, 4:49, Felipe Pina <[email protected]> wrote: >>>> >>>> >>>> Why cdi OWB injection do not works only by servlet url ? >>>> >>>> My java beans below. >>>> >>>> @WebServlet( urlPatterns = {"/tarifas"}) >>>> public class Tarifas extends HttpServlet { >>>> /** >>>> * Atributo '<code>serialVersionUID</code>' do tipo long >>>> */ >>>> private static final long serialVersionUID = 1L; >>>> @javax.inject.Inject >>>> private TarifaBean tarifaBean; -> This injection do not works, when access by servlet url tarifas >>>> @Override >>>> protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { >>>> try { >>>> >>>> tarifaBean.setSession(request.getSession()); >>>> request.setAttribute("valorTarifa", tarifaBean.getValorUnitario()); >>>> getServletContext().getRequestDispatcher("/WEB-INF/pages/tarifas.jsp").forward(request, response); >>>> } catch (GrowUpException e) { >>>> throw new ServletException(e); >>>> // getServletContext().getRequestDispatcher("error.jsp").forward(request, response); >>>> } >>>> } >>>> } >>>> >>>> >>>> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>> @javax.inject.Named(value="tarifaBean") >>>> @javax.enterprise.context.SessionScoped >>>> public class TarifaBean implements Serializable { >>>> /** >>>> * Atributo '<code>serialVersionUID</code>' do tipo long >>>> */ >>>> private static final long serialVersionUID = 1L; >>>> @javax.inject.Inject >>>> private GrowUpFacadeAdapter facade; -> This injection works fine, when access by jsf page. >>>> private Double valorUnitario; >>>> public TarifaBean() {} >>>> /** >>>> * @return the valorUnitario >>>> * @throws GrowUpException >>>> */ >>>> public Double getValorUnitario() throws Exception { >>>> if (valorUnitario==null) >>>> valorUnitario = buscarValorPedido(); >>>> return valorUnitario; >>>> } >>>> /** >>>> * @return >>>> */ >>>> private Double buscarValorPedido() throws Exception { >>>> VariavelDTO var = (VariavelDTO) facade.executarComando(session, >>>> GCS.MAPA_VARIAVEL, >>>> GCS.BUSCAR_VALOR_UNITARIO); >>>> if (!isCodigoValido(var)) >>>> throw new IllegalArgumentException("Não foi possível encontrar o valor Unitário do pedido."); >>>> return var.getValorAsDouble(); >>>> } >>>> } >>>> >>>> >>>> >>>> -- >>>> Atenciosamente, >>>> Felipe Pina >>>> >>>> >>> >>> >>> >>> -- >>> Atenciosamente, >>> Felipe Pina >> > > > > -- > Atenciosamente, > Felipe Pina > -- Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau
