MFP CLI cannot build-deploy project initially created with MFP Studio

不打扰是莪最后的温柔 提交于 2019-12-12 17:32:37

问题


Problem Context:
We initially created a MFP hybrid project with the iOS environment using MFP Studio plugin for Eclipse. We have this project under source control (Git on DevOps). Some team members in our team are doing iOS development for this project and since they are not familiar with Eclipse, they are wanting to use the CLI instead. Other developers in the same team will continue to use Studio since they are writing Java code for the MFP adapters and want to leverage the capabilities Eclipse provides such as compilation, code auto-completion, etc.

Problem:
After pulling down the MFP project code from Git (fresh pull), if Studio is first used to “Build All Environments” and “Run on MobileFirst Platform”, we can then run the MFP app without any problems. We can then also switch to the CLI for building and deploying artifacts and the CLI commands work just fine.

Now, say that after pulling down the code from Git (fresh pull), instead of using Studio, we start using right away the CLI for building and deploying artifacts. Under such scenario, the CLI throws errors. It seems that the CLI is missing steps that Studio knows how to do. The errors we get when using the CLI right away for building and deploying (mfp bd) after a fresh pull from Git are the following:

$ mfp bd 
All apps and adapters were successfully built.  
Initializing MobileFirst Console.

BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:147: Compile failed; see the compiler error output for details.

Total time: 1 second
Error: Build process failed. Please check the stack above for details.

BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:380: Element <project> inside <configureApplicationServer>: File '/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/bin/HatchReadyApp.war' does not exist.

Total time: 1 second
Error: Build process failed. Please check the stack above for details.
objc[81801]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Starting server worklight.
Server worklight started with process ID 81800.
    [wladm] Unexpected response from http://192.168.1.126:10080/worklightadmin/management-apis/1.0/runtimes/HatchReadyApp/adapters?locale=en_US:
    [wladm] <?xml version="1.0" encoding="UTF-8"?>
    [wladm] <deploy-adapter-result ok="false" productVersion="6.3.0.00-20150214-1702">
    [wladm]   <transaction id="168" type="UPLOAD_ADAPTER" status="FAILURE" timeCreated="2015-04-13T13:53:18.599Z" timeUpdated="2015-04-13T13:53:18.870Z" userName="admin" appServerId="Liberty">
    [wladm]     <project name="HatchReadyApp"/>
    [wladm]     <description filename="SBBAdapter.adapter" name="SBBAdapter" alreadyDeployed="false"/>
    [wladm]     <errors>
    [wladm]       <error mbeanName="com.worklight.common.server.jmx.api:qualifier=HatchReadyApp,type=ProjectManagement" date="2015-04-13T13:53:18.831Z" phase="PREPARE" code="FAILURE" exception="RuntimeException" details="Runtime synchronization failed. Cannot deploy adapter to runtime"/>
    [wladm]     </errors>
    [wladm]     <warnings/>
    [wladm]   </transaction>
    [wladm] </deploy-adapter-result>

Error: The MobileFirst server that you have configured does not appear to be running. Start the server with 'mobilefirst start'.

More details:

If I start the MFP server first before doing a 'mfp bd', it also fails with a similar error:

$ mfp start
Initializing MobileFirst Console.

BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:147: Compile failed; see the compiler error output for details.

Total time: 1 second
Error: Build process failed. Please check the stack above for details.

BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:380: Element <project> inside <configureApplicationServer>: File '/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/bin/HatchReadyApp.war' does not exist.

Total time: 1 second
Error: Build process failed. Please check the stack above for details.
objc[55444]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Starting server worklight.
Server worklight started with process ID 55443.

MFP info output:

$ mfp info
OS: darwin x64
Release: 14.1.0
System Memory: 89MB free out of 16384MB
Node: v0.10.30
MobileFirst CLI: 6.3.0.00.20150214-1708
Current directory: /Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp

Current project: /Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp

Adapter: getOffers (/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/adapters/SBBAdapter/SBBAdapter.xml)
Description: SBBAdapter
Type: http
Procedures: test, getUser, getAccounts, getTransactions, getGoals, getDashboardData, getFeasibility, submitAuthentication, getTradeoffSolution, getOffers

Application: Hatch (/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/apps/Hatch/application-descriptor.xml)
Description: Hatch
Type: hybrid application
Features: 
Environments: iphone
Skins: 

Server location: /Users/olivieri/.ibm/mobilefirst/6.3.0/server
Server binary: /Users/olivieri/.ibm/mobilefirst/6.3.0/server/wlp/bin/server
MobileFirst instance: /Users/olivieri/.ibm/mobilefirst/6.3.0/server/wlp/usr/servers/worklight
objc[85669]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
WebSphere Application Server 8.5.5.3 (1.0.6.cl50320140731-0257) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_51-b13 (en_US)

Environment variables:
TERM_PROGRAM: Apple_Terminal
ANDROID_HOME: /Users/olivieri/android-sdks
SHELL: /bin/bash
TERM: xterm-256color
TMPDIR: /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/
Apple_PubSub_Socket_Render: /private/tmp/com.apple.launchd.JKtd63AtGc/Render
TERM_PROGRAM_VERSION: 343.6
TERM_SESSION_ID: D5FA1866-C7B1-4AC0-A045-B8BD0AF18A5D
ANT_HOME: /Users/olivieri/Development/apache-ant-1.9.4
USER: olivieri
SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.ECR6tzx7Xe/Listeners
__CF_USER_TEXT_ENCODING: 0x1F5:0x0:0x0
PATH: /Users/olivieri/Development/apache-ant-1.9.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/IBM/MobileFirst-CLI:/Users/olivieri/Development/gradle-1.12/bin:/Users/olivieri/android-sdks/tools:/Users/olivieri/android-sdks/platform-tools
PWD: /Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp
LANG: en_US.UTF-8
XPC_FLAGS: 0x0
XPC_SERVICE_NAME: 0
SHLVL: 2
HOME: /Users/olivieri
LOGNAME: olivieri
DISPLAY: /private/tmp/com.apple.launchd.8nfQqEAeMS/org.macosforge.xquartz:0
_: /Applications/IBM/MobileFirst-CLI/IBMnode/bin/node
WLP_USER_DIR: /Users/olivieri/.ibm/mobilefirst/6.3.0/server/wlp/usr

回答1:


Thanks to the IBM folks who helped us resolve this problem. To fix this issue, we had to make two changes to the following file: /Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml

We replaced the following two sections [in this file] as shown below:

1)

 <!--
  <path id="server-classpath">
    <fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
    <fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
  </path>
 -->

  <path id="server-classpath">
    <fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
    <fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
    <!-- add server/lib folder to classpath -->
    <fileset dir="${worklight.app.dir}/../server/lib" includes="**/*.jar" />
  </path>

2)

<!--
  <target name="build-WAR" description="Build worklight WAR for project">
    <echo message="Building worklight WAR for project ${ProjectName}" />
    <javac
      srcdir="server/java"
      destdir="bin/classes"
      classpathref="server-classpath"
      verbose="true"
      includeantruntime="false"
    />
    <war-builder
      projectfolder="${basedir}"
      destinationfolder="bin/war"
      warfile="bin/${ProjectName}.war"
      classesfolder="bin/classes">
    </war-builder>
  </target>
-->

<target name="build-WAR" description="Build worklight WAR for project">
    <echo message="Building worklight WAR for project ${ProjectName}" />
    <!-- first clear out the existing bin/classes contents -->
  <delete includeemptydirs="true">
    <fileset dir="bin/classes" includes="**/*"/>
  </delete>
    <javac
      srcdir="server/java"
      destdir="bin/classes"
      classpathref="server-classpath"
      verbose="true"
      includeantruntime="false"
    />
    <if>
      <available file="server/java/resources" />
      <then>
        <!-- now copy the contents of server/java/resources into bin/classes so they get included in the war -->
      <copy todir="bin/classes/resources" failonerror="false">
        <fileset dir="server/java/resources"/>
      </copy>
      </then>
    </if>
    <war-builder
      projectfolder="${basedir}"
      destinationfolder="bin/war"
      warfile="bin/${ProjectName}.war"
      classesfolder="bin/classes">
    </war-builder>
  </target>

After making the above changes, we could then run the 'mfp restart' and 'mfp bd' commands without any errors.



来源:https://stackoverflow.com/questions/29608972/mfp-cli-cannot-build-deploy-project-initially-created-with-mfp-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!