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
Resources not listed : Jersey 2.5 + Swagger on Websphere 7 #829
Comments
The I realize it works on Jetty/Tomcat, but obviously something is slightly different in the WebSphere environment. Two suggestions:
|
I have tested setting an explicit path. Setup is
This class is being component scanned by Spring. The reason for doing it this way is to set a different basePath for different environments. My JerseyConfig looks like this
The last block is the interesting one That's it. No more config |
Looks good, overall. I doubt this is the problem, but the line |
I have removed |
Is this the commercial version of websphere or the community edition? |
Commercial. version 7.0.0.19 What's interesting is that to get Jersey to work on WAS7, we have to register each resource, as The development team has structured the code like this
The "application" module contains all resources classes and config, whereas the "webapp" module only contains files under src/main/webapp. |
Thank you for the additional information. Different classloaders could definitely be the issue. Are the JAX-RS resources and the beanconfig in the same module? |
No, I'll move the beanconfig, and retest |
Same result I am afraid. |
And to be certain, the ResourceConfig class is also in the same module as the resources, right? |
Yes, Jax-RS resources, ResourceConfig and SwaggerConfiguration classes are now in the same module |
I think the next step would be to enable the logs and try to see if there's anything there that can help us. Can you try that please? The samples have sample configurations for the logs. |
Yes, I'll have a look at it tomorrow! |
Where can I post the log? |
Best if you put it in a gist and post the link here. |
Ok, this is my log config (taken from samples)
the only thing logged when running on websphere is this
And this is logged in my regular application log
which is logged before the swagger log statements Would it make sense to log org.reflections with level debug? |
Tracing the error and looking into Reflection's code, it looks like the only way to get that error is if resourcePackage is empty or null. I realize it doesn't make a lot of sense, especially since the other parameters seem to load fine. Do you have an additional web.xml configuration (or applicationContext.xml)? By the way, you never mentioned what happened when you tried setting the resourcePackage explicitly (you only mentioned you did it). |
Ok, I have tried hardcoded the settings
Makes no difference |
what about the web.xml/applicationContext (for spring)? |
Here is the web.xml https://gist.github.com/engrun/8c2b6f4fcb7a40372112 The applicationContext is split into several files, and mixing both javaconfig and xml. |
Regarding the parameters, this is the json generated So the other parameters are definitely being picked up |
Thanks for sharing the web.xml. Regarding the applicationContext, I only really need anything that may be related to Swagger (that is, relates to the swagger-core classes). I'm trying to figure out if there's a chance for duplicate definitions that may override each other. |
Ok, there is no reference to com.wordnik or swagger in any spring context files. That is: No other config that what's listed above |
Okay, that's good. Thanks for the patience with this, this is a but uncharted ground and unfortunately I don't have access to WebSphere to do local testing so it requires some back and forth. And since you say it works with jetty/tomcat, we know it's not a configuration issue. Most likely a class loading / ordering issue. Do you have any other application on that WebSphere instance that produces a Swagger documentation? |
Yes, we have. However, that is an Jersey 1.x application with an older swagger implementation.
|
Do you have means to test the application on an isolated WebSphere instance? I'd rather we rule out any chance for conflict there. |
We don't have an isolated instance unfortunately. If so, I would have to contact operations to install a new clean instance. I'm afraid that's not doable/is out of scope at the moment. An easier path would probably be to request upgrading to the latest fixpack. I'm not sure what the timeframe for that would be though |
It's been a really long time for me since I had used WebSphere, but if I recall correctly, there are ways to control the order of the application loading and the scope of the class loaders. Can you see if you can ensure that the new application is loaded before the old one for testing purposes? |
I've set class loading to PARENT_LAST and modified startup order to ensure my new appliation loads before the existing jersey1 application. Still a problem |
Another thing that's worth checking is whether you have the reflections.org library in websphere's shared libraries directory and if so, which version is there. |
Found a workaround! It works now! |
Aha! So it was the |
Yes. |
Thanks for sharing the solution, it may prove helpful to other users as well. Can we close the issue? |
I was a little bit too quick.
I'll revert the |
I was going to check the option set it only for a specific application. The last sentence at http://www-01.ibm.com/support/knowledgecenter/api/content/nl/en-us/SSEQTP_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/xrun_jvm.html#com.ibm.ws.classloader.strict pretty much killed that suggestion. |
The custom property is still a workaround, so I you feel that this issue is not longer a bug, you can of course close the issue again. |
Yeah I know. We were hoping for the same |
Apparently there is a setting in WAS8 (and also the Liberty profile) which looks promising.
which can be set as a global classloading property This was introduced in fixpack explicitly mentioning Jersey and Hadoop Hopefully others on WAS8 can benefit from this if encountering this problem |
Okay, just looked into the GitHub issues for reflections.org and it looks like some fixes were add (though one was rejected) that may help with resolving this issue. This would require some further testing on your end. First step would be to exclude the reflections.org dependency from swagger-core. This is to ensure that maven picks the right version. The second step is to add the reflections.org dependency explicitly, with version 0.10-SNAPSHOT. It should be available from Sonatype and not central. |
I'll try it. Do you have the url to the correct snapshot repo? Can't find it at https://repository.sonatype.org or https://oss.sonatype.org/content/repositories/snapshots/ |
I'll clone the repo and build it locally |
Argh. I'll have a last look at it on Monday. |
Since you're already compiling it yourself, try modifying the pom.xml and set the target version - https://github.com/ronmamo/reflections/blob/master/pom.xml#L250 - to 1.6. Another option is to use the jdk 1.5 profile - https://github.com/ronmamo/reflections/blob/master/pom.xml#L147-L157 |
Hmm there is a reason for target being set to 1.7
There is a profile called jdk1.5 in the pom.xml. However, building with that profile results in the exact same error. It looks like we have to resort to one of two
Again, thanks for assisting |
That's an odd error. I'd expect it to work with source 1.7 and target 1.6. I'll try reaching out the reflections.org developer and see if he can provide any insight (at least regarding the websphere fixes). |
Ok, let my know when you have any news. For now we will setup a new WAS instans as a workaround |
we can't move to java 6 for swagger, so this is going to be a problem. I'll move to m2 just in case there's hope for some sort of resolution. |
hi, support for java6 is not possible. |
Hi
I have successfully configured Swagger with our Jax-rs/Jersey 2 application.
Works fine with maven jetty plugin and on Tomcat test server
However, when deploying to Websphere 7, no resources are listed.
The /api-docs resources returns
My BeanConfig looks like this
(apiVersion, resourcePackage and basePath are defined in a properties file and injected by Spring)
Not sure how to get past this.
We would like to have our APIs documented when running in our production and qa environments
Dependency in pom.xml
The text was updated successfully, but these errors were encountered: