Im trying to use a web service.
My project is Java 6, using Jboss 4.3.2.GA.
I've tryied to import the web service using the New-> Web Service Client in Eclipse.
Like this tutorial http://www.craigsprogramming.com/2011/03/tutorial-consume-any-web-service-using.html
But when i try to get the Soap Client in this code:
WebServiceEscolaSoapStub service = (WebServiceEscolaSoapStub)new WebServiceEscolaLocator().getWebServiceEscolaSoap();
I get the following error.
org.apache.commons.discovery.DiscoveryException: Class org.apache.commons.logging.impl.SLF4JLogFactory does not implement org.apache.commons.logging.LogFactory
at org.apache.commons.discovery.tools.ClassUtils.verifyAncestory(ClassUtils.java:180)
at org.apache.commons.discovery.tools.SPInterface.verifyAncestory(SPInterface.java:201)
at org.apache.commons.discovery.tools.SPInterface.newInstance(SPInterface.java:195)
at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:579)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:418)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
at br.com.portalpitagorasdeeducacao.gestaodeusuarios.Service.WebServiceEscolaLocator.<init>(WebServiceEscolaLocator.java:12)...
The error is pretty clear.
You are mixing two jars slf4j and commons-logging. Get rid of commons-logging.jar file.
On second thought remove all logging for now and just a run webservice client to see if you get an output. Later you can add the logging. This error has nothing to do with webservice error.
Related
I'm writing a web application which uses JAXB and JAX-RS. The content-type used for getting/sending data to the server is XML. The web application runs in a GlassFish server(4.1.2/ 5), the JDK used is 1.8.
The problem is that the internal SAXParser allows doctype declarations which makes XEE-Attacks possible. I'm not able to inject the specific feature into the SAXParserFactory, so i built a wrapper for the SAXParserFactory, which sets the feature. The SAXParserFactory is registered using the system properties.
System.setProperty("javax.xml.parsers.SAXParserFactory","de.mycompany.sdk.parser.SAXParserFactoryWrapper");
Unfortunately, the server throws a ClassNotFoundException on every second startup, otherwise the application behaves normal.
Has anyone ideas how to fix it?
I've also tried to include the jar into the class path or specify it using the manifest, but did not work neither.
I get the following error:
javax.xml.parsers.FactoryConfigurationError: Provider de.mycompany.sdk.parser.SAXParserFactoryWrapper not found
at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:200)
at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:152)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:232)
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:127)
at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.getSAXParser(DeploymentDescriptorFile.java:125)
at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:305)
at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:245)
Caused by: java.lang.ClassNotFoundException: de/mycompany/sdk/parser/SAXParserFactoryWrapper
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:124)
at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:188)
... 56 more```
ClassNotFoundException
can occur if you have multiple versions of a class (de.mycompany.sdk.parser.SAXParserFactoryWrapper in this case) in your class path. This generally happens when you have multiple versions of the same library in your classpath.
Thanks for your help! I found a solution for my problem. I deployed the application using the GlassFish CLI and it works! The previous tries were done using NetBeans. It seems that NetBeans does anything different during the startup or shutdown process of the GlassFish server wich involves the exception.
I get the error when generating web service. I have a simple class that i want to create web service.
I am using CXF 2.7 and Tomcat 7 version.
org.apache.cxf.tools.common.ToolException: Fail to load class :RequestLimit
at org.apache.cxf.tools.util.AnnotationUtil.loadClass(AnnotationUtil.java:88)
at org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor.getServiceClass(JavaToWSDLProcessor.java:284)
at org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor.getServiceBuilder(JavaToWSDLProcessor.java:181)
at org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor.process(JavaToWSDLProcessor.java:100)
at org.apache.cxf.tools.java2ws.JavaToWSContainer.processWSDL(JavaToWSContainer.java:110)
at org.apache.cxf.tools.java2ws.JavaToWSContainer.execute(JavaToWSContainer.java:75)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:58)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:40)
at org.apache.cxf.tools.java2ws.JavaToWS.run(JavaToWS.java:77)
at org.apache.cxf.tools.java2ws.JavaToWS.main(JavaToWS.java:45)
It is all about project hasnt been built. I selected Project->Build Automatically in Eclipse.
More information. Solution here
I am using axis2 on Apache Tomcat. I am writing client side to consumer SOAP WS. I configured Eclipse to use Tomcat as a server and while executing that line
stub._getServiceClient().engageModule("addressing");
I was getting that error "unable to engage module addressing". To fix that issue I add following line in the VM arguments of run configuration
-Daxis2.repo="E:\axis2\repository"
Now I export my project as a war file and deploy it on the real server. But Now I am again getting the same error(I checked the log file). I don't know how to fix, can every one help me. Thanks
It got resolved on my side in the following way:
I had an outdated WEB-INF/modules/axis2-jaxws-mar*.mar or rather 2 versions of it and the classloader got the older one of it and AxisServlet didn't start altogether
java.lang.NoSuchMethodError: org.apache.axis2.engine.AxisConfiguration.getGlobalModules()Ljava/util/List;
at org.apache.axis2.jaxws.module.JAXWSModule.registerGlobalModule(JAXWSModule.java:51)
I created a jaxws web service. I totally followed the url
The service was up perfectly without any error. But the server having errors when request hit it.
SEVERE: caught throwable
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext
at com.sun.xml.ws.db.glassfish.JAXBRIContextFactory.newContext(JAXBRIContextFactory.java:74)
at com.sun.xml.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:149)
at com.sun.xml.ws.message.jaxb.JAXBMessage.create(JAXBMessage.java:160)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAP11Fault(SOAPFaultBuilder.java:433)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:210)
I checked through out stackoverflow and many other sites all says jar file conflict.
I use java-6-openjdk.
and below is my jar file list in the jetty server.
gmbal-api-only.jar ha-api.jar jaxb-core.jar
jaxb-impl.jar jaxws-rt.jar management-api.jar
policy-2.3.1.jar stax-ex.jar streambuffer-1.5.1.jar
Since above jars are not working I tried with
Go here
Download JAX-WS RI distribution.
But those jars gave the same error.
I have also came across same exception and little bit googling it confirmed that its because of classpath/jar issue.
I'm using Java 6.0 as build and runtime environment and my project setup having jaxb-api.jar and jaxb-impl.jar. I simply removed these two jars from classpath and it works.
As if we are having Java 6.0 we dont need to use explicitely JAX binding jars. It comes by default with Java 6.0.
Check this thread: web client for web service. The main problem I think is that you have several jaxb jars that differ in versions. For example, I think that jaxb is already part of jaxws-rt.jar which would mean you don't need jaxb-core.jar and jaxb-impl.jar.
Same error occured on my Java 7 project. Removing
com/sun/xml/bind/jaxb-impl-2.2.6.jar
com/sun/xml/bind/jaxb-xjc-2.2.6.jar
dependencies solved the problem.
Alternative solution :
clientPort is an Interface with #WebService annotation.
BindingProvider prov = (BindingProvider) clientPort;
prov.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, serviceUsername);
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, servicePassword);
I am new to web services and I have deployed a web service locally ( I am able to see the wsdl)
I tried to query the web service by creating a request in SOAPUI.
The response I got back was
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>java.lang.NoClassDefFoundError: org/apache/commons/lang/StringEscapeUtils
</faultstring>
</env:Fault>
I see a bunch of errors in the jboss console in eclipse...
11:53:06,226 ERROR [SOAPFaultHelperJAXWS]
SOAP requestexceptionjava.lang.RuntimeException:
java.lang.NoClassDefFoundError:org/apache/commons/lang/StringEscapeUtils
Can someone help me in figuring out what the problem could be?
Is something wrong with the way I setup my SOAPUI or is it I missed something in my project(web service server)
You need commons-lang.jar in your classpath
How do you exactly deploy the web service? For example, if you create an .aar archive, please verify that the corresponding jar (commons-lang.jar?) is available into the lib folder of the archive. For example:
your_service_root
->META-INF
->lib
->commons-lang.jar
-> com
->bla
->bla