2 Replies Latest reply on May 4, 2011 3:32 AM by aagenielsen.aagnie.gmail.com

    Tomcat 7 war and Weld

    aagenielsen.aagnie.gmail.com
      We are using Weld 1.1.0 in a JSF 2.1 applikation and we are struggleing with war files and Tomcat 6.0.32.

      Our production environment are currently using "pure" war files and exploded apps are not permitted ! It is true that Weld does not work unless the war files are exploded ? Our own little test show no beans when running the app unexploded, but all our beans when exploded

      .....

          public List<Bean> getJndiBeans() {
              List<Bean> jndiBeans=new ArrayList<Bean>();
              Context initCtx;
              try {
                  initCtx = new InitialContext();
                  Context envCtx = (Context) initCtx.lookup("java:comp/env");
                  BeanManagerImpl bm= (BeanManagerImpl) envCtx.lookup("BeanManager");
                  for (Object bean : Arrays.asList(bm.getBeans().toArray())) {
                      jndiBeans.add((Bean) bean);
                  }
              } catch (NamingException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              return jndiBeans;
          }

      ......

      ......


                  <rich:dataTable var="bean" value="#{simpleTest.jndiBeans}">
                      <f:facet name="header">
                          <h:column>Name</h:column>
                          <h:column>Scope</h:column>
                      </f:facet>
                      <h:column>
                          <h:outputText value="#{bean.name}" />
                      </h:column>
                      <h:column>
                          <h:outputText value="#{bean.scope.name}" />
                      </h:column>
                  </rich:dataTable>


      Anyone ?


      best regards

      aage
        • 1. Re: Tomcat 7 war and Weld
          fup

          Where did you place the beans.xml file? There are two options: in the META-INF directory of the classpath or WEB-INF directory of the web root.


          I deployed a simple example app on Tomcat 6.0.32. For exploded deployment, beans were discovered placing the beans.xml file either at /WEB-INF/ or at /WEB-INF/classes/META-INF/. But, surprisingly, in case of an unexploded war beans were discovered only if the beans.xml file was placed at /WEB-INF/classes/META-INF/. Placing it at /WEB-INF/ does not work for me.

          • 2. Re: Tomcat 7 war and Weld
            aagenielsen.aagnie.gmail.com

            Hmmmm strange - we have tried copying our (empty) beans.xml around without any luck - and we are also using Tomcat 6.0.32 not Tomcat 7 as we wrote in subject.


            Are we alone in deploying only nonexploding webapps in Tomcat ?


            /aage