I am building a bat file which automatically adds android environment to my worklight project and produce me with the apk file and worklight .war and .wlapp files to my destined location.
I have completed and everything works fine. i am using mfp bulid -d command to build the project and i have modifided the ant file in the MobileFirstServer Generator so that the above command give me .war file of the project.
Now my requirement is i want to build my project to a remote server so that my project.properties file in the android also gets updated with the serverip which i provide and i want to do this with the mobilefirst cli command since i am using a bat file and executing the commands.
I have seen this in the CLI build.xml file so this means if i have a build.properties file in my project anywhere i dont know exactly where it will take the ip,root,etc from that file.
XML
<!-- specify properties in this file or loaded from build.properties
<property name="worklight.server.install.dir" value=""/>
<property name="worklight.hostname" value="localhost"/>
<property name="worklight.port" value="10080"/>
<property name="worklight.username" value=""/>
<property name="worklight.password" value=""/>
<property name="worklight.app.dir" value=""/>
<property name="worklight.app.environments" value="common,iphone,android,blackberry10,windowsPhone8,windows8,ipad,mobileWebApp"/>
-->
In current releases of Worklight/MFP (6.x - 7.0), the CLI tool does not provide the ability to alter the IP address to a remote server prior to the build.
The workaround is to manually edit the wlclient.properties (Android, WP8) or worklight.plist (iOS) files in order for the application to connect to the remote server.
I have Done what i wanted via build.properties file.
Placed it in the Project folder of Worklight Project.
build.properties file has the following things in it
worklight.hostname=111.111.11.11
worklight.port=9090
Note: The above works only when internet connectivity is not present (i.e your ip-address should not be present for your system) This is an issue which i have noted. if your internet connectivity is there it will take your current ip address.
Related
my project has a messages_tr.properties file outside of any sub-module. It is configured by this xml:
<bean id="messageSource" class="...ExposedResourceBundleMessageSource"> // derived from ReloadableResourceBundleMessageSource
<property name="basenames">
<list>
<value>file://${PROP_PATH}/messages</value>
...
</list>
</property>
<property name="cacheSeconds" value="40"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="fallbackToSystemLocale" value="false" />
</bean>
When I run project in debug mode, it works just fine. But, any change to the messages_tr.properties doesn't reflect. Neither editing any key-value pair, nor adding a new one.
I thought it maybe a Intellij Cache problem and tried several combinations of:
Invalidate Caches / Restart
Close Project, delete all .iml + .idea + target
restart computer
Rebuild + mvn clean install -DskipTests -P Profile
File -> Synchronize
VCS -> Refresh File Status
try on IE and Chrome Incognito, Chrome ctrl-f5
add ?*.properties to Settings -> Compiler -> Resource Patterns
I don't want to create a new property file just for this problem, and also it may not work too. I just run out of ideas.
What may prevent Intellij IDEA to update a property file? How can I resolve this?
EDIT: I have a key-value pair in this messages_tr.properties file like key = abcd and I edit it with editor to key = abcd222. Or I add a new pair key2 = abcd222. In the 1st case, message still comes as abcd and in the 2nd case, I get an error saying there is no key like key2. I mean editing content doesn't work.
PROP_PATH is a folder outside of any project module, here absolute path method is used. PROP_PATH is configured via server.xml in websphere configuration wlp folder. This configuration works, but editing doesn't reflect.
We are trying to use a org.JSON.JSONObject library for some intense json processing in the adapter side. We have Java classes which processes the data received from http adapters.
mobilefirst 6.3.0 and using cli 20150701 build
(the recent one).
This JSON referencing has no issues when building from eclipse mobilefirst studio environment.
We are building this environment in ubuntu linux 14.04. There is an error in referencing org.JSON.JSONObject..x.jar file when we execute
mfp start or mfp build or mfp deploy
Is there a way to reference this jar file during mfp start or mfp build or mfp deploy as a classpath.
We need to have something like
mfp -classpath "path/to/json.jar" build
please help.
As it turns out, the CLI does not yet recognize jars placed into the server/lib folder of your project. In oder to make this work, you can make a simple edit to the following file:
[cli install folder]/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml
At or about line 123, add the third fileset element shown below:
<!-- Classpath for server runtime libraries used when building the WAR -->
<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>
After that, running 'mfp start' (or 'mfp restart' if your server is already running) will compile your custom Java code with any jars that you add to the server/lib folder included in the classpath.
JARs for use by your adapters should be added to you Project's server directory in the folder lib. They will be included in your Projects WAR file when the project is built (in Studio or by the ant tasks) and when you deploy that WAR it will be visible to your adapters.
I agree with #bjustin_ibm. Thanks for that. While the above approach works, there's also another way of doing this.
Alternative hack
Just add your required .jars to the following location, it gets added to the classpath during mfp start
/home/instanceubuntu/.ibm/mobilefirst/6.3.0/server/wlp/dev/spi/third-party
This solution is more simple and doesn't really have to maintain the build.xml file.
Hope this helps.
I am trying to add Java classes to my adapter as described in the tutorial Using Java in Adapters. However, I am trying to do that from the CLI.
When I do:
wl create WLProject
cd WLProject
wl add adapter
copy the Java class (Calculator1.java) to server/java/com/worklight/customcode
wl start
The build process fails and no war file is created;
When I do:
wl create WLProject
cd WLProject
wl add adapter
wl start
copy the Java class (Calculator1.java) to server/java/com/worklight/customcode
wl build
wl deploy
wl invoke
The invocation fails. When I inspect the war file, the Calculator1.class has not been deployed.
So the question is: how can I add Java classes to an adapter when using the CLI?
Sounds like a bug to me. It looks like the build process fails when introducing server-side artifacts.
This might be not currently supported in the CLI, but I can't imagine such a limitation...
I've opened a defect to have this looked at.
You can open a PMR (support ticket) to receive a fix if/when available.
If I do the following,
the .war file is being generated.
wl create myTestProject
cd myTestProject/
wl build
But if I do this,
the .war file is not generated which is why everything else then fails:
wl create myTestProject
mkdir -p myTestProject/server/java/com/worklight/customcode
cp Calculator.java myTestProject/server/java/com/worklight/customcode
cd myTestProject/
wl build
There's an invalid classpathref in the build file that's producing the WAR.
You can edit [CLI Install Location]/worklight-cli/node_modules/generator-worklight-server/lib/build.xml to fix this issue with the classpathref.
If you're not planning on using any server runtime libraries:
On line 132, you can remove the attribute classpathref="server-classpath".
If you plan on using server runtime libraries:
You'll need to add the "server-classpath" to be used when compiling your code. Before the build-WAR target in the build.xml file, you can add the following
<path id="server-classpath">
<fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
<fileset dir="[your home directory]/.worklight/6.2.0/server/wlp/dev" includes="**/*.jar" />
</path>
Please note that the second fileset, you'll have to change [your home directory] to the appropriate path. Adding both of these filesets includes the worklight runtime and the server runtime when compiling your classes.
When you've made your changes:
Restart the server. At this point, the Calculator1 class should be added to your WAR.
Version: Worklight 6.0
I'm following the instructions in infocenter for deploying the war file to a standalone websphere application server 8.5 and there is one step that I do not understand.
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fdevref%2Fc_ant_tasks_sample_config_files.html
Step 5.
In the configureapplicationserver and unconfigureapplicationserver invocations (in target install and uninstall), define Worklight properties. For a list of properties that can be set, see Configuration of IBM Worklight applications on the server. In production, you must often define the following specific properties:
publicWorkLightHostname
publicWorkLightProtocol
publicWorkLightPort
In configureapplicationserver/unconfigureapplicationserver those properties do not exist, how do I define them and where and how do I use them in the ant file?
Or does this mean that before using this ant script I have to change the values of those properties in the worklight.properties file and (automatically) generate the WAR file? If this is the case I think it is not clear.
Thank you.
Define the three properties in install/uninstall target like this:
<property name="publicWorkLightHostname" value="myhost.com"/>
<property name="publicWorkLightProtocol" value="http"/>
<property name="publicWorkLightPort" value="9080"/>
Or you can set the three properties in worklight.properties file before running Ant. To set the properties, open the war file with tools like 7zip and modify the worklight.properties.
I'm currently using MSBuild to create an MSDeploy package by passing in arguments:
/p:DeployOnBuild=true;DeployTarget=Package
I'm using a parameters.xml file (placed at the root of my website). Another SO question I found tries to set up the application pool.
My parameters.xml file:
<parameters>
<parameter name="Application Pool Name" description="Application Pool for this site" tags="" defaultValue="ASP.NET v4.0">
<parameterEntry kind="DeploymentObjectAttribute"
scope="application"
match="/application/#applicationPool" />
</parameter>
...
</parameters>
but it seems that the archive.xml file inside the msdeploy package generated by the msbuild doesn't have an section with an applicationPool element
How can I get the archive.xml to be generated with this section so that I can set the application pool?
The app pool I want to set will exist already, so I'm not concerned with MSDeploy synching or creating app pools here.
Edit:
I have found this question How do I control the AppPool used for deploy through VS & MSDeploy settings which hints at using wpp.targets to generate a custom provider. I'm exploring how to use this approach to modify the archive.xml file
Assuming you have the correct IIS settings on your project and are running as Administrator, you should be able to specify IncludeIisSettings=true to have the settings included in the zip.
If you need the actual AppPool definition included (so it can be created), you should also set IncludeAppPool=true.