7 Replies Latest reply on May 15, 2009 6:43 AM by Arbi Sookazian

    Can Seam handle binary images from db resultset?

    Arbi Sookazian Master

      Regarding rendering images stored in a RDBMS table, is it possible to read and display a binary image in Seam app?


      e.g.


      SELECT [web_smallImage]
        FROM corg0dv01.[coxReports].[dbo].[temp_images_test]



      result:


      0xFFD8FFE000104A46494600010200006400640000FFEC00114475636B7900010004000000640000FFEE000E41646F62650064C000000001FFDB008400010101010101010101010101010101010101010101010101010101010101010101010101010101010101010202020202020202020202030303030303030303030101010101010102010102020201020203030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303FFC00011080068007803011100021101031101FFC4009D0001000006030101000000000000000000000304050708090102060B0A01010101010101000000000000000000000002010304051000010302050105040706030900000000010203040005111206070821314122130961D1521451819132922315714216171819A18233D435456536664728481101000104010205040203000000000000000111021203213141516171A11381E12204F03291B114FFDA000C03010002110311003F00FDFC5028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A050513526A4B068FB05E354EA9BC5BB4FE9CD3F6F9576BDDEEED29A856DB65BA134A7A54C9929F525A65965B492493EC1D48141A02DCFF005D37AD5AF2FF0067DA2D82635A682B74B30EC9ABB54EAFB8698B9EA2433F96FDD5160634DDC176CB7C97413190F3BF3059CAA750D2D45A44E5E02856FF005BDDDAB8C61293C66D1719B5ACA50246E5DE829601C0AD213A40928C7A0270C7BAB3296D213DFDEB3777103FA75D00927B8EE36A13F5FF00D26053291DFF00BD46EE9ECE3DEDE8EDFF00C83A8940E1EDFE1848E94CCA3A9F5A7DDF3D13B01B780F703AE751ABD98FFB8518F53599CD2A70807D6937A48F0EC2EDAA7E8CDAC75228777D16D4E34CE4E1057EB4BBDC9FBBB17B5FDDD0EABD52AFF110923B299C9C241CF5ABDF64E211B1BB5208F8F536AD3DBEC0C0A6725120E7AD7F2087FA7B21B407D86FFAC49F67EFA71270A67271579CBAFAE3F23ADAA404EC16D34842C7471ABC6B15A42C138B641988585E03A62003DD4CE58CA3E23FAD2691DD2D4CAD0DC97D236AD95BA5CE625AD31ADED3367CCDBF78BA96D08B66A776E45CB8698945FC724D716EC05255F9CA8C1199CA8BBC46F2E3C8625B0C4A8AFB3262C965B911A4C7710F3121879097197D879B529B75975B5052549252A49041C2A846A0506A5BD40ED16DDCE9AD684DC4DDBBE685DB9B6DD20B71F4A69EB389117525D459AD77B55DF53BE87DD953D9B49B812842D0DC2889425D524BB83955669D9BA6635F66CCD96C44DFD2583EC7A756D5E54F95AE7523C1C212D9458EDAB2BCD80484E5B978B363D30EDA8C67A57D978DAC639F65F4E6B4CD9B6C9DCF1D95893ED5324DB2E16E97BA7B551E5DBAE16F90E449B02546775921D8B2E149656D3ADA9216DAD0524020D235DDFC84CE3E74426E2FA6FA8628E796C6127A63FCDADA5C32E20E031D662B3E3BBC7DBEECFC7CD3E2CDE9D69C31E76EC834492521FDD4DA44E61D312336B449576F68ACF8E67D3D3EEDFC7BD536D5ABD3B13FFDD1B02F859094891BADB467020E24232EBF631C71F6D3E2BBF9056C4C8B5FA73A48079CBC78054024056EAED29C71230C0277113D4E423EB3F56FC577D3D3EE9FC3EA86EDA7D3897827FAEBE3E327EF8F2F76369FC49E831CBFCC451CA0A7BBBC9FA9F1DDF4F4FB918F9A0AF4F7A6FAD38FF5E7B01DC3AEECED48ECEDECDC34F654FC73E3ECAA594FBA45DD39E9B18292AE7DEC033DE47F3736A8603A1C48FE628FB6B309AF33ECD8B6C9F1488D13E9A72D611FDC2F60417084841DD9DA8585127001215B8C3139BB30ACC67BC985BE6CACFED77B5F716DA79ADCDBEA9B79B6DE69E6B4D42710EB2EA12B6DC439FC464388710A052A1D08208ADA4C2BE3B7B3639C33DAAD61C7E916CDBA87BCB7FD77B712D52A3DBB486ACB034BFE185316BBADC507495E117F7E5D9E23AFC54F9B11487E194E62DB4D38B53B55133134EC5DAE222B56C96ADC8A0D6DF2634F69DD45B897487A8EC76EBDC78D32CB7586CDCE322536C4D62C3686DB96C25C4F81680DE5E98A48041C7A8AAD7B2FD7333AEE9899E385636DD111745616FE0CF4312E18EC025472475C07E6A7123B6A5757CAFB7AEC7BDCDEFAEF8C1D352F54356E637A776D30E15B351BB162B4CCADC5D4B2434CC46E6B6DB6642D6A596C271512491DB5DEDFDEB74D9165D7CDB1DA2AE13FAD3B666EB6D899F463CB5A2F5AAEEAC5CAE167766B9FA83336638F4D82F3B29499287DF53AB75F25E71E09389513989EB5B76ED7744C4CCD67C931AEF8F45D6DCF5DEB59B5676E1D9AED2956E7A4AD4EDD136C8CB8F1DD69B433062945DA795446CA494825253DE547A8E5A6FB2C9ADDD1D2F8BAE8E3AA9BA12E9ABF41C0D5F6D6B40596FA357D9FF4A2FDE1D8E5FB4210CCF65532DC199013E78F9FC4E6E98B69F6D5DF7E9D975B74DDB2DC6EAFE3336C4F95DE31E5EAF77E87EFEDFD0D5BF4DBFAFF00A9BBE7B31AEED76ECBB5F13F96A99FE9773FDA39E23C1EDA5EE5EBA9AD4F4AF6934086EE28BE672DC46006D17CB4DAAD4E7945339272C46ED21C6FE9538A07A615DFFE9D33E2F9F4BE38A44A87ABF56EB4D69A4AEDA40ED6E8EB47EB7AFD1B86E5EAD2586AECC3E8B126C3FA1C671E94E25BB229B4079481862FF8B0EA6A277EA99EEA9CEEB31A44735AF75937B6EF59AF140B2A5B57438895071031E83A387127D9D6A6776A9F14C5B7C4F48987B1D33A4F71203B021CB17985638EF3921C163976272E2CAD61C507A1B5707998A5C53CE78B3AC0CA4F7F4A46ED713115BB0F76CDB752B11197B2E045D257396E4D80CB1B853245DEE101888EDCEF1A2D882FB2530E3045F20C68D3243C50EF989063C86F16B2740ACD5576FD185D6DB37D67A74F7FB269B32899C78EBD7D9F59BD39292D59AC91BA831ECD68630EA30F22DD19AECFF2D787BBD56F45E4DB191E66BBD2E9EB899F711D4FFDADA8D5F5FDDA4758FE762FFEB2CC9AE8E05063FEE06DE694D49A964DCEEF6832E629988C29E4CEB9C50B4331D01B2A6A1CC8ECA9C4A559739495948009C12900D858A1C52DA156AE4EB11137185D8CA327E513BE5BE28D2E975C4F967268A46E2A74734C253F7194C00CA15E24A02BAD3BB6AD5A5DB6078D10751EAD278B7C777DDB85E6F8D5C263BB03B4EF4EB979D729AA90F5CE739A4D52AEB265B8E296EBB254F29E714A52F32944989D7973482DBF1AC5679F37881C60E2A28848E22717C951091FFAD1B22312AC00E9FC11D3AD5E1DF84E51D153B9717F8CA551D73F891C6274A23B51582AE3B6CB4AC8C474E0DB492AD20F169B4255E14029401D80566333E0DAD1018E35F191B8AF4263891C67F955BEC4B7DA6F8DFB39E497E3625879C65BD1A1852DAEB956A415A7F7542AB1B99947546738E1C6774490E712B8D0AF9B9A8B8C9CDC6ED9E525D98D059121D0E68E579AF361D27CC7333A9CDD143138B09A72561D5CE37F199C61F65EE24F1A0C69138CD9095F1B76754D2E714A8171C4B9A354CB9232A8F8960BB81FBDDB4C64CBFCBBC5E3D718E0332D88BC50E3330CCE6BC89486B8E3B38C21E6866F03CDC7D1CD36FA3C47C2E05A7AF676D66326487178D1C5B71E4A18E24F187CD513930E366C8358900927CC568C6D29E9F49A6333C155619E30F1ADA790F1E23F1A5098CFB45C7DAE38EC91F21414DB8141D6B4828A5690A04149C41F6D275CC7342ADBDC6E32ED50D428D5C98DB808B9ACA247C9B7BD3BD2DE974A96C06FCB6B44237013A3198C941F0B48809692702120806A691555785F6D2BA42C367BC5B64C1B7F94F4653C865D724CD94A6C1B74C60AD225C97D21D534B524B9867214A18F88E3A4AEFD6A4A0F1F7BB4489B214E4791F2EAF35B5295E0C5684B2D2427C495E29CC9EA3018FD22B629DC9AF6709B425241F092083DA9EE38FD358DAB1CA571774FCB972E5BB70694E4B972A5ACAA0AF36694FB8F904A2E6DA0E42E618E518E1559268911C50B08585A6F4A490ACE948B73252920E200CD2D4481ED26B2B2D4ECAE2ED92584072F25010A2AC1BB7B4732940052959E628E6561D6B2381DE1F18AD301B92DC7BF2D2996D792F636E60928C163A1F9CE87059A4F3499ECE9AF6ECD517459348BA293C44F1F58FF0049C571C212C2C1D42AFCCF3B3616A8A3FD76DB6978612BA785A1855652E6812F8D16E9B19D88FEA1714C3B345C16916C8E0FCC867C80A07E6CE080DF7765665276A76524F1374E9FF8E3BD7FE5F1FF00DAB0A65274454714B4EA1213FAB2578127172D8D29471EE51139230FAA951D8714F4E8248BBB693882149B537991861F7319C70EA31EFA5464EB56C436DA118A4E442118E2918E4484E3DBDF85637AA762434B721A73C38A14A230231EACBA8FA71FDEA1CAB946141C1483DA01FDA01A0E3223E14FE11EEA06447C29FC23DD40C88F853F847BA81911F0A7F08F75032A7E14FD8281953F0A7EC140CA9F853F60A06447C29FC23DD40C88F853F847BA81911F0A7F08F7503223E14FE11EEA0E4240EC007EC00507340A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A05028140A0FFD9

        • 1. Re: Can Seam handle binary images from db resultset?
          raja garlapati Newbie
          Yes we can ,

          Eg: <s:graphicImage value="#{XYZ.image}" />

          where image is the byte[].

          • 2. Re: Can Seam handle binary images from db resultset?
            Arbi Sookazian Master

            raja garlapati wrote on May 14, 2009 21:12:


            Yes we can ,

            Eg: <s:graphicImage value="#{XYZ.image}" />

            where image is the byte[].




            Thx for the reply.  I tried the following:


            .xhtml:


            <s:graphicImage value="#{testBackButtonAction.image}" />  



            SFSB:


            public byte[] getImage() {
                      List list = entityManager.createNativeQuery("SELECT [web_smallImage] "+
                                                                             " FROM corg0dv01.[coxReports].[dbo].[temp_images_test] ")
                                                            .getResultList();
                      image = (byte[])list.get(0);
            
                      return image;
                 }



            result:


            14:08:29,372 INFO  [ProfilingInterceptor] *** Method class org.jboss.ejb3.interceptor.InvocationContextImpl.public byte[] com.cox.bets.session.TestBackButtonAction.getImage() executed in 109ms ***
            14:08:29,403 ERROR [STDERR] May 14, 2009 2:08:29 PM com.sun.facelets.FaceletViewHandler handleRenderException
            SEVERE: Error Rendering View[/TestBackButton1.xhtml]
            javax.faces.FacesException: javax.el.ELException: /TestBackButton1.xhtml @29,61 value="#{testBackButtonAction.image}": Error reading 'image' on type org.javassist.tmp.java.lang.Object_$$_javassist_6
                 at javax.faces.component.UIGraphic.getValue(UIGraphic.java:151)
                 at org.jboss.seam.ui.graphicImage.GraphicImageRendererBase.doEncodeBegin(GraphicImageRendererBase.java:31)
                 at org.jboss.seam.ui.util.cdk.RendererBase.encodeBegin(RendererBase.java:79)
                 at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:808)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
                 at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
                 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
                 at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:239)
                 at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178)
                 at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126)
                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:832)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                 at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                 at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
                 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:125)
                 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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 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:178)
                 at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                 at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                 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:182)
                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                 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:241)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                 at java.lang.Thread.run(Thread.java:595)
            Caused by: javax.el.ELException: /TestBackButton1.xhtml @29,61 value="#{testBackButtonAction.image}": Error reading 'image' on type org.javassist.tmp.java.lang.Object_$$_javassist_6
                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
                 at javax.faces.component.UIGraphic.getValue(UIGraphic.java:148)
                 ... 62 more
            Caused by: javax.ejb.EJBTransactionRolledbackException: org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
                 at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
                 at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
                 at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:94)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                 at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
                 at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:117)
                 at $Proxy287.getImage(Unknown Source)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                 at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationCon
            14:08:29,403 ERROR [STDERR] text.java:56)
                 at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                 at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
                 at org.javassist.tmp.java.lang.Object_$$_javassist_6.getImage(Object_$$_javassist_6.java)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
                 at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                 at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
                 at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
                 at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                 at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                 ... 63 more
            Caused by: javax.persistence.PersistenceException: org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
                 at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
                 at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:74)
                 at com.cox.bets.session.TestBackButtonAction.getImage(TestBackButtonAction.java:76)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                 at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                 at com.cox.bets.utils.ProfilingInterceptor.profile(ProfilingInterceptor.java:22)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                 at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                 at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                 at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                 at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                 ... 103 more
            Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
                 at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
                 at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
                 at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)
                 at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
                 at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
                 at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
                 at org.hibernate.loader.Loader.getResultSet(Loader.java:1796)
                 at org.hibernate.loader.Loader.doQuery(Loader.java:674)
                 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
                 at org.hibernate.loader.Loader.doList(Loader.java:2220)
                 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
                 at org.hibernate.loader.Loader.list(Loader.java:2099)
                 at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
                 at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
                 at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
                 at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
                 at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:65)
                 ... 148 more

            • 3. Re: Can Seam handle binary images from db resultset?
              Arbi Sookazian Master

              this fails as well with same exception:


              public byte[] getImage() {
                        image = (byte[])entityManager.createNativeQuery("SELECT [web_smallImage] "+
                                                                               " FROM corg0dv01.[coxReports].[dbo].[temp_images_test] ")
                                                              .getSingleResult();
                        //image = (byte[])list.get(0);
              
                        return image;
                   }
              

              • 4. Re: Can Seam handle binary images from db resultset?
                raja garlapati Newbie

                Hi ,
                   May be something related to your query. Keep a try catch over the query and see by debug or print a error stt whether the query is getting execute correctly,
                   I doubt it doesn't, If you get back a list this should work fine.

                • 5. Re: Can Seam handle binary images from db resultset?
                  Arbi Sookazian Master

                  So I just tried using JDBC instead of JPA/Hibernate.  The value of the image variable is null and no exception is thrown.  The definition of the column is varbinary(max) in SQL SERVER 2005.  Then there is image data type.  Not sure if we should try that instead.


                  public byte[] getImage() {
                                      
                            Connection con = null;
                            Statement stmt = null;
                            ResultSet rs = null;
                            
                            try {
                                 con = jdbcUtils.getConnection("java:boBETSDatasource");
                                 if (con != null){             
                                    stmt = con.createStatement();
                                    rs = stmt.executeQuery("SELECT [web_smallImage] FROM corg0dv01.[coxReports].[dbo].[temp_images_test]");
                                    while(rs.next()){
                                         byte[] image = rs.getBytes("web_smallImage");
                                                 //image is null here
                                    }
                                    
                                    rs = stmt.executeQuery("select serialnumber from equipment where equipmentid = 1");
                                    while(rs.next()){
                                         log.info("serialnumber = "+rs.getString("serialnumber"));
                                                  // this logs out fine!
                                    }
                                    }
                           } catch (Exception e) {
                                log.error("in getImage(), error occured",e);
                           } finally {     
                                 try {
                                      cleanUp(con, stmt, rs);
                                 }
                                 catch (SQLException e) {
                                      log.error("getImage(): SQLException caught: ", e);
                                 }
                            }          
                  
                  
                            return image;
                       }



                  As a side note, and this is most likely a Seam bug related to <s:graphicImage>, if the method proceeds with image = null, I get this:


                  16:16:18,156 ERROR [ExceptionFilter] handling uncaught exception
                  javax.servlet.ServletException: java.lang.NullPointerException
                       at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:74)
                       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:617)
                       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                       at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:125)
                       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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                       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:178)
                       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
                       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
                       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:182)
                       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                       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:241)
                       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                       at java.lang.Thread.run(Thread.java:595)
                  Caused by: java.lang.NullPointerException
                       at org.jboss.seam.ui.graphicImage.GraphicImageResource.doWork(GraphicImageResource.java:67)
                       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)
                       ... 46 more

                  • 6. Re: Can Seam handle binary images from db resultset?
                    Francisco Jose Peredo Noguez Master

                    Your original stacktrace has:


                    Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
                    



                    as the root exception, that looks like an error in the mappings of your @Entity (or a limitation in the Hibernate dialect for your database) therefore this question could be a better match the hibernate forum

                    • 7. Re: Can Seam handle binary images from db resultset?
                      Arbi Sookazian Master

                      You're right.  I got the JDBC version working (I was using a local variable for image rather than the instance variable, local variable goes out of scope in try block, so instance was returned as always null (bug!))


                      And yes, this is a question for the Hibernate forum.


                      I don't have a mapped entity class yet but I will try that tomorrow with @Lob annotation as suggested in Bauer/King book.


                      http://java.sun.com/javaee/5/docs/api/javax/persistence/Lob.html


                      ex:


                      @Lob
                      @Column(name="foo")
                      private byte[] image;



                      The question is how to get it to work using JPA native query b/c in that case there is no entity mapping, etc.