ERROR - Failed to import resource foo.xsd. All database operations will be rolled back. String index out of range: -1

wolfb's picture

When I try to import any of my XSDs into Registry I recieve the same error (on the console), the UI just jumps to the Entry view without complaining. The XSD is not added.

Here is what I do:

use Registry 2.0.1 or nightly build 382 (Linux)
Add Resource -> Import content from URL
URL: http://localhost:8080/FlayService/Flay?xsd=1
set name to Flay.xsd
set mediatype to: application/x-xsd+xml
(annotation: it would be nice if Registry would set the name and media type correctly for the above URI syntax)

the XSD in question:

<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3.1-hudson-417-SNAPSHOT. --><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://test.ws/schema/Flay" targetNamespace="http://test.ws/schema/Flay" elementFormDefault="qualified">

    <xsd:complexType name="foo">
        <xsd:sequence>
            <xsd:element name="bar" type="xsd:int"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>

</xsd:schema>

Press 'Add'

What happens:
the UI jumps to the Entry view, nothing is added.
Registry says (on the console):

[2009-05-14 13:54:17,905] ERROR -  Failed to import resource /Flay.xsd. All database operations will be rolled back. String index out of range: -1 {org.wso2.carbon.registry.core.jdbc.AtomicRegistry}
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(Unknown Source)
        at org.wso2.carbon.registry.extensions.handlers.utils.SchemaProcessor.evaluateSchemasRecursively(SchemaProcessor.java:186)
        at org.wso2.carbon.registry.extensions.handlers.utils.SchemaProcessor.importSchemaToRegistry(SchemaProcessor.java:102)
        at org.wso2.carbon.registry.extensions.handlers.XSDMediaTypeHandler.importResource(XSDMediaTypeHandler.java:140)
        at org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager.importResource(HandlerManager.java:282)
        at org.wso2.carbon.registry.core.jdbc.BasicRegistry.importResource(BasicRegistry.java:323)
        at org.wso2.carbon.registry.core.jdbc.AtomicRegistry.importResource(AtomicRegistry.java:284)
        at org.wso2.carbon.registry.core.jdbc.JDBCRegistry.importResource(JDBCRegistry.java:496)
        at org.wso2.carbon.registry.core.session.UserRegistry.importResource(UserRegistry.java:323)
        at org.wso2.carbon.registry.core.CarbonRegistry.importResource(CarbonRegistry.java:277)
        at org.wso2.carbon.registry.mgt.ui.resource.services.utils.ImportResourceUtil.importResource(ImportResourceUtil.java:52)
        at org.wso2.carbon.registry.mgt.ui.resource.services.ResourceService.importResource(ResourceService.java:79)
        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.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:205)
        at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:63)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        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.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Unknown Source)
[2009-05-14 13:54:17,908] ERROR -  Failed to import resource from the URL http://localhost:8080/FlayService/Flay?xsd=1 to path /Flay.xsd. Failed to import resource /Flay.xsd. All database operations will be rolled back. String index out of range: -1 {org.wso2.carbon.registry.mgt.ui.resource.services.utils.ImportResourceUtil}
org.wso2.carbon.registry.core.exceptions.RegistryException: Failed to import resource /Flay.xsd. All database operations will be rolled back. String index out of range: -1
        at org.wso2.carbon.registry.core.jdbc.AtomicRegistry.importResource(AtomicRegistry.java:299)
        at org.wso2.carbon.registry.core.jdbc.JDBCRegistry.importResource(JDBCRegistry.java:496)
        at org.wso2.carbon.registry.core.session.UserRegistry.importResource(UserRegistry.java:323)
        at org.wso2.carbon.registry.core.CarbonRegistry.importResource(CarbonRegistry.java:277)
        at org.wso2.carbon.registry.mgt.ui.resource.services.utils.ImportResourceUtil.importResource(ImportResourceUtil.java:52)
        at org.wso2.carbon.registry.mgt.ui.resource.services.ResourceService.importResource(ResourceService.java:79)
        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.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:205)
        at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:63)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        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.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(Unknown Source)
        at org.wso2.carbon.registry.extensions.handlers.utils.SchemaProcessor.evaluateSchemasRecursively(SchemaProcessor.java:186)
        at org.wso2.carbon.registry.extensions.handlers.utils.SchemaProcessor.importSchemaToRegistry(SchemaProcessor.java:102)
        at org.wso2.carbon.registry.extensions.handlers.XSDMediaTypeHandler.importResource(XSDMediaTypeHandler.java:140)
        at org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager.importResource(HandlerManager.java:282)
        at org.wso2.carbon.registry.core.jdbc.BasicRegistry.importResource(BasicRegistry.java:323)
        at org.wso2.carbon.registry.core.jdbc.AtomicRegistry.importResource(AtomicRegistry.java:284)
        ... 37 more
... and lots more

krishantha's picture

Hi.., If it is possible, can

Hi.., If it is possible, can you please attach your XSD file in here. Then we could check what actually went wrong. I assume you got this error with registry 2.0.1 as well. If not please check with registry 2.0.1 and let us know the results. (annotation: it would be nice if Registry would set the name and media type correctly for the above URI syntax) yes we have fixed this issue on upcoming wso2 governance registry which is going to be out on end of May. Thanks, Krishantha.
wolfb's picture

Hello! The XSD is

Hello! The XSD is attached. The error occurs in the current release version 2.0.1, as well as in nightly build 382. I tried 383 but with it the admin account is either broken or I need another login and I didn't bother to read the changes, as the import problem is my show stopper right now. Thanks for looking into this! Wolf
krishantha's picture

Hi.., I was able to recreate

Hi.., I was able to recreate your issue. The issue seem to be related to xsd file imports from localhost. I check with your attached xsd file (http://wso2.org/files/Flay.xsd) and it got upload to registry without any problem. so the XSD files imported from external URLs working fine. I have created a JIRA for this issue [1]. You can monitor the progress of the issue by being a watcher. [1]https://wso2.org/jira/browse/CARBON-3804 Thanks, Krishantha.
wolfb's picture

no movement

Thanks, however, its a bit sad to see there is no movement at all.
wolfb's picture

Problem persists in Development Release 3.0.0 alpha 1

Problem persists in Development Release 3.0.0 alpha 1
krishantha's picture

I tested with latest

I tested with latest snapshot and your scenarios works fine. So the issue seems to be fixed now. I assume you tried out adding of XSD though add resource window. There was an issue when adding XSD from add resource window and it is fixed now. In alpaha2 we have provide separate option to add schemas. So please try out Add schema from Home > Metadata > Add > Schema menu option. The add schema option works fine for me with alpha1. Thanks, Krishantha.
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)