12 Replies Latest reply on Feb 4, 2013 9:22 AM by schum-hacker

    jboss-as-7.1.1.Final and fop (classpath)

    schum-hacker

      Hello,

      I use fop 0.95 and jsf 1.2. with netbeans 6.9.1 like ide.

      The fop librairies are added in the WAR project but in the file, there are in the EAR not in the WAR.

      On jboss 5, all is ok, fop works fine.

      On jboss 7, i have a problem of classpath , the EAR is the same with jboss 5 or 7.

      The stacktrace:

       

      10:05:20,574 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "McustomsEAR.ear"

      10:05:24,672 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry xml-apis.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/serializer-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,674 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry servlet-2.2.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,675 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry fop-hyph.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,677 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry jai_codec.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,678 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry jai_core.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,679 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry jai_imageio.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,681 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry jimi-1.0.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,682 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry xmlunit1.0.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/fop.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,684 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry xercesImpl.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/xalan-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,685 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry xml-apis.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/xalan-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,687 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-1) Class Path entry serializer.jar in "/E:/serveur/jboss-as-7.1.1.Final/bin/content/McustomsEAR.ear/lib/xalan-2.7.0.jar"  does not point to a valid jar for a Class-Path reference.

      10:05:24,689 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "McustomsWeb.war"

      10:05:24,689 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "McustomsEjb.jar"

       

       

      please help

      Thanks !!!

        • 1. Re: jboss-as-7.1.1.Final and fop (classpath)
          nickarls

          Those are just warnings (AS7 is more pedantic). If you open up the jar files mentioned and clean out the classpath-entries in their manifest files, the warnings should go away.

          • 2. Re: jboss-as-7.1.1.Final and fop (classpath)
            schum-hacker

            it's more than just warning.

            When i call the servlet with fop:

            12:27:19,718 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) (Emplacement inconnu de l'erreur)java.net.MalformedURLException

             

             

            12:27:19,874 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/McustomsWeb].[GeneratePdf]] (http-localhost-127.0.0.1-8080-1) "Servlet.service()" pour la servlet GeneratePdf a généré une exception: java.lang.NullPointerException

                      at fr.mgi.mcustomsweb.ics.servlet.GeneratePdf.processRequest(GeneratePdf.java:122) [classes:]

                      at fr.mgi.mcustomsweb.ics.servlet.GeneratePdf.doGet(GeneratePdf.java:156) [classes:]

                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]

                      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

                      at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_30]

             

            line 122:   xslfoTransformer.transform(new StreamSource(xmlFile), res);

            • 3. Re: jboss-as-7.1.1.Final and fop (classpath)
              nickarls

              I don't think it's related. What happens at GeneratePdf.java:122? What field is referenced?

              • 4. Re: jboss-as-7.1.1.Final and fop (classpath)
                schum-hacker

                            File xmlFile;

                            StreamSource transformSource;

                 

                 

                               xmlFile = messageService.buildCC313AFile(ens);

                               // creation of transform source

                              transformSource = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("../../resources/xsl/PDFmcustoms_313.xsl"));

                 

                            // create an instance of fop factory

                            FopFactory fopFactory = FopFactory.newInstance();

                            // a user agent is needed for transformation

                            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

                            // to store output

                            ByteArrayOutputStream outStream = new ByteArrayOutputStream();

                 

                 

                            Transformer xslfoTransformer = getTransformer(transformSource);

                            // Construct fop with desired output format

                            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, outStream);

                            // Resulting SAX events (the generated FO) must be piped through to FOP

                            Result res = new SAXResult(fop.getDefaultHandler());

                 

                 

                            // Start XSLT transformation and FOP processing

                            // everything will happen here.

                            xslfoTransformer.transform(new StreamSource(xmlFile), res);

                 

                 

                the pb is here:   xslfoTransformer.transform(new StreamSource(xmlFile), res);

                 

                can i have a pb with my url "../../resources/xsl/PDFmcustoms_313.xsl" but , it's works fine in jboss 5

                • 5. Re: jboss-as-7.1.1.Final and fop (classpath)
                  sfcoy

                  JBoss 5 and earlier would allow you to get away with all sorts of classpath stuff that was not very spec compliant and therefore not very portable either.

                   

                  Where exactly in your deployment have you been placing PDFmcustoms_313.xsl?

                   

                  It looks like it's probably external to your deployment. If that's the case and you want to maintain that arrangement then have a look at How to put an external file in the classpath.

                  • 6. Re: jboss-as-7.1.1.Final and fop (classpath)
                    schum-hacker

                    in my project McustomsWeb\web\resources\xsl\PDFmcustoms_313.xsl

                    xsl url: http://localhost:8080/McustomsWeb/resources/xsl/PDFmcustoms_313.xsl

                    servlet url: http://localhost:8080/McustomsWeb/GeneratePdf

                    • 7. Re: jboss-as-7.1.1.Final and fop (classpath)
                      sfcoy

                      The correct way to access the XSL resource in this case is to use javax.servlet.ServletContext.getResourceAsStream(java.lang.String).

                       

                      If you need a reference to pass around or stash then use javax.servlet.ServletContext.getResource(java.lang.String) and java.net.URL.openStream().

                       

                      Alternatively, move it to WEB-INF/classes and access it using the TCCL as you were above (without the "../../").

                      • 8. Re: jboss-as-7.1.1.Final and fop (classpath)
                        schum-hacker

                        I use a string:

                        transformSource = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("../../resources/xsl/PDFmcustoms_313.xsl"));

                        so i'm a little confused on the way to follow to correct my pb ...

                        in my project McustomsWeb\src\java\fr\mgi\mcustomsweb\ics\servlet\GeneratePdf.java

                         

                        i try absolute path:

                        transformSource = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("http://localhost:8080/McustomsWeb/resources/xsl/PDFmcustoms_313.xsl"));

                        same error


                        • 9. Re: jboss-as-7.1.1.Final and fop (classpath)
                          sfcoy

                          {code}McustomsWeb/resources/xsl/PDFmcustoms_313.xsl{code}

                           

                          is not on any classpath. The fact that you could access it on the classpath in JBoss 5 was a happy accident that was never portable.

                           

                          Therefore, you have two choices:

                          1. access it as a web resource from your servlet context
                          2. move it so that it's available on the classpath (into WEB-INF/classes) and access it the same way that you are now, but removing the "../../" from the path
                          • 10. Re: jboss-as-7.1.1.Final and fop (classpath)
                            schum-hacker

                            thanks

                            it works fine if:

                            i move PDFmcustoms_313.xsl in the directory McustomsWeb\src\java

                            transformSource = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("PDFmcustoms_313.xsl"));

                             

                            I'd like to keep my file PDFmcustoms_313.xsl in

                            McustomsWeb\web\resources\xsl\PDFmcustoms_313.xsl

                            but in this case  in don't found the string to use in getResourceAsStream(?)

                            • 11. Re: jboss-as-7.1.1.Final and fop (classpath)
                              sfcoy

                              If you leave the file where it is then it will not be visible on any classpath. You have to use option 1 above. Click on the links in my original response to find out more.

                               

                              Having said that, do you really want this XSL to be accessible from a web browser?

                              • 12. Re: jboss-as-7.1.1.Final and fop (classpath)
                                schum-hacker

                                i haven't this need .

                                So i stay like this.

                                thanks very much !!!!!!!