ok, i've found IBM reference implementation and got some questions:
media is added using:
| MediaEntityLocal imgSamp = mediaEntityHome.create();
| imgSamp.setName("image"+System.currentTimeMillis());
imgSamp.setContent(getServletContext().getResourceAsStream("/samples/image1.jpg"));
| imgSamp.setDescription("kocio");
| imgSamp.setMimeType("image/jpeg");
|
in database record is filled in, image content exists but when:
| MediaEntityLocal media = mediaEntityHome.findByPrimaryKey(imgId);
| resp.setContentType(media.getMimeType());
| resp.setContentLength((int) media.getSize());
|
| byte[] buffer = new byte[0x10000];
| long position = 0;
| int bytesRead = 0;
| while ((bytesRead = media.readContent(position, buffer)) != -1)
| {
| log("bytes read: " + bytesRead);
| resp.getOutputStream().write(buffer, 0, bytesRead);
| position += bytesRead;
| }
|
copied from emb spec, serwer throws this:
javax.ejb.EJBException: RuntimeException; CausedByException is:
null
org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:357)
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:514)
org.jboss.ejb.Container.invoke(Container.java:854)
org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
$Proxy102.readContent(Unknown Source)
net.homeunix.andrzejr.web.MediaLoadServlet.doGet(MediaLoadServlet.java:85)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
no content? my database is postgresql 7.4.3 (i've changed DefaultDS to other)
root cause:
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.jboss.media.entity.MediaEntity.readContent(MediaEntity.java:542)
at org.jboss.media.entity.MediaEntity.readContent(MediaEntity.java:526)
at sun.reflect.GeneratedMethodAccessor111.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
any ideas?
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3849816#3849816
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3849816
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development