简体   繁体   中英

MobileFirst: CLI Java adapter will not run in Studio

I'm using MobileFirst Platform v7.0 on OSX. I tend to switch back and forth between Studio and the CLI depending on what I am doing.

I found that a Java adapter created through the command line will not build using Studio without some manual configuration. I had this question 95% typed when I found a solution so I decided to post it anyway in hopes it might help others.

To duplicate:

  1. Create a workspace, MFP project and Hybrid app in Studio
  2. In Studio, create a Java adapter named Studio with package com.studio
  3. Deploy the Studio adapter. Adapter builds and deploys successfully.
  4. Open a terminal and navigate to the adapters directory of the project
  5. From CLI, create a Java adapter named CLI with the following command: mfp adapter add CLI -t java -p com.cli
  6. Back in Studio, refresh and Deploy the CLI adapter. Observe error 'com.cli.CLIApplication' was not found .

I discovered the problem is that the source folder adapters/CLI/src was not added to the Java Build Path of the project when the adapter was created using the CLI.

In trying to manually add the source folder to the build path, I found that the 'bin' folder was not created in the CLI directory. If I did not manually create the bin folder and set it as the Output folder for the source folder, I would get the error JAXRS Application class: 'com.cli.CLIApplication' must extend javax.ws.rs.Application .

So the solution is:

  1. In Studio, edit the Java Build Path for the project (right-click the project, Build Path > Configure Build Path ).
  2. Select Source tab and click Add Folder .
  3. Select adapters/CLI/src and click OK .
  4. Select the Output folder under the new entry and click Edit
  5. Enter adapters/CLI/bin .

The adapter should now build in either Studio or CLI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM