Hi Rafa,

We're getting the same error. I think it's because the creativecommons url
doesn't expose a content-length in the header. Possibly a recent change
because it seemed to be working for us last month.

I'm using the following (untested) workaround:

*Add to the imports...*
import java.io.BufferedReader;
import java.io.InputStreamReader;

*Replace everything in the try{} block with...*
URL url = new URL(url_string);
URLConnection connection = url.openConnection();
InputStream inputStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new
InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();

while ((line = reader.readLine()) != null)
    sb.append(line);

return sb.toString().getBytes();



Instead of declaring a byte array upfront (which requires the length), I
read in the entire file and then output the byte array. As a side note, it
looks like version 1.8.0 catches the generic "Exception" and just swallows
the error.

Hope that helps,

Daniel Ishimitsu
Hamilton Library, DNS
University of Hawaii at Manoa



On Mon, Dec 5, 2011 at 10:23 AM, Rafa Carreres <[email protected]> wrote:

> **
> [This is a repost. Sorry for the inconvenience.]
>
>
> Hi,
>
> I have a DSpace test instance with 1.7.1, jspui, Oracle and  java6.
>
> When I submit an item and grant a CC license or edit an item and want to
> substitute the CC license by a different one, I get this  error:
>
> ....................
>
> - URL Was:
> http://ruadesa.ua.es/jspui/tools/edit-item?item_id=19065&cc_license_url=http%3A%2F%2Fcreativecommons.org%2Flicenses%2Fby%2F3.0%2F
>
> -- Method: GET
> -- Parameters were:
> -- item_id: "19065"
> -- cc_license_url: 
> "http://creativecommons.org/licenses/by/3.0/";<http://creativecommons.org/licenses/by/3.0/>
>
>
> Exception:
> java.lang.NegativeArraySizeException
> at org.dspace.license.CreativeCommons.fetchURL(CreativeCommons.java:393)
> at
> org.dspace.license.CreativeCommons.fetchLicenseText(CreativeCommons.java:268)
> at org.dspace.license.CreativeCommons.setLicense(CreativeCommons.java:130)
> at
> org.dspace.app.webui.servlet.admin.EditItemServlet.showEditForm(EditItemServlet.java:379)
> at
> org.dspace.app.webui.servlet.admin.EditItemServlet.doDSGet(EditItemServlet.java:135)
> at
> org.dspace.app.webui.servlet.DSpaceServlet.processRequest(DSpaceServlet.java:119)
> at org.dspace.app.webui.servlet.DSpaceServlet.doGet(DSpaceServlet.java:67)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
> at
> org.dspace.app.webui.filter.RegisteredOnlyFilter.doFilter(RegisteredOnlyFilter.java:66)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
> at
> org.dspace.utils.servlet.DSpaceWebappServletFilter.doFilter(DSpaceWebappServletFilter.java:78)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:544)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
> at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
> at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
> at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
> at
> org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
> at
> org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
> at java.lang.Thread.run(Thread.java:662)
> ...............................................
>
> After tracking the error log, I've found that DSpace can't execute
> fetchURL successfully, but if I comment that part of the code, it works.
> That is, I can see the license_rdf and the license_url bitstreams, but of
> course, there's no license_txt.
>
>
> I've commented this lines at CreativeCommons.java:
>
> -------------------
> 127c127
> < // String license_text = fetchLicenseText(cc_license_url);
>
> 145,146c144,145
>
> > setBitstreamFromBytes(item, bundle, BSN_LICENSE_TEXT, bs_text_format,
> > license_text.getBytes());
> -------------------
>
>
> I think I'm very close to the solution but I can't find it. Any help would
> be appreciated
>
> Regards.
>
> Rafa Carreres
> Institutional Repository Administrator (http://rua.ua.es)
> University of Alicante
> Spain
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
>
> _______________________________________________
> DSpace-tech mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dspace-tech
>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to