-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete Automation of Endpoint Initialization #6
Comments
Idea: The feature is now implemented in a first version - but the reaction if you don´t have an implementation of your SEI is an Exception. It would be better a Failure Analysis shown as startup failure. |
…tFoundException integrated in WebServiceAutoDetector to handle the Situation, where the user didn´t implement the SEI - because automatic Endpoint Detection is based upon this class.
…ingClassNotFoundException enhanced
…dpoint Interface (SEI) is annotated with javax.jws.WebService, but also another class (e.g. the SEI implementing Endpoint class).
Also handle situations, where not only the SEI is annotated with javax.jws.WebService, but also the SEI implementing Endpoint class. |
…uct instead of Pre!) of WebServiceAutoDetector
The Failure Analyzer for the missing SEI implementation is cool, but we should also analyze, if the SEI itself couldn´t be found - along with the WebServiceClient class. So two more Failure Analyzers should be implemented. |
…ent annotated class could´t be found.
…int Interface (SEI) could´nt be found. Also refactored the WebServiceAutoDetector module architecture that now separates the Scanning and the working with the specific WebService-Classes. That also results in the possiblility to use Mocks instead of preimplemented WebServiceAutoDetector Testable class, which never felt right.
…terface_and_the_other_not() --> class.getName instead of class.getSimpleName is required for Class-resolution.
…AutoConfiguration - so the Autodetection is only done once and if it fails, it will fail fast. Also the Logging is enhanced, so you can see the Endpoint initializing better. Also some getters renamed and used inside CxfAutoConfiguration.
…er were missing in spring.factories - and not used :( We need a integration test for that!
Everything is working fine, but not when starting via java -jar. Then currently you get a
|
The problem seems to be related to the underlying use of fast-classpath-scanner issue classgraph/classgraph#46 - allthough the scanning in spring boot jars should have been resolved... After debugging-session, this is not true. All needed class files are listed in the scan results of the FastClassPathScanner. Problem seems to be, how the annotation javax.jws.WebService ist searched for... Ok, found it :P Works as designed... ~
|
One more step is achieved, the fast-classpath-scanner is definitively working correct - now we get an error inside Apache CXF: NoSuchMethodException inorg.apache.cxf.jaxws.JAXWSMethodDispatcher...
Maybe this has something to do with different classloaders in different threads, where different cxf Bus instances are holded: http://stackoverflow.com/questions/14452201/nosuchmethodexception-for-an-available-method |
|
You´re right, with Let´s switch to the Spring variant and ClassPathScanningCandidateComponentProvider, which is after all capable of scanning for Interfaces with specific Annotations (which I (incl. stackoverflow and google) thought it is not and what was the reason started to go with the fast-classpath-scanner). |
…ng variant (https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java). New tests for the WebServiceScanner. This was only possible, because Spring is after all able to scan for Interfaces which have specific Annotations (http://stackoverflow.com/a/41504372/4964553). Therefore Spring can be used and all problems with java -jar and mvn spring-boot:run not finding classes or CXF gone wild are completely gone now!
…for an Class that implements a given Interface it also returns the Interface itself so we have to throw that out of the results. Not cxf-boot-simple is also running again.
The only thing that´s missing is the right package-basename for Spring to scan for the SEI, SEI-Implementation and WebServiceClient classes. To get this 100% right, we need to use the same mechanism as the cxf-spring-boot-starter-maven-plugin / jaxws-maven-plugin, which itself uses WSimportTool of the JAXWS-RI implementation, to obtain the package-Name from the WSDL file, where the classes are generated to. I knew from former experiments, that the WSDL´s targetNamespace is used to generate the package name. If you have
And the best thing is, this algorithm is specified in the JAXB spec. So it should be ok to rely onto it. All we have to do now is to read the WSDL (maybe use the code from cxf-spring-boot-starter-maven-plugin), obtain the targetNamespace, insert into Spring Scanner and scan :) |
…om MANIFEST to the cxf-spring-boot-maven.properties generated by the cxf-spring-boot-maven-plugin.
…SEI and WebServiceClient´s packageName with the help of JAXB XJC (like it is done in the JAXWS RI) is now part of the cxf-spring-boot-maven-plugin. The packageName is put into the cxf-spring-boot-maven.properties file - already known from the injection of the project´s packageName to later obtain the SEI Implementation class. We only need a PackageName Reader in the cxf-spring-boot-starter now, so the WsdlScanner was deleted.
Now this feature is completely working. For the time beeing (without releases), you need the current cxf-spring-boot-starter-maven-plugin installed via Maven with the package extraction features. But the Automation of Endpoint initialization should also consider situations, where it should´nt try to autoinitialize the Endpoints. E.g. if you have an integration test / JAXWS client scenario, you don´t need it. But in the current implementation you @autowire the CxfAutoConfiguration to obtain the baseAndServiceEndingUrl(). Therefore it should be possible to deactive it - at least via a property. Further deactivation features are not part of this (already long) issue. |
…t only sceanarios (it also helps #8). Renamed the SystemTest from Integration test which it is not.
and Method matching inside the CXF core:
All other situations are working correctly - |
We were using the Spring Boot Devtools to help us speeding up the development. But it seems to be the case that the two class loaders used to start the application get in our way. If both classloaders load the same class independently, the classes are not equal and Spring won't use these for autowiring components. |
Ah 1000 thanks to you @marcopaga for reporting and sorting that out! I close it again :) |
hi jonashakt de.codecentric.namespace.weatherservice this package is not available so its't loaded project |
Sorry, I don´t really understand... This package isn´t available after first checkout of this project. But if you run a |
Autodetect everything needed to initialize
javax.xml.ws.Endpoint
completely based upon generated Class files.Background: The cxf-spring-boot-starter-maven-plugin generates two Class files among others:
One representing your Service Endpoint Interface (SEI) - annotated with
javax.jws.WebService
- and another WebServiceClient class - which implementsjavax.xml.ws.Service
. Both are needed to initialize thejavax.xml.ws.Endpoint
for publishing it with Apache CXF. In traditional way with Spring Boot, but without the cxf-spring-boot-starter, this is done like that:Now the idea is, that this is all boilerplate - if you like to run your SOAP web services in a contract first manner. Because then, everything is quite clear from your starting point - the WSDL and XSD files. There you have already the Name of your Service and all it´s methods. It should be possible to initialize the CXF endpoint from that information. Prerequisites remain the generation of the Java classes via the cxf-spring-boot-starter-maven-plugin and a manual implementation of the Service Endpoint Interface (SEI), because that´s the place where you´re service coding starts - we shouldn´t generate that one for you.
With this feature, you dont´t have to do a lot any more - the hole Endpoint initialization (including the definition of a WebService URL) is done for you.
The text was updated successfully, but these errors were encountered: