6 Replies Latest reply on Mar 20, 2014 3:35 AM by mkouba

    weld issue with  tomcat

    hanymanyy

      hi guys  i have a problem by integrating weld with tomcat

       

      i have two war files for two applications

      but tomcat container doesn't allow me to deploy both of them

      tomcat container only allow one of them and the other application fails and get this error

       

      org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.SessionScoped

      org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680)

      org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79)

      org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78)

      managed.managedTheme$Proxy$_$$_WeldClientProxy.getTheme(Unknown Source)

      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

      sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

      java.lang.reflect.Method.invoke(Unknown Source)

      javax.el.BeanELResolver.getValue(BeanELResolver.java:87)

      com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)

      com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)

      org.apache.el.parser.AstValue.getValue(AstValue.java:182)

      org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)

      org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)

      org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:65)

      javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)

      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1894)

      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1899)

      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:451)

      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)

      javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)

      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)

      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)

      javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)

      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

       

       

       

      in brief (tomcat doesn't allow two applications to deploy on the same instance)

       

      any ideas?

        • 1. Re: weld issue with  tomcat
          mkouba

          Hi Hany,

          what version of Weld and Tomcat do you use?

          • 2. Re: weld issue with  tomcat
            hanymanyy

            i'm using 2.1.2.Final with latest tomcat version(7.52)

             

            i'd like to say that i have tried (2.2.0.Beta1) but it gave me the same results

            • 3. Re: weld issue with  tomcat
              hanymanyy

              any ideas?????????????

              • 4. Re: weld issue with  tomcat
                mkouba

                I did a quick test with two simple JSF apps (Weld numberguess example) on Tomcat 7.0.47 and everything worked. Could you describe your applications in more detail? A simplified example would be ideal . Also do these applications share anything or are they completely isolated?

                • 5. Re: weld issue with  tomcat
                  hanymanyy

                  this is my context.xml file

                   

                  <?xml version="1.0" encoding="UTF-8"?>

                  <Context antiJARLocking="true" path="/webtest"  fireRequestListenersOnForwards="true" >

                   

                     <Resource name="BeanManager"

                        auth="Container"

                        type="javax.enterprise.inject.spi.BeanManager"

                        factory="org.jboss.weld.resources.ManagerObjectFactory"/>

                   

                  </Context>

                   

                   

                  and this is my web.xml file

                   

                  <?xml version="1.0" encoding="UTF-8"?>

                  <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

                      <context-param>

                          <param-name>javax.faces.PROJECT_STAGE</param-name>

                          <param-value>Development</param-value>

                      </context-param>

                      <servlet>

                          <servlet-name>Faces Servlet</servlet-name>

                          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                          <load-on-startup>1</load-on-startup>

                      </servlet>

                      <servlet-mapping>

                          <servlet-name>Faces Servlet</servlet-name>

                          <url-pattern>/faces/*</url-pattern>

                      </servlet-mapping>

                      <session-config>

                          <session-timeout>

                              30

                          </session-timeout>

                      </session-config>

                      <welcome-file-list>

                          <welcome-file>faces/index.xhtml</welcome-file>

                      </welcome-file-list>

                     

                    

                  <listener>

                     <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>

                  </listener>

                   

                  <resource-env-ref>

                     <resource-env-ref-name>BeanManager</resource-env-ref-name>

                     <resource-env-ref-type>

                        javax.enterprise.inject.spi.BeanManager

                     </resource-env-ref-type>

                  </resource-env-ref>

                   

                  </web-app>

                   

                  i'm using tomcat container in web server (vps) i'm using one instance of tomcat for all domains as virtual host

                  and all applications shared in libraries folder

                   

                  any ideas?

                  • 6. Re: weld issue with  tomcat
                    mkouba
                    and all applications shared in libraries folder

                    Do you mean $CATALINA_HOME/lib directory? Application classes should not be placed there. Otherwise they will be visible to all web applications (all web apps will share the same classloader). See also http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html#Class_Loader_Definitions