You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "FURTADO, Murray, GBM" <Mu...@rbos.com> on 2007/04/03 18:08:33 UTC

Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in parse () method of Stub.InnerClass

Hi,
 
I have adb generated stub classes which are subclasses of a common parent
(XPortfolioProduct). In the static method to create the parent class object
I have code as follows:
 
 
       /**
        * static method to create the object
        * Precondition:  If this object is an element, the current or next
start element starts this object and any intervening reader events are
ignorable
        *                If this object is not an element, it is a complex
type and the reader is at the event just after the outer start element
        * Postcondition: If this object is an element, the reader is
positioned at its end element
        *                If this object is a complex type, the reader is
positioned at the end element of its outer element
        */
        public static XPortfolioProduct
parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
            XPortfolioProduct object = new XPortfolioProduct();
            int event;
            try {
                
                while (!reader.isStartElement() && !reader.isEndElement())
                    reader.next();
 
                
                if
(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type"
)!=null <http://www.w3.org/2001/XMLSchema-instance> ){
                  java.lang.String fullTypeName =
reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> ",
                        "type");
                  if (fullTypeName!=null){
                    java.lang.String nsPrefix =
fullTypeName.substring(0,fullTypeName.indexOf(":"));    <--- String index
out of range: -1
                    nsPrefix = nsPrefix==null?"":nsPrefix;
 
                    java.lang.String type =
fullTypeName.substring(fullTypeName.indexOf(":")+1);
                    if (!"XPortfolioProduct".equals(type)){
                        //find namespace for the prefix
                        java.lang.String nsUri =
reader.getNamespaceContext().getNamespaceURI(nsPrefix);
                        return
(XPortfolioProduct)ExtensionMapper.getTypeObject(
                             nsUri,type,reader);
                      }
                  }
             }...
 
The fullTypeName = 'SubClassName'  and doesn't contain a colon, so a
StringIndexOutOfBoundsException is thrown.
 
Any idea why this is happening?
 
 
Murray Furtado
Currency Options Sales Technology
RBS Global Banking and Markets 
280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP 
 ( +44 207 085 0748 | * murray.furtado@rbos.com
<ma...@rbos.com> 
 

***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority 
 
This e-mail message is confidential and for use by the 
addressee only. If the message is received by anyone other 
than the addressee, please return the message to the sender 
by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The 
Royal Bank of Scotland plc does not accept responsibility for 
changes made to this message after it was sent. 

Whilst all reasonable care has been taken to avoid the 
transmission of viruses, it is the responsibility of the recipient to 
ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its 
systems or data. No responsibility is accepted by The 
Royal Bank of Scotland plc in this regard and the recipient should carry 
out such virus and other checks as it considers appropriate. 
Visit our websites at: 
www.rbs.com
www.rbsgc.com
www.rbsmarkets.com
***********************************************************************************

Maven2 java2wsdl plugin classpath problem

Posted by "John R. Hover" <jh...@bnl.gov>.
Both of these recent posts were about the same problem--the java2wsdl 
maven2 plugin doesn't appear to use the current project's classpath to 
resolve the class to convert to wsdl.

I'm also having the same problem, and even downloaded the plugin source 
to look into it (the issue doesn't seem to be explicitly handled). Which 
means that at the very least the documentation should state that a jar 
dependency entry in the plugin element is necessary.

Is this the right list to ask about this?

Thanks,

--john

Re:  Classpath Problem using Maven2 plugin java2wsdl
"Kehren, Peter (regio iT)" <Peter.Kehren () regioit-aachen ! de> wrote:
> Hi,
> 
> I'm trying to generate wsdl informations using the maven2 plugin
> java2wsdl under Java 5:
> 
> <plugin>
> 	<groupId>org.apache.axis2.maven2</groupId>
> 	<artifactId>axis2-java2wsdl-maven-plugin</artifactId>
> 	<version>1.1</version>
> 	<executions>
> 		<execution>
> 			<goals>
> 				<goal>java2wsdl</goal>
> 			</goals>
> 		</execution>
> 	</executions>
> 	<configuration>
> 		<className>de.regioit.test.DummyService</className>
> 		...
> 	</configuration>
> </plugin>
> 
> Executing maven I receive always the following exception:
> 
> -------------------------------
> [INFO] [axis2-java2wsdl:java2wsdl {execution: default}]
> java.lang.Exception: java.lang.ClassNotFoundException:
> de.regioit.test.DummyService
>         at
[snip]
> ------------------------------------------------------------------------
> 
> 
> Why doesn't the plugin use the default classpath of the project? Or
> where else could be the problem? Is there someone how can give me a
> hint?
> 
> Peter


Re: [AXIS2] java2wsdl maven2 plugin problems
"Scot Hale" <scot.hale () gmail ! com> wrote:
> Hi all,
> I am trying to use the maven java2wsdl 1.1 plugin, and I have run into
> several problems.  I am using maven 2.0.5, java 5, and Linux Ubuntu
> 6.10.
> 
> 1.) Documentation:  The example snippet on
> http://ws.apache.org/axis2/tools/1_1/maven-plugins/maven-java2wsdl-plugin.html
> is wrong and won't work.  This part:
> 
>           </execution>
>           <configuration>
>             <className>com.foo.myservice.MyHandler</className>
>           </configuration>
>         </executions>
>       </plugin>
>     </plugins>
>   </build>
> 
> Should be
> 
>           </execution>
>         </executions>
>         <configuration>
>           <className>com.foo.myservice.MyHandler</className>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> 
> 2.) Documentation: The example command doesn't work (on the same page).
> 
> mvn java2wsdl:java2wsdl
> 
> Should be
> 
> mvn axis-java2wsdl:java2wsdl
> 
> 3.) Strangly, a directory gets created in my maven project called
> "home".  I think this might be causing other issues as well.  It looks
> like it is taking the full path to my project (for example
> /home/scot/src/webservice/ ) and lopping off the first "/", then
> creating a new directory ( for example
> /home/scot/src/webservice/home/scot/src/webservice/target/... ).
> 
> 4.) When I run the plugin it can't find a class that exists in the
> standard maven2 directory src/main/java/ ( for example
> src/main/java/com/DummyHandler.java ).  I noticed someone else
> complained about this on January 22nd, but I didn't see a reply to his
> post to the mailing list.
> 
> java.lang.Exception: java.lang.ClassNotFoundException: com.DummyHandler
>         at org.apache.ws.java2wsdl.Java2WSDLCodegenEngine.generate(Java2WSDLCodegenEng \
>                 ine.java:58)
[snip]


-- 
John R. Hover
RHIC/Atlas Computing Facility, Bldg. 510M
Physics Department
Brookhaven National Laboratory
Upton, NY 11793
email: jhover@bnl.gov
tel: 631-344-5828

Re: Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in parse () method of Stub.InnerClass

Posted by Amila Suriarachchi <am...@gmail.com>.
It is normally assume that the type attribute value has a namespace prefix.
i.e ns1:complexTypeName. that is why we check for ':'
but if the complex type belongs to the default namespace the we may not have
the namespace prefix as you have mentioned.
so I change the method as follows,
java.lang.String nsPrefix = null;
                    if (fullTypeName.indexOf(":") > -1){
                        nsPrefix = fullTypeName.substring(0,
fullTypeName.indexOf(":"));
                    }

On 4/3/07, FURTADO, Murray, GBM <Mu...@rbos.com> wrote:
>
>  Hi,
>
> I have adb generated stub classes which are subclasses of a common parent
> (XPortfolioProduct). In the static method to create the parent class object
> I have code as follows:
>
>
>        /**
>         * static method to create the object
>         * Precondition:  If this object is an element, the current or next
> start element starts this object and any intervening reader events are
> ignorable
>         *                If this object is not an element, it is a complex
> type and the reader is at the event just after the outer start element
>         * Postcondition: If this object is an element, the reader is
> positioned at its end element
>         *                If this object is a complex type, the reader is
> positioned at the end element of its outer element
>         */
>         public static XPortfolioProduct parse(
> javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
>             XPortfolioProduct object = new XPortfolioProduct();
>             int event;
>             try {
>
>                 while (!reader.isStartElement() && !reader.isEndElement())
>                     reader.next();
>
>
>                 if (reader.getAttributeValue("
> http://www.w3.org/2001/XMLSchema-instance","type")!=null<http://www.w3.org/2001/XMLSchema-instance%22,%22type%22%29%21=null>
> ){
>                   java.lang.String fullTypeName = reader.getAttributeValue
> ("http://www.w3.org/2001/XMLSchema-instance",
>                         "type");
>                   if (fullTypeName!=null){
> *                    java.lang.String nsPrefix = fullTypeName.substring(0,
> fullTypeName.indexOf(":"));    <--- String index out of range: -1*
>                     nsPrefix = nsPrefix==null?"":nsPrefix;
>
>                     java.lang.String type = fullTypeName.substring(
> fullTypeName.indexOf(":")+1);
>                     if (!"XPortfolioProduct".equals(type)){
>                         //find namespace for the prefix
>                         java.lang.String nsUri =
> reader.getNamespaceContext().getNamespaceURI(nsPrefix);
>                         return
> (XPortfolioProduct)ExtensionMapper.getTypeObject(
>                              nsUri,type,reader);
>                       }
>                   }
>              }...
>
> The fullTypeName = 'SubClassName'  and doesn't contain a colon, so a
> StringIndexOutOfBoundsException is thrown.
>
> Any idea why this is happening?
>
>
>  Murray Furtado
> Currency Options Sales Technology
> RBS Global Banking and Markets
> 280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP
>  ( +44 207 085 0748 | * murray.furtado@rbos.com
>
>
> ***********************************************************************************
> The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
> Authorised and regulated by the Financial Services Authority
>
> This e-mail message is confidential and for use by the
> addressee only. If the message is received by anyone other
> than the addressee, please return the message to the sender
> by replying to it and then delete the message from your
> computer. Internet e-mails are not necessarily secure. The
> Royal Bank of Scotland plc does not accept responsibility for
> changes made to this message after it was sent.
>
> Whilst all reasonable care has been taken to avoid the
> transmission of viruses, it is the responsibility of the recipient to
> ensure that the onward transmission, opening or use of this
> message and any attachments will not adversely affect its
> systems or data. No responsibility is accepted by The
> Royal Bank of Scotland plc in this regard and the recipient should carry
> out such virus and other checks as it considers appropriate.
> Visit our websites at:
> www.rbs.comwww.rbsgc.comwww.rbsmarkets.com
> ***********************************************************************************
>
>


-- 
Amila Suriarachchi,
WSO2 Inc.