0

I know that jax-rs 1.1 not supports upload directly and every application server has its own implementation to handle multipart/form-data. I can't realize how to do it with Websphere Liberty 17 using jax-rs 1.1 feature. jaxrs-2.0 feature I can't use because it conflicts with openidConnectClient-1.0

I understand that Websphere Liberty's solution to upload files based on Apache Wink but it doesn't recognize any of the following files: InMultiPart or BufferedInMultiPart as described here: Apache Wink : 7.8 MultiPart

Where am I wrong? Thank you.

Anatoly
  • 5,056
  • 9
  • 62
  • 136

2 Answers2

2

You should be able to use the InMultiPart and BufferedInMultiPart APIs when using the jaxrs-1.1 feature. The knowledge center provides some instructions here: https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/twbs_jaxrs_multipartcontent.html

However, I suspect that the problem is resulting because your application does not specify the "third-party" API type. This is required in order to access APIs from non-IBM sources - in this case, Apache Wink. I don't think that this gotcha is well documented in the knowledge center (I will work with the IBM documentation team and try to improve the docs).

Can you check your server.xml file for something like this:

    <application id="myApp" name="myApp" type="war" location="myApp.war">
        <classloader apiTypeVisibility="spec, ibm-api, third-party"  />
    </application>

The apiTypeVisibility of "spec" and "ibm-api" are enabled by default, but "third-party" is not. Adding this line should allow your application to load the org.apache.wink.* classes.

Hope this helps, Andy

Andy McCright
  • 1,273
  • 6
  • 8
  • I tried to do as you advised but `Eclipse` doesn't see `InMultiPart ` and `BufferedInMultiPart ` files. I think that your solution more relevant if I'd encountered with runtime issue, it can't find files even before I published war on Liberty, when I try to compile it. It didn't mentioned in documentation but maybe I need to add **Apache Wink** library manually to my project or I miss something else? – Anatoly Jun 19 '17 at 16:06
  • 1
    My understanding was was that the Eclipse tooling (WDT) would see the same packages that the runtime provides - make sure that you have your project's build path set up to use the server's build path. Worst case, you should be able to add the library at /dev/api/third-party/com.ibm.websphere.appserver.thirdparty.jaxrs_1.0.*.jar (the micro version number will depend on which version of Liberty you are using) to your project's class path to find those classes at development time. – Andy McCright Jun 19 '17 at 17:52
  • Thank you very much for your help, you provided me some clue what can cause the issue, and thank to it I've found what caused it. I didn't mention that I built project using `maven` and `archetype` from liberty's repository. Default configuration doesn't contain required third-party libraries and another dependency should be added to `pom.xml` to import it. I will provide detailed explanation in my answer, but please keep your answer too, it can be helpful to someone else. Thank you again for your help! – Anatoly Jun 20 '17 at 06:45
0

I didn't mentioned this in my question because I didn't think it can be relevant to my issue, but I have built project with Maven by using archetype provided by Liberty Maven Repository. Default configuration of the project provided by this archetype: webapp-jee7-liberty doesn't contain all third-party libraries, for example com.ibm.websphere.appserver.thirdp‌​arty.jaxrs_1.0.*.jar as mentioned by Andy McCright in comments to him answer. So you have two options, or add this dependency manually (what I'd like to avoid) or add it through pom.xml as following:

<dependency> <groupId>com.ibm.tools.target</groupId> <artifactId>was-liberty-impl</artifactId> <version>RELEASE</version> <type>pom</type> <scope>provided</scope> </dependency>

was-liberty-impl: This dependency contains third-party implementation libraries such as Open JPA, Wind, and Jackson.

For more detailed explanation look at this resource: Configuring dependency POM files that emulate the classpath of specific WebSphere runtime environments

Of course you should add to server.xml the following code: <application id="myApp" name="myApp" type="war" location="myApp.war"> <classloader apiTypeVisibility="spec, ibm-api, third-party" /> </application> As Andy McCright explained here: https://stackoverflow.com/a/44632423/947111

Anatoly
  • 5,056
  • 9
  • 62
  • 136