OK. I will. Thanks, Colm.
On Thursday, April 19, 2018, 8:35:45 AM CDT, Colm O hEigeartaigh
<[email protected]> wrote:
Please create a JIRA and attach the test-case so that we can track the
problem.
Colm.
On Sun, Apr 15, 2018 at 10:14 PM, Dongfeng Lu <[email protected]>
wrote:
> Screenshots for today's posting, in word doc.
> On Sunday, April 15, 2018, 4:10:55 PM CDT, Dongfeng Lu
> <[email protected]> wrote:
>
>
> Just realized all screenshots are removed in the posting, but zip files
> seem to stay. Collected all screenshots in a word doc, and see if it stays.
>
> Thanks,
> Dongfeng
>
> On Sunday, April 15, 2018, 3:47:32 PM CDT, Dongfeng Lu
> <[email protected]> wrote:
>
>
> 3 more screenshots.
>
> On Sunday, April 15, 2018, 3:45:04 PM CDT, Dongfeng Lu <[email protected]>
> wrote:
>
>
> Colm,
>
> Thank you very much for your response.
>
> The funny thing is our existing application is XML based, and I did read
> that CXF-6740. However, adding "<property name="usePathBasedConfig"
> value="true"/>" to our project did exactly the same thing as in Figure 2 in
> the previous posting, that is, the Swagger UI displays the titles
> correctly, but both pages do not have any method. See the screenshot
> "Figure 6".
>
> As I was building a sample project using the XML configuration to
> demonstrate it, I accidentally set the context root to an empty string ""
> during the deployment of the project to a Tomcat server in Eclipse.
> Suddenly, things seem to work correctly. I see methods as shown in "Figure
> 7". This is a progress, however, we do need use a non-empty context root,
> as we are building a WAR file, and that WAR file is supposed to work under
> any context root. How should we do that?
>
> Since there is a little progress here, I made some changes under
> "com.example.api.serverTwo". I moved the implementation class to be in the
> same folder as its interface, that is, under "com.example.api.serverTwo.api"
> and removed the folder "com.example.api.serverTwo.impl". I also added two
> more interfaces and implementations as that resembles the our actural
> application. See "Figure 8".
>
> Then my second issue. Keep using the empty context root for now, I can see
> "Figure 9", "Figure 10", and "Figure 11". But these 3 screenshots look
> exactly the same in the middle, displaying methods for 3 servers. I would
> expect "Figure 9" to only contain TwoServer's methods, just like in
> http://localhost:9080/twoServer?_wadl, not methods belonging to
> "TwoServer_SubServer 1" or "TwoServer_SubServer 2". This is not correct.
> Even the generated "curl 'http://localhost:9080/twoServer/twoServerSubOne'"
> is wrong as there is NO "/twoServer/twoServerSubOne" in the wadl, and
> running this command would get "404 Not Found". How can we limit it? Do we
> have to move the 3 sets of interfaces and implementations into their own
> folders?
>
> The third issue I have is that we used to have "@Path("")" for all our
> interfaces, even for interfaces in the same package, as the "address"
> attribute in <jaxrs:server> has already defined "root" path for the
> interface, why do we need to add another layer. However, if I use
> "@Path("")" for the 3 interfaces under "serverTwo", all 3 would only
> display "TwoServer_SubServer 2" as shown in "Figure 12". I guess we just
> have to move the 3 sets of interfaces and implementations into their own
> folders. Any other solution?
>
> The attached project has the code to reproduce the above finding. It is an
> ANT + Ivy project. BTW, I am using CXF 3.1.11, the project is developed and
> deployed to Tomcat in Eclipse.
>
> Thanks for your help.
> Dongfeng
>
>
>
> On Thursday, April 12, 2018, 11:30:13 AM CDT, Colm O hEigeartaigh <
> [email protected]> wrote:
>
>
> I think when you have the two separate endpoints it's necessary to set the
> setUsePathBasedConfig value to "true", otherwise you end up with some
> caching of APIs. The following JIRA explains it better:
>
> https://issues.apache.org/jira/browse/CXF-6740
>
> It seems that the problem with "setUsePathBasedConfig" is set to true might
> be unique to spring-boot, as the following CXF demo sets it to true for
> multiple endpoints in Tomcat and it appears to work correctly:
>
> https://github.com/apache/cxf/blob/master/distribution/src/
> main/release/samples/jax_rs/description_swagger2_web/src/
> main/webapp/WEB-INF/context.xml
>
> Could you create a JIRA for it and attach the test-case?
>
> Colm.
>
>
>
> On Wed, Apr 11, 2018 at 6:27 PM, Dongfeng Lu <[email protected]>
> wrote:
>
> > Let me explain a little bit more about the structure of this simple
> > project. In the attached "Figure 1", you can see there are two main
> > packages "serverOne" and "serverTwo". Under each one, there is an
> interface
> > like "OneServer.java", an implementation like "OneServerImpl.java", and a
> > CXF configuration file like "OneServerConfig.java". The main part of the
> > "OneServerConfig.java" is
> >
> > @Bean
> > @DependsOn("cxf")
> > public Server oneServerServerREST(ApplicationContext appContext) {
> > JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().
> > createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class);
> > factory.setServiceBean(oneServer);
> > factory.setAddress("/oneServer");
> > factory.setProviders(restProviderList(appContext, oneServer));
> >
> > Swagger2Feature feature = new Swagger2Feature();
> > // customize some of the properties
> > feature.setTitle("oneServer");
> > feature.setResourcePackage("com.example.api.serverOne");
> > feature.setBasePath("/oneServer");
> > feature.setUsePathBasedConfig(Boolean.TRUE);
> > feature.setScan(true);
> > feature.setScanAllResources(true);
> >
> > factory.getFeatures().add(feature);
> >
> > return factory.create();
> > }
> >
> > The structure for "serverTwo" is basically the same, with the main part
> of
> > the "TwoServerConfig.java" as
> >
> > @Bean
> > @DependsOn("cxf")
> > public Server twoServerServerREST(ApplicationContext appContext) {
> > JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().
> > createEndpoint(twoServerJaxRsApiApplication(),
> > JAXRSServerFactoryBean.class);
> > factory.setServiceBean(twoServer);
> > factory.setAddress("/twoServer");
> > factory.setProviders(restProviderList(appContext, twoServer));
> >
> > Swagger2Feature feature = new Swagger2Feature();
> > // customize some of the properties
> > feature.setTitle("twoServer");
> > feature.setResourcePackage("com.example.api.serverTwo");
> > feature.setBasePath("/twoServer");
> > feature.setUsePathBasedConfig(Boolean.TRUE);
> > feature.setScan(true);
> > feature.setScanAllResources(true);
> >
> > factory.getFeatures().add(feature);
> >
> > return factory.create();
> > }
> >
> > So you can see that the two "Servers" are basically the same, and they
> are
> > loaded in "AppConfig.java" via
> >
> > @Import({TwoServerConfig.class, OneServerConfig.class})
> >
> > I am attaching 4 more screenshots here with comments to further explain
> > what we expects and what is happening. "Figure 2" and "Figure 3" show the
> > cases when "feature.setUsePathBasedConfig(Boolean.TRUE);" is enabled in
> > both "OneServerConfig.java" and "TwoServerConfig.java". Like I stated in
> my
> > first email, they display the titles correctly, but both pages do not
> have
> > any method, and I don't even see the "Show/Hide" link.
> >
> > "Figure 4" and "Figure 5" show the cases when "feature.
> > setUsePathBasedConfig(Boolean.TRUE);" is commented out in both
> > "OneServerConfig.java" and "TwoServerConfig.java". Both display the same
> > thing, which is the API on "twoServer" with the actual API showing. I can
> > show/hide the API to show the two methods, "/two" and "/two/feed". We
> need
> > "Figure 4" to display "oneServer" APIs.
> >
> > I hope I have explained my case clearly. Please help.
> >
> > Dongfeng
> >
> >
> > On Tuesday, April 10, 2018, 5:47:52 PM CDT, Dongfeng Lu <
> > [email protected]> wrote:
> >
> >
> > Hi. We have been using CXF for a long time, and we would like to add
> > Swagger 2 to our project. However, I have been having a hard time doing
> it.
> > I have been searching on the web for a couple of days, but I still cannot
> > figure it out. I need help.
> >
> > For easy communication, I have build a sample project to illustrate my
> > issue. You can unzip it and run "mvn clean tomcat7:run" in the directory,
> > and then you can access it with "http://localhost:8080" to display the
> > two REST services, built on two org.apache.cxf.endpoint.Servers.
> >
> > If I comment out "feature.setUsePathBasedConfig(Boolean.TRUE);" in both
> > "OneServerConfig.java" and "TwoServerConfig.java", then both "
> > http://localhost:8080/oneServer/api-docs?url=/oneServer/swagger.json"
> and
> > "http://localhost:8080/twoServer/api-docs?url=/twoServer/swagger.json"
> > display the same thing, which is the API on "twoServer" with the actual
> API
> > showing. I can show/hide the API to show the two methods, "/two" and
> > "/two/feed". Why do they display the same thing?
> >
> > If I enable "feature.setUsePathBasedConfig(Boolean.TRUE);" in both
> > "OneServerConfig.java" and "TwoServerConfig.java", then "
> > http://localhost:8080/oneServer/api-docs?url=/oneServer/swagger.json"
> > displays a page titled correctly with "oneServer", while "
> > http://localhost:8080/twoServer/api-docs?url=/twoServer/swagger.json"
> > displays a page titled correctly with "twoServer". Seems correct, but
> both
> > pages do not have any method, and I don't even see the "Show/Hide" link.
> > Where does those methods go?
> >
> > Of course, we want each link to display its own Swagger information
> > correctly, with all available methods. What have I been doing wrong?
> Please
> > help. Thanks in advance.
> >
> > Dongfeng
>
> >
>
>
>
> --
> Colm O hEigeartaigh
>
> Talend Community Coder
> http://coders.talend.com
>
>
--
Colm O hEigeartaigh
Talend Community Coder
http://coders.talend.com