9 Replies Latest reply: Feb 29, 2012 3:59 AM by Anil Kumar Khichar RSS

    How to serve the images in JBoss faster

    Satya K Newbie

      Hi,

       

      The requirement for my project is that user uploads the picture.

       

      Options that I came up with :

       

         1. To store the image as BLOB in DB.

         2. Save the image into a folder on my server.

       

      But I chose the second option so that I don't have to modify my HSQLDB or JPA models for storing the BLOB.

       

      Now I need to display the image.

       

      Here again I thought of two options :

       

         1. Use JBoss to serve the static images from my folder.

         2. Use the servlet to stream the images.

       

      Could you suggest which one is faster and cleaner way?

       

      I assume using the JBoss for this purpose would be better option, so could you let me know how to configure JBoss to serve static images?

       

      Regards,

      Satya

        • 1. Re: How to serve the images in JBoss faster
          iabughosh Master

          Hi Satya,

          JBoss already serves static images , you can place your files in this path :

          ${jboss-home}/server/${configuration}/deploy/ROOT.war/images.

           

          Regards.

          • 2. How to serve the images in JBoss faster
            Satya K Newbie

            I would not like to depend on ROOT.war for copying my images file to this war. I prefer to save them in a different folder convenient for me.

             

            Is there a way to serve those images from JBoss? if so how would I achieve this?

             

            Also I found link : http://community.jboss.org/wiki/UsingModjkWithJBoss

             

            Will that approach serve my requirement? Any other suggestion or approach is also most welcome.

             

            Regards,

            Satya

            • 3. Re: How to serve the images in JBoss faster
              Benjamin Seyinbour Expert

              1. To store the image as BLOB in DB.

              2.Save the image into a folder on my server.

               

               

              It would depend on your data protection and query requirements. If you are storing other people's images, then data protection requirement is a must – to be on the right side of the law (in some countries). Also database provides facilities for querying  the image.

               

              Cheers

              • 4. How to serve the images in JBoss faster
                iabughosh Master

                if you want to store the images outside the JBoss directory and download it to clients i think you'll need a Servlet.

                • 5. How to serve the images in JBoss faster
                  Wolfgang Knauf Master

                  Hi,

                   

                  see this thread for some more info: http://community.jboss.org/message/250762

                   

                  Best regards

                   

                  Wolfgang

                  • 6. How to serve the images in JBoss faster
                    Satya K Newbie

                    Hi,

                     

                    That was really helpful, but I stumbled upon another link which I was trying to utilise for my purpose.

                     

                    http://community.jboss.org/wiki/ExternalDirectories

                     

                    Is there any updated info available on the above link?

                     

                     

                    I use the JBoss 5.1 version, and the instructions provided in the above link for 5.1 version are resulting in error when I start my server.

                     

                    Below is the change I did in server.xml in "<SERVER_ROOT>\server\default\deploy\jbossweb.sar"

                     

                             <Host name="localhost">

                                <Context path="/images" appBase="" docBase="D:/images" debug="99" reloadable="true"/>

                                   - - -

                                   - - -

                                   - - -

                             </Host>

                     

                    Here is the extract of stack :

                     

                    15:36:38,883 ERROR [AbstractKernelController] Error installing to Start: name=WebServer state=Create

                    org.jboss.xb.binding.JBossXBException: Failed to parse source: Context not found as a child of Host in unordered_sequence: Listener* Valve* Alias* Realm? attributes?

                        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)

                        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:183)

                        at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:133)

                        at org.jboss.web.tomcat.service.deployers.TomcatService.startService(TomcatService.java:167)

                        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:376)

                        at org.jboss.system.ServiceMBeanSupport.pojoStart(ServiceMBeanSupport.java:216)

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

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

                        at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

                        at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

                        at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)

                        at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)

                        at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)

                        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)

                        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)

                        at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)

                        at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)

                        at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

                        at org.jboss.system.ServiceController.doChange(ServiceController.java:688)

                        at org.jboss.system.ServiceController.start(ServiceController.java:460)

                        at org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback.install(ServiceControllerStartStopLifecycleCallback.java:44)

                        at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

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

                        at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

                        at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

                        at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

                        at org.jboss.beans.info.plugins.AbstractBeanInfo.invoke(AbstractBeanInfo.java:300)

                        at org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext.invoke(AbstractKernelControllerContext.java:286)

                        at org.jboss.dependency.plugins.AbstractLifecycleCallbackItem.install(AbstractLifecycleCallbackItem.java:87)

                        at org.jboss.dependency.plugins.AbstractController.handleLifecycleCallbacks(AbstractController.java:1568)

                        at org.jboss.dependency.plugins.AbstractController.handleInstallLifecycleCallbacks(AbstractController.java:1533)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:943)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

                        at org.jboss.system.ServiceController.doChange(ServiceController.java:688)

                        at org.jboss.system.ServiceController.start(ServiceController.java:460)

                        at org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback.install(ServiceControllerStartStopLifecycleCallback.java:44)

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

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

                        at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

                        at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

                        at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

                        at org.jboss.beans.info.plugins.AbstractBeanInfo.invoke(AbstractBeanInfo.java:300)

                        at org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext.invoke(AbstractKernelControllerContext.java:286)

                        at org.jboss.dependency.plugins.AbstractLifecycleCallbackItem.install(AbstractLifecycleCallbackItem.java:87)

                        at org.jboss.dependency.plugins.AbstractController.handleLifecycleCallbacks(AbstractController.java:1568)

                        at org.jboss.dependency.plugins.AbstractController.handleInstallLifecycleCallbacks(AbstractController.java:1533)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:943)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)

                        at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)

                        at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)

                        at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)

                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)

                        at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)

                        at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)

                        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)

                        at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)

                        at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)

                        at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

                        at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)

                        at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)

                        at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)

                        at org.jboss.Main.boot(Main.java:221)

                        at org.jboss.Main$1.run(Main.java:556)

                        at java.lang.Thread.run(Unknown Source)

                    Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Context not found as a child of Host in unordered_sequence: Listener* Valve* Alias* Realm? attributes?

                        at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:383)

                        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:401)

                        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                        at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)

                        at org.apache.xerces.xinclude.XIncludeHandler.emptyElement(Unknown Source)

                        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)

                        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

                        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

                        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)

                        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

                        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

                        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)

                        at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:199)

                        ... 103 more

                     

                    Regards,

                    Satya

                    • 7. Re: How to serve the images in JBoss faster
                      Anil Kumar Khichar Newbie

                      Hi Satya,

                      Did you resolved the isuue?

                      Actually i am sandwitched in the same error while upgrading my application from jboss-4.x to jboss-6.0.0.Final.

                      The same context element was working with jboss4.x but now with 6.0.0.Final , it's showing invalid sequence and even not in the sequence list,

                       

                      If you somehow adjusted this one, please let me know. I needs it desperately.

                       

                      Thanks!

                      Anil

                      • 8. Re: How to serve the images in JBoss faster
                        saurabh agrawal Newbie

                        hi,

                         

                        have you people found any solution of this issue....

                         

                        please share it.

                         

                        thanks.

                        • 9. Re: How to serve the images in JBoss faster
                          Anil Kumar Khichar Newbie

                          Hi saurabh please follow the thread :

                          https://community.jboss.org/thread/161761

                           

                          If you found any problem let me know.