Issue
I'm using Eclipse Mars, and Apache CXF 3.06 in order to create a JAX-WS compliant Web Service, my Java Version is JDK 1.7.0_45. I was following this tutorial which I can't complete because I'm unable to see the WSDL Navigator (Step 18 )
The following images are the process so far I've being doing:
1- My Apache CXF 2.x Preferences were set as the next screenshot:
2- Then I've created a Dynamic Web Project with these Project Facets
3- Dynamic Web Project Final CONF
4- I created a class named Calculate containing the next code:
package test;
public class Calculate {
public Integer calculateSum(int i, int j) {
return i + j;
}
public Integer multiplyNumber(int i, int j) {
return i * j;
}
public Integer divideNumber(int i, int j) {
return i / j;
}
}
5- Then right click on the class and go to Web Services, my final configuration:
6- I've made the interface exactly the tutorial indicate and the other steps, but when I launched the Web Services Explorer, I was unable to see the WSDL Main.
Even when I tried to launch the WSDL URL Browser it keeps saying, Please wait while the form loads... forever
Inside WebContent --> wsdl there is calculate.wsdl file with the next code:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="CalculateService" targetNamespace="http://test/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://test/" schemaLocation="calculate_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="divideNumberResponse">
<wsdl:part name="parameters" element="tns:divideNumberResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="calculateSum">
<wsdl:part name="parameters" element="tns:calculateSum">
</wsdl:part>
</wsdl:message>
<wsdl:message name="multiplyNumberResponse">
<wsdl:part name="parameters" element="tns:multiplyNumberResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="multiplyNumber">
<wsdl:part name="parameters" element="tns:multiplyNumber">
</wsdl:part>
</wsdl:message>
<wsdl:message name="calculateSumResponse">
<wsdl:part name="parameters" element="tns:calculateSumResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="divideNumber">
<wsdl:part name="parameters" element="tns:divideNumber">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="CalculateInterface">
<wsdl:operation name="divideNumber">
<wsdl:input name="divideNumber" message="tns:divideNumber">
</wsdl:input>
<wsdl:output name="divideNumberResponse" message="tns:divideNumberResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplyNumber">
<wsdl:input name="multiplyNumber" message="tns:multiplyNumber">
</wsdl:input>
<wsdl:output name="multiplyNumberResponse" message="tns:multiplyNumberResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateSum">
<wsdl:input name="calculateSum" message="tns:calculateSum">
</wsdl:input>
<wsdl:output name="calculateSumResponse" message="tns:calculateSumResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculateServiceSoapBinding" type="tns:CalculateInterface">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="divideNumber">
<soap:operation soapAction="urn:DivideNumber" style="document"/>
<wsdl:input name="divideNumber">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="divideNumberResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateSum">
<soap:operation soapAction="urn:CalculateSum" style="document"/>
<wsdl:input name="calculateSum">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="calculateSumResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplyNumber">
<soap:operation soapAction="urn:MultiplyNumber" style="document"/>
<wsdl:input name="multiplyNumber">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="multiplyNumberResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculateService">
<wsdl:port name="CalculatePort" binding="tns:CalculateServiceSoapBinding">
<soap:address location="http://localhost:8080/WebService/services/CalculatePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
In my opinion there is a problem at the time tomcat is initialized, when I go to console to see the logs Tomcat putted there, there are some nasty exceptions, here is the Tomcat's log:
WARNING: Exception configuring digester to permit java encoding names in XML files. Only IANA encoding names will be supported.
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/allow-java-encodings
at oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:128)
at org.apache.tomcat.util.digester.Digester.setFeature(Digester.java:538)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:411)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:104)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:119)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:73)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:36)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:140)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:112)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:84)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:347)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:725)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:691)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Aug 26, 2015 8:17:50 AM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext resource [/WEB-INF/cxf-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:300)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:748)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:448)
at oracle.xml.parser.schema.XSDValidator.processSchemaLocation(XSDValidator.java:972)
at oracle.xml.parser.schema.XSDValidator.startElement(XSDValidator.java:581)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1276)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
... 26 more
Aug 26, 2015 8:17:50 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext resource [/WEB-INF/cxf-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:300)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:748)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:448)
at oracle.xml.parser.schema.XSDValidator.processSchemaLocation(XSDValidator.java:972)
at oracle.xml.parser.schema.XSDValidator.startElement(XSDValidator.java:581)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1276)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
... 26 more
WARNING: Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Wed Aug 26 08:17:50 EDT 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Aug 26, 2015 8:17:50 AM org.springframework.context.support.AbstractApplicationContext doClose
WARNING: Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Wed Aug 26 08:17:50 EDT 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Aug 26, 2015 8:17:50 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Solution
The problem with the web service was at the time to initialize Tomcat. I was reading posts related to tomcat's error output and tried to include cxf-rt-bindings-soap.jar
even when this file is already include inside CXF libraries, this approach didn't work.
The solution that really worked was to remove import resource="classpath:META-INF/ cxf/ cxf-extension-soap.xml" />
from WebContent/WEB-INF/cxf-beans.xml
, this link enforces this solution.
I would like to know why cxf-beans.xml
is still generated with this class path even when it isn't longer needed, even when the version of Apache CXF is relative new (CXF 3.06 -- August 3, 2015)
Answered By - Luis Armando
Answer Checked By - Candace Johnson (JavaFixing Volunteer)