openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: Servlet 3.0 not injeting bean
Date Thu, 19 Jun 2014 20:42:09 GMT
Code uses 7.0.0 but think 7.0.47 is fine

Le mercredi 18 juin 2014, Felipe Pina <fop.net@gmail.com> a écrit :
> which version of tomcat i should use?
>
> Em 18/06/2014 17:50, "Romain Manni-Bucau" <rmannibucau@gmail.com>
escreveu:
>>
>> Tomcat api changed but owb didnt follow it. Either downgrade tomcat or
wait we fix it sorry :(
>>
>> Le mercredi 18 juin 2014, Felipe Pina <fop.net@gmail.com> a écrit :
>> > Romain, I put exactly the tomcat 7 dependencies  but i am getting this
error.
>> > SEVERE: ContainerBase.addChild: start:
>> > org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/GrowUpWeb]]
>> > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
>> > at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>> > at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>> > at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
>> > at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
>> > at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
>> > at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>> > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
>> > at java.util.concurrent.FutureTask.run(FutureTask.java:166)
>> > at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>> > at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>> > at java.lang.Thread.run(Thread.java:722)
>> > Caused by: java.lang.AbstractMethodError:
org.apache.webbeans.web.tomcat.TomcatInstanceManager.newInstance(Ljava/lang/Class;)Ljava/lang/Object;
>> > at
org.apache.catalina.core.ApplicationContext.createListener(ApplicationContext.java:1402)
>> > at
org.apache.catalina.core.ApplicationContext.addListener(ApplicationContext.java:1307)
>> > at
org.apache.catalina.core.ApplicationContextFacade.addListener(ApplicationContextFacade.java:636)
>> > at
com.sun.faces.config.FacesInitializer.onStartup(FacesInitializer.java:140)
>> > at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456)
>> > at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>> > ... 11 more
>> > Jun 17, 2014 7:38:38 PM org.apache.catalina.startup.HostConfig
deployWAR
>> > SEVERE: Error deploying web application archive D:\Arquivos de
programas\Apache Software Fondation\tomcat-7.0.54\webapps\GrowUpWeb.war
>> > java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/GrowUpWeb]]
>> > at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
>> > at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>> > at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
>> > at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
>> > at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
>> > at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>> > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
>> > at java.util.concurrent.FutureTask.run(FutureTask.java:166)
>> > at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>> > at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>> > at java.lang.Thread.run(Thread.java:722)
>> >
>> > 2014-06-17 11:37 GMT-03:00 Romain Manni-Bucau <rmannibucau@gmail.com>:
>> >>
>> >> 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 <fop.net@gmail.com> 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 <rmannibucau@gmail.com
>:
>> >> >>
>> >> >> 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 <fop.net@gmail.com>:
>> >> >>>
>> >> >>> 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 <struberg@yahoo.de>:
>> >> >>>>
>> >> >>>> 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 <fop.net@gmail.com>
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
>> >>
>> >
>> >
>> >
>> > --
>> > 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
>>
>

-- 


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau

Mime
View raw message