6 Replies Latest reply on Jun 15, 2008 7:00 PM by Dan Allen

    s:graphicImage problem

    Susanne Jarl Newbie

      I have an ear with one ejb3 module and two wars.
      If I put the exact same code



      <s:graphicImage rendered="#{recipe.imagex != null}" value="#{recipe.imagex}" fileName="testImage" /> 



      in the two different wars it works fine in one and the other one I get an exception.


      The recipe object is rendered by a Factory in a stateful session bean and returns the recipe entity.


      The imagex property is a byte[]


      The two wars have equal components.xml, web.xml, pages.xml and jboss.xml and also the same jars in WEB-INF/lib and empty WEB-INF/classes. I use equal xhtml files in both wars to test with, which only contains the s:graphicImage code and necessary stuff.


      The exception stacktrace is:


      ERROR [ContextualHttpServletRequest] ended request due to exception
      
      java.lang.IllegalArgumentException: value of context variable is not an instance of the component bound to the context variable: org.jboss.seam.ui.graphicImage.graphicImageStore
      
              at org.jboss.seam.Component.getInstance(Component.java:1888)
      
              at org.jboss.seam.Component.getInstance(Component.java:1843)
      
              at org.jboss.seam.Component.getInstance(Component.java:1822)
      
              at org.jboss.seam.Component.getInstance(Component.java:1817)
      
              at org.jboss.seam.ui.graphicImage.GraphicImageStore.instance(GraphicImageStore.java:105)
      
              at org.jboss.seam.ui.graphicImage.GraphicImageResource.doWork(GraphicImageResource.java:62)
      
              at org.jboss.seam.ui.graphicImage.GraphicImageResource.access$000(GraphicImageResource.java:28)
      
              at org.jboss.seam.ui.graphicImage.GraphicImageResource$1.process(GraphicImageResource.java:51)
      
              at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
      
              at org.jboss.seam.ui.graphicImage.GraphicImageResource.getResource(GraphicImageResource.java:46)
      
              at org.jboss.seam.servlet.SeamResourceServlet.doGet(SeamResourceServlet.java:75)
      
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
              at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:350)
      
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
      
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
      
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      
              at java.lang.Thread.run(Thread.java:619)





      Any ideas why I get this stacktrace and the image won't show in one of the wars and works fine in the other?


      The HTML code is rendered correctly and equal in both wars. I have debugged the session bean and it works fine and similar.



        • 1. Re: s:graphicImage problem
          Susanne Jarl Newbie

          Forgot to mention that I use the the latest stable versions: Seam 2.0.2.SP1, RichFaces 3.2.1 and JBoss 4.2.2.

          • 2. Re: s:graphicImage problem
            Dan Allen Master

            I have always hated this exception because it is so cryptic. Here's what it means. When Seam looks for an existing instance of a component, it checks for a context variable equivalent to the component name. It is expecting to find an instance of the component. If it finds a value of a different type, then it throws this exception. The context variable was basically used for a different purpose, which is illegal.


            As to why it happens, it would be necessary to know what class it found. If I were you, I would debug into Component.java and find out what value it found.

            • 3. Re: s:graphicImage problem
              Susanne Jarl Newbie

              Thanks for your answer. I have now digged into this a little deeper and the war that did not work, is working IF you remove the other war module from application.xml. So it seems like something goes wrong when you have 2 wars using the graphicImageStore.


              When I have 2 war modules, the exception is thrown (for one of the wars) on row 1888 in org.jboss.seam.component and when I debug that row I get the following result:



              name = "org.jboss.seam.ui.graphicImage.graphicImageStore" 
              
              create = true
              
              result = GraphicImageStore (id=11037)
              
              component = Component (id=11039)
              
              component.beanClass = Class<T>(org.jboss.seam.ui.graphicImage.GraphicImageStore)(id=10998)





              The jars included in both the wars are


              common-beanutils.jar
              commons-digester.jar
              jboss-seam-debug.jar
              jboss-seam-gen.jar
              jboss-seam-mail.jar
              jboss-seam-pdf.jar
              jboss-seam-ui.jar
              jsf-facelets.jar
              richfaces-impl.jar
              richfaces-ui.jar
              urlrewrite-2.5.2.jar


              The jars included in the EAR are:


              antlr-runtime.jar
              core.jar
              drools-compiler.jar
              drools-core.jar
              hibernate-search.jar
              jboss-el.jar
              jboss-seam.jar
              jbpm-jpdl.jar
              lucene-core.jar
              mvel14.jar
              postgresql-8.3-603.jdbc4.jar
              richfaces-api.jar
              security.drl
              ws-commons-util.jar
              xmlrpc-client.jar
              xmlrpc-common.jar



              Any ideas why I can not get the GraphicImageStore to work in 2 wars deployed in the same ear at the same time?


              • 4. Re: s:graphicImage problem
                Susanne Jarl Newbie

                I looked into the jboss console and at startup I get this warn message:


                WARN  [SeamPhaseListener] There should only be one Seam phase listener per application



                You can also see this initialization twice (i.e. one for each war) in the console:


                12:57:32,163 INFO  [Component] Component: org.jboss.seam.ui.graphicImage.graphicImageResource, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.ui.graphicImage.GraphicImageResource
                
                12:57:32,163 INFO  [Component] Component: org.jboss.seam.ui.graphicImage.graphicImageStore, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.ui.graphicImage.GraphicImageStore



                I have googled the There should be only one Seam phase listener but I could not find any helpful information, it seems like my ear structure is correct. I use the JSF-RI in jboss-4.2.2. And I listed the jars i have included in the wars and ear in my previous post.


                Please help me if you have any idea of what is wrong.

                • 5. Re: s:graphicImage problem
                  Susanne Jarl Newbie

                  Well I solved the problem with s:graphicImage by putting this in jboss-web.xml in the first war:


                  <class-loading java2ClassLoadingCompliance="false">
                  
                          <loader-repository>
                  
                              seam.jboss.org:loader=app1
                  
                              <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                  
                          </loader-repository>
                  
                  </class-loading>



                  and this in jboss-web.xml in the second war:


                  <class-loading java2ClassLoadingCompliance="false">
                  
                          <loader-repository>
                  
                              seam.jboss.org:loader=app2
                  
                              <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
                  
                          </loader-repository>
                  
                  </class-loading>



                  Still I get the


                  WARN  [SeamPhaseListener] There should only be one Seam phase listener per application
                  
                  



                  but the application now works.

                  • 6. Re: s:graphicImage problem
                    Dan Allen Master

                    Yeah, it's fairly clear from these messages that the two WARs are sharing classloaders, a common problem in JBoss deployments. As you figured out, though, there are ways to isolate them. Still, when the SeamPhaseListener from one WAR is loaded, the SeamPhaseListener from the other WAR recognizes the presence of the first (hence the message). So the JSF application instance is still being shared between the two WARs. That's about as far as I can help because I am no expert at the JBoss classloader (nor do I want to be).