Viniciustelles 8 de mar. de 2013
evandro_araujo 8 de mar. de 2013
Abri o xml e e editei colocando o parametro $P{caminho}, quando eu rodo pelo preview e coloco o caminho dá tudo certo, porem
normalmente atraves da pagina (passando parametro pelo java ) da o erro abaixo :
<image>
<reportElement uuid= "d843cd63-df0f-49d4-9985-3652a7c0d6b0" x= "725" y= "0" width= "77" height= "102" />
<imageExpression> <![CDATA[$P{caminho}]]> </imageExpression>
</image>
*********************** bean
Map<String , Object > map = new HashMap<String , Object > ();
map.put("caminhologo", "/resources/images/logo_unimedfb1.jpg");
AVISO : # { cadguiaMbean . executarRelatorioguiaservico }: net . sf . jasperreports . engine . JRException : Byte data not found at : / resources / images / logo_unimedfb1 . jpg
javax . faces . FacesException : # { cadguiaMbean . executarRelatorioguiaservico }: net . sf . jasperreports . engine . JRException : Byte data not found at : / resources / images / logo_unimedfb1 . jpg
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 118 )
at javax . faces . component . UICommand . broadcast ( UICommand . java : 315 )
at javax . faces . component . UIViewRoot . broadcastEvents ( UIViewRoot . java : 794 )
at javax . faces . component . UIViewRoot . processApplication ( UIViewRoot . java : 1259 )
at com . sun . faces . lifecycle . InvokeApplicationPhase . execute ( InvokeApplicationPhase . java : 81 )
at com . sun . faces . lifecycle . Phase . doPhase ( Phase . java : 101 )
at com . sun . faces . lifecycle . LifecycleImpl . execute ( LifecycleImpl . java : 118 )
at javax . faces . webapp . FacesServlet . service ( FacesServlet . java : 593 )
at org . apache . catalina . core . StandardWrapper . service ( StandardWrapper . java : 1550 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 281 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 175 )
at org . apache . catalina . core . StandardPipeline . doInvoke ( StandardPipeline . java : 655 )
at org . apache . catalina . core . StandardPipeline . invoke ( StandardPipeline . java : 595 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 161 )
at org . apache . catalina . connector . CoyoteAdapter . doService ( CoyoteAdapter . java : 331 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 231 )
at com . sun . enterprise . v3 . services . impl . ContainerMapper $ AdapterCallable . call ( ContainerMapper . java : 317 )
at com . sun . enterprise . v3 . services . impl . ContainerMapper . service ( ContainerMapper . java : 195 )
at com . sun . grizzly . http . ProcessorTask . invokeAdapter ( ProcessorTask . java : 860 )
at com . sun . grizzly . http . ProcessorTask . doProcess ( ProcessorTask . java : 757 )
at com . sun . grizzly . http . ProcessorTask . process ( ProcessorTask . java : 1056 )
at com . sun . grizzly . http . DefaultProtocolFilter . execute ( DefaultProtocolFilter . java : 229 )
at com . sun . grizzly . DefaultProtocolChain . executeProtocolFilter ( DefaultProtocolChain . java : 137 )
at com . sun . grizzly . DefaultProtocolChain . execute ( DefaultProtocolChain . java : 104 )
at com . sun . grizzly . DefaultProtocolChain . execute ( DefaultProtocolChain . java : 90 )
at com . sun . grizzly . http . HttpProtocolChain . execute ( HttpProtocolChain . java : 79 )
at com . sun . grizzly . ProtocolChainContextTask . doCall ( ProtocolChainContextTask . java : 54 )
at com . sun . grizzly . SelectionKeyContextTask . call ( SelectionKeyContextTask . java : 59 )
at com . sun . grizzly . ContextTask . run ( ContextTask . java : 71 )
at com . sun . grizzly . util . AbstractThreadPool $ Worker . doWork ( AbstractThreadPool . java : 532 )
at com . sun . grizzly . util . AbstractThreadPool $ Worker . run ( AbstractThreadPool . java : 513 )
at java . lang . Thread . run ( Thread . java : 662 )
Caused by : javax . faces . el . EvaluationException : net . sf . jasperreports . engine . JRException : Byte data not found at : / resources / images / logo_unimedfb1 . jpg
at javax . faces . component . MethodBindingMethodExpressionAdapter . invoke ( MethodBindingMethodExpressionAdapter . java : 102 )
at com . sun . faces . application . ActionListenerImpl . processAction ( ActionListenerImpl . java : 102 )
… 31 more
Caused by : net . sf . jasperreports . engine . JRException : Byte data not found at : / resources / images / logo_unimedfb1 . jpg
at net . sf . jasperreports . repo . RepositoryUtil . getBytesFromLocation ( RepositoryUtil . java : 324 )
at net . sf . jasperreports . engine . RenderableUtil . getRenderable ( RenderableUtil . java : 121 )
at net . sf . jasperreports . engine . fill . JRFillImage . evaluateImage ( JRFillImage . java : 527 )
at net . sf . jasperreports . engine . fill . JRFillImage . evaluate ( JRFillImage . java : 463 )
at net . sf . jasperreports . engine . fill . JRFillElementContainer . evaluate ( JRFillElementContainer . java : 259 )
at net . sf . jasperreports . engine . fill . JRFillBand . evaluate ( JRFillBand . java : 459 )
at net . sf . jasperreports . engine . fill . JRVerticalFiller . fillTitle ( JRVerticalFiller . java : 344 )
at net . sf . jasperreports . engine . fill . JRVerticalFiller . fillReportStart ( JRVerticalFiller . java : 280 )
at net . sf . jasperreports . engine . fill . JRVerticalFiller . fillReport ( JRVerticalFiller . java : 151 )
at net . sf . jasperreports . engine . fill . JRBaseFiller . fill ( JRBaseFiller . java : 909 )
at net . sf . jasperreports . engine . fill . JRBaseFiller . fill ( JRBaseFiller . java : 841 )
at net . sf . jasperreports . engine . fill . JRFiller . fill ( JRFiller . java : 88 )
at net . sf . jasperreports . engine . JasperFillManager . fill ( JasperFillManager . java : 653 )
at net . sf . jasperreports . engine . JasperFillManager . fill ( JasperFillManager . java : 634 )
at net . sf . jasperreports . engine . JasperFillManager . fillReport ( JasperFillManager . java : 956 )
at br . uniplan . controle . CadguiaMb . executarRelatorioguiaservico ( CadguiaMb . java : 696 )
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 : 597 )
at com . sun . el . parser . AstValue . invoke ( AstValue . java : 254 )
at com . sun . el . MethodExpressionImpl . invoke ( MethodExpressionImpl . java : 302 )
at org . jboss . weld . util . el . ForwardingMethodExpression . invoke ( ForwardingMethodExpression . java : 39 )
at org . jboss . weld . el . WeldMethodExpression . invoke ( WeldMethodExpression . java : 50 )
at com . sun . faces . facelets . el . TagMethodExpression . invoke ( TagMethodExpression . java : 105 )
at javax . faces . component . MethodBindingMethodExpressionAdapter . invoke ( MethodBindingMethodExpressionAdapter . java : 88 )
… 32 more
evandro_araujo 8 de mar. de 2013
consegui resolver dessa forma :
HttpSession sessao = ( HttpSession ) FacesContext . getCurrentInstance (). getExternalContext (). getSession ( false );
File logoFile = new File ( sessao . getServletContext (). getRealPath ( System . getProperty ( "file.separator" ) + "resources" + System . getProperty ( "file.separator" ) + "images" + System . getProperty ( "file.separator" ) + "logo_unimedfb1.jpg" ));
String caminho = logoFile . getAbsolutePath ();
InputStream inputStreamDaImagem = null ;
try {
File file = new File ( caminho );
if ( file . exists ()) //testa se imagem existe
inputStreamDaImagem = new FileInputStream ( file );
} catch ( FileNotFoundException e ) {
e . printStackTrace ();
}
map . put ( "caminhologo" , caminho );