JavaToWS Error while generating web service with CXF - java

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

Related

NoSuchMethodError: org.hibernate.SessionFactory.openSession()

I'm having hibernate3.jar and hibernate-core-4.2.0.CR1.jar in my classpath and I'm using Spring 3.1.3 version. Code got compiles sucessfully but while runtime I'm getting following error
2014-10-28 10:51:25,174 DEBUG [RMI TCP Connection(2)-10.126.30.203] -
Target method failed for RemoteInvocation: method name
'getPriceByKeys'; parameter types [java.util.List, java.util.Date]
java.lang.NoSuchMethodError:
org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
I google it but not find any solution. Please note : My project needs hibernate3.jar but at the same time my project dependent on some other 3rd party jar which inturn using hibernet4.2.0 jar.
Any help Pls ??
You need to remove multiple hibernate JAR files from your classpath. Without doing this, your application may not work as you expect; which means you need to migrate the hibernate version of your application from 3 to 4.1.
Although Spring 3.1 uses Hibernate 3 JAR files, you can still migrate to Hibernate 4. Check out Spring blog gives a small tutorial to do so.
Migrating to Spring 3.1 and Hibernate 4.1
As part of the Core-Spring course, we have a lab application that we
use to show how to integrate Spring and JPA/Hibernate together. We
have just upgraded it to Spring 3.1 / Hibernate 4.1, and thought we
should share a few tips.
Just an update. The cause of problem is , I'm having two spring-context xml files in project (one of my project and one related to another module that I'm integrating). I'm loading context xmls from two different classes. So one of the DAO class loaded by one of spring-context xml not getting the hibernate Session.
Later on using import tag, I included 2nd spring application context file in 1st application context file and then loaded a Single application context file from the class. It solved the error.
Thanks,

Axis Error unable to engage module addressing

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)

Simple Glassfish RESTful service in eclipse throws exception

This should be easy, but it's been costing me tons of time. I basically can't get a RESTful web service running under eclipse. I'm sure I'm missing something stupid, but resources seem to be a bit scattered and nothing covers the recent 4.0/EE 7 release.
I have a clean install of Eclipse Kepler (4.3). I try and set up a basic RESTful app using the following steps.
I have Java EE 7 installed
I open eclipse, point it to a fresh workspace and create a new 'Dynamic Web Application'.
Project name doesn't particularly matter, a new Target Runtime is created by downloading the Glassfish extension (New Runtime->Download additional server adapters->Glassfish). This requires restarting eclipse - so just repeat the previous, but select a Glassfish 4.0 runtime after clicking 'New Runtime'. Web Module is 3.1, everything else is default. I click 'Finish' to create my new project.
I then right click and open project properties, then 'Project Facets'. I check of JAX-RS (REST Web Services). Then click 'Further Configuration required...". I then select 'Disable Library Configuration' from the drop down. The fields receive the following values:
JAX-RS servlet name: JAX-RS Servlet
JAX-RS servlet class name: org.glassfish.jersey.servlet.ServletContainer
URL mapping patterns: /jaxrs/*
I then click OK to close all the windows.
Now adding a New->'RESTful Web Service from Pattern' creates a new class, that doesn't seem to ever get picked up by glassfish on deployment. My understanding is that it should auto scan and pick up things with an #path. It doesn't seem to. If I finagle things enough I can seem to access the application.wadl - but doesn't show my resource.
If I go back into properties and take a look at my JAX-RS project facet, I'm presented with an error box saying some of my values are invalid.
In the workspace log I'm greeted with the following exception:
!ENTRY org.eclipse.jst.jee 4 0 2013-07-02 21:54:27.780
!MESSAGE org.eclipse.jst.javaee.web.internal.impl.WebAppImpl cannot be cast to org.eclipse.jst.j2ee.webapplication.WebApp
!STACK 0
java.lang.ClassCastException: org.eclipse.jst.javaee.web.internal.impl.WebAppImpl cannot be cast to org.eclipse.jst.j2ee.webapplication.WebApp
at org.eclipse.jst.ws.jaxrs.core.internal.project.facet.UpdateWebXMLForJ2EE.run(UpdateWebXMLForJ2EE.java:32)
at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.modify(JEE5ModelProvider.java:255)
at org.eclipse.jst.jee.model.internal.Web25MergedModelProvider.modify(Web25MergedModelProvider.java:92)
at org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSFacetInstallDelegate.createServletAndModifyWebXML(JAXRSFacetInstallDelegate.java:275)
at org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSFacetInstallDelegate.execute(JAXRSFacetInstallDelegate.java:156)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(FacetedProject.java:1477)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modifyInternal(FacetedProject.java:441)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChangesInternal(FacetedProject.java:1181)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.access$2(FacetedProject.java:1117)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject$5.run(FacetedProject.java:1099)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChanges(FacetedProject.java:1109)
at org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy.commitChanges(FacetedProjectWorkingCopy.java:2020)
at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$4.run(FacetsPropertyPage.java:232)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$5.run(FacetsPropertyPage.java:246)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Any insight would be so greatly appreciated.
Try running Eclipse with Java SE. The parts of Java EE that your project needs to compile against can come from Glassfish itself. You might also need to use #Path rather than #path since it matches to a type name and is case sensitive.

Import a Web Service Client from a WSDL in Java

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.

SoapUI error on request - NoClassDefFoundError

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

Categories