10 Replies Latest reply on Oct 5, 2007 8:51 AM by pmuir

    DocumentStore usage

    nickarls

      Hi,

      I'm trying to serve a PDF from the database through the DocumentStore
      but when I try to get an instance with

       String id = DocumentStore.instance().newId();
      


      I just get a
      Caused by: java.lang.ClassCastException: org.jboss.seam.pdf.DocumentStore_$$_javassist_12
      


      (also tried variation of DocumentStore ds = DocumentStore.instance() and Component.getInstance() but to no avail)

      How should it be used?

        • 1. Re: DocumentStore usage

          Are you getting an incompatible type or are you getting an incompatible DocumentStore class from another classloader?

          • 2. Re: DocumentStore usage
            nickarls

            Hmm, it might be a classloader issue, normally the seam-jars are under WEB-INF\lib in the war but where should it be put so that everyone sees it? (both the WAR and my JAR) Only in the EAR?

            • 3. Re: DocumentStore usage

              They should be in the WAR.

              I was just trying to understand what the ClassCastException you are getting is. There isn't enough information there to understand what problem you are seeing.

              • 4. Re: DocumentStore usage
                nickarls

                 

                "norman.richards@jboss.com" wrote:
                They should be in the WAR.

                I was just trying to understand what the ClassCastException you are getting is. There isn't enough information there to understand what problem you are seeing.


                I'm trying to do a
                public String getInstructionManualURL() {
                 String id = DocumentStore.instance().newId();
                 DocumentData data = new DocumentData("manual.pdf",DocumentData.DocType.PDF, manualBytes);
                 DocumentStore.instance().saveData(id, data);
                 return DocumentStore.instance().preferredUrlForContent("manual.pdf", DocumentData.DocType.PDF, id);
                }
                


                But the bean action is in a JAR file and if just have the seam-pdf.jar in my WAR then the JAR can't see it. The classcast just came from moving around seam-jar trying to see what worked. But if it should be in WEB-INF/lib, how can you make the JAR see it?

                • 5. Re: DocumentStore usage
                  nickarls

                  Or if there are no solutions to this (although I find it quite strange that the singleton would return an javassist instance instead of the real one) then what is the suggested way of sending a PDF to the browser?

                  If I write an own servlet for this, what util classes can be used to attach to the seam contexts from an external servlet?

                  • 6. Re: DocumentStore usage
                    pmuir

                    You can't. You'll need to do the work in the war. The war can see the jar but not vice-versa.

                    • 7. Re: DocumentStore usage
                      nickarls

                      Aah, thanks. That got rid of the class-loading stuff. Now I got a "/seam-doc.xhtml Not Found in ExternalContext as a Resource".

                      The manual gave me the impression that the pdf:s could be served ootb if you didn't need the *.pdf mapping. What component is responsible for the /seam-doc.seam mapping?

                      • 8. Re: DocumentStore usage
                        pmuir

                        I believe the phase listener in jboss-seam-pdf.jar

                        • 9. Re: DocumentStore usage
                          nickarls

                          OK, and is it one of the things that should be automagically installed by some other seam listener or filter under 2.0.0CR1? And if so, could something in ICEFaces 1.7DR1 interfere?

                          • 10. Re: DocumentStore usage
                            pmuir

                            All phase listeners are automatically installed by JSF. IceFaces could well interfere - put a breakpoint on beforePhase of DocumentStorePhaseListener and see whether it gets called.