facebook

Problem when trying to add method to a web services,

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #267139 Reply

    alababi
    Member

    Hey, I’m new to Web Services, and having trouble when add another method to a web services.

    I create a Web Services project first and then create a new Web Services,
    It generated 2 class, named: checkCertificationImpl.java and IcheckCertification.java then I deploy it to Tomcat Server, it works well

    Later I add another method to the Web Services, both in the interface and the implement class, and redeploy, hic, and it send me an error

    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    javax.servlet.ServletException: Error initializing XFireServlet.
        org.codehaus.xfire.transport.http.XFireServlet.init(XFireServlet.java:52)
        javax.servlet.GenericServlet.init(GenericServlet.java:212)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
        org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
        java.lang.Thread.run(Unknown Source)
    
    root cause
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.xfire.spring.ServiceBean' defined in class path resource [META-INF/xfire/services.xml]: Initialization of bean failed; nested exception is org.codehaus.xfire.XFireRuntimeException: Cannot create mapping for java.util.ArrayList, unspecified component type for return type of method testArrayList in interface IcheckCertification
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:370)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
        org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
        org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
        org.codehaus.xfire.spring.XFireConfigLoader.getXFireApplicationContext(XFireConfigLoader.java:107)
        org.codehaus.xfire.spring.XFireConfigLoader.loadContext(XFireConfigLoader.java:41)
        org.codehaus.xfire.transport.http.XFireConfigurableServlet.loadConfig(XFireConfigurableServlet.java:86)
        org.codehaus.xfire.transport.http.XFireConfigurableServlet.createXFire(XFireConfigurableServlet.java:54)
        org.codehaus.xfire.transport.http.XFireServlet.init(XFireServlet.java:45)
        javax.servlet.GenericServlet.init(GenericServlet.java:212)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
        org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
        java.lang.Thread.run(Unknown Source)
    
    root cause
    
    org.codehaus.xfire.XFireRuntimeException: Cannot create mapping for java.util.ArrayList, unspecified component type for return type of method testArrayList in interface IcheckCertification
        org.codehaus.xfire.aegis.type.DefaultTypeCreator.createCollectionType(DefaultTypeCreator.java:43)
        org.codehaus.xfire.aegis.type.java5.Java5TypeCreator.createCollectionType(Java5TypeCreator.java:138)
        org.codehaus.xfire.aegis.type.XMLTypeCreator.createCollectionType(XMLTypeCreator.java:137)
        org.codehaus.xfire.aegis.type.AbstractTypeCreator.createTypeForClass(AbstractTypeCreator.java:91)
        org.codehaus.xfire.aegis.type.AbstractTypeCreator.createType(AbstractTypeCreator.java:334)
        org.codehaus.xfire.aegis.AegisBindingProvider.getSuggestedName(AegisBindingProvider.java:226)
        org.codehaus.xfire.service.binding.DefaultServiceConfiguration.getOutParameterName(DefaultServiceConfiguration.java:174)
        org.codehaus.xfire.service.binding.ObjectServiceFactory.getOutParameterName(ObjectServiceFactory.java:1033)
        org.codehaus.xfire.service.binding.ObjectServiceFactory.addOperation(ObjectServiceFactory.java:794)
        org.codehaus.xfire.service.binding.ObjectServiceFactory.initializeOperations(ObjectServiceFactory.java:720)
        org.codehaus.xfire.service.binding.ObjectServiceFactory.create(ObjectServiceFactory.java:418)
        org.codehaus.xfire.spring.ServiceBean.afterPropertiesSet(ServiceBean.java:176)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
        org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
        org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
        org.codehaus.xfire.spring.XFireConfigLoader.getXFireApplicationContext(XFireConfigLoader.java:107)
        org.codehaus.xfire.spring.XFireConfigLoader.loadContext(XFireConfigLoader.java:41)
        org.codehaus.xfire.transport.http.XFireConfigurableServlet.loadConfig(XFireConfigurableServlet.java:86)
        org.codehaus.xfire.transport.http.XFireConfigurableServlet.createXFire(XFireConfigurableServlet.java:54)
        org.codehaus.xfire.transport.http.XFireServlet.init(XFireServlet.java:45)
        javax.servlet.GenericServlet.init(GenericServlet.java:212)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
        org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
        java.lang.Thread.run(Unknown Source)
    

    Here is the source code of the WS, it’s very simple, just for testing,

    
    
    import java.sql.ResultSet;
    import java.util.ArrayList;
    
    
    //Generated by MyEclipse
    
    public interface IcheckCertification {
        public ArrayList testArrayList();
        public ResultSet ViewCertDetails(String certNo);
        
        
    }
    
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.Date;
    
    
    
    //Generated by MyEclipse
    
    public class checkCertificationImpl implements IcheckCertification {
        
        public ArrayList testArrayList()
        {
            ArrayList a = new ArrayList();
    //        a.add("hello");
    //        Date today = new Date("20-10-1995");
    //        a.add(today);
            return a;
        }
        
        public ResultSet ViewCertDetails(String certNo) {
    
            
            ResultSet rs=null;        
            return rs;
            
        }
        
    }

    And here is 2 .xml file
    services.xml

    
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://xfire.codehaus.org/config/1.0">
    
        <service>
            <name>checkCertification</name>
            <serviceClass>IcheckCertification</serviceClass>
            <implementationClass>
                checkCertificationImpl
            </implementationClass>
            <style>wrapped</style>
            <use>literal</use>
            <scope>application</scope>
        </service></beans>
    

    web.xml

    
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <servlet>
        <servlet-name>XFireServlet</servlet-name>
        <servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>XFireServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
      </servlet-mapping>
    </web-app>
    
    

    Please help

    #267165 Reply

    tomeksz
    Member

    Hi
    You can’t return “untyped” collections. If you are using java5 then use e.g. ArrayList<String> syntax , if not, then use aegis mapping file to specify collection type.
    You can’t also return different types of object inside collection like String and Date in your case.

    #267217 Reply

    alababi
    Member

    Thanks,
    I use String[] instead and it worked.

    #267891 Reply

    Greetings:

    I am using XFire, EJB and Hibernate.

    I am accessing this ejb from a web service project…

    In the ejb project…
    I have an EJB bean class named RegistrarEr.java.
    Also, I’ve an Hibernate dataobject named RegistrationEr.java too..

    This data object has another data object like the following in it..

    public abstract class AbstractRegistrationEr implements java.io.Serializable {

    private ChallengeQuestion challengeQuestion;

    }

    I am creating a binding file for this dataobject , using
    RegistrationEr.aegis.xml as follows

    <mappings>
    <mapping name=”com.vrs.selfserv.hibernate.dataobject.RegistrationEr”>
    <property name=”challengeQuestion” componentType=”
    com.vrs.selfserv.hibernate.dataobject.ChallengeQuestion” />
    <method name=”getChallengeQuestion”>
    <return-type componentType=”
    com.vrs.selfserv.hibernate.dataobject.ChallengeQuestion” />
    </method>
    <method name=”setChallengeQuestion”>
    <return-type componentType=”
    com.vrs.selfserv.hibernate.dataobject.ChallengeQuestion” />
    </method>
    </mapping>
    </mappings>

    When I start the server after deploying it, Iam getting the following
    error..
    Any Idea..??

    ERROR [XFireServlet] Error initializing XFireServlet.

    org.springframework.beans.factory.BeanCreationException: Error creating bean
    with name ‘org.codehaus.xfire.spring.ServiceBean#1′ defined in class path
    resource [META-INF/xfire/services.xml]: Initialization of bean failed;
    nested exception is org.codehaus.xfire.XFireRuntimeException: Error
    evaluating xpath /mappings/mapping[@uri=’
    http://interfaces.session.selfserv.vrs.com’%5D. Nested exception is
    org.jdom.JDOMException: java.lang.NoClassDefFoundError: org/jdom/Text:
    org/jdom/Text

    org.codehaus.xfire.XFireRuntimeException: Error evaluating xpath
    /mappings/mapping[@uri=’http://interfaces.session.selfserv.vrs.com’%5D. Nested
    exception is org.jdom.JDOMException: java.lang.NoClassDefFoundError:
    org/jdom/Text: org/jdom/Text

    org.jdom.JDOMException: java.lang.NoClassDefFoundError: org/jdom/Text:
    org/jdom/Text

    If I remove the RegistrationEr.aegis.xml file, the server starts up without
    any error..But, throws the following error, when I try to access the WSDL…

    org.codehaus.xfire.XFireRuntimeException: Couldn’t create type for property
    challengeQuestion on class
    com.vrs.selfserv.hibernate.dataobject.RegistrationEr: Error evaluating xpath
    /mappings/mapping[@uri=’http://interfaces.session.selfserv.vrs.com’%5D.
    Nested exception is org.jdom.JDOMException: java.lang.NoClassDefFoundError:
    org/jdom/Text: org/jdom/Text

    Any Idea..??

    Thanks,
    -Ganesh.

    #267892 Reply

    tomeksz
    Member

    you need to add jdom.jar to your classpath

    #267893 Reply

    Thanks for your reply..
    I’ve already added the jdom.jar to the class path of the Web services project..
    I guess, the real problem is something else..
    I tried adding the jdom.jar to the EJB project too..
    Still its not working…

    #267896 Reply

    tomeksz
    Member

    Make sure you have jdom in correct version 🙂

    #267900 Reply

    Thanks..
    I’m using jdom-1.0.jar, which comes with myEclipse….I guess, its the right one…
    Any other idea..??

    #267903 Reply

    tomeksz
    Member

    Maybe its classloader problem. EJB module uses separate CL, so maybe try to put xfire libraries in same place visible by everyone ( server share library folder or something like )

    #267907 Reply

    I had same problem — and it’s the ArrayList return type of your method: http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-16539.html

    Lee

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Problem when trying to add method to a web services,

You must be logged in to post in the forum log in