How to install maven on microsoft Azure (app servies) - java

I have an app service, hosted on Azure.
The code for our service is on bitbucket and it is a maven based Java project. The process adopted by developers to deploy WAR files is to build them on local and FTP it to Azure which obviously isn't recommended.
Let's say I don't have the liberty and resource for hosting a CI tool like Jenkins, I am trying to do the following:
Sync the code from bitbucket.org to Azure by using 'Deployment Options' in Azure. Every time I do a git push, Azure automatically picks up the code from the specified branch and copies/updates/deletes the files modified (and places them under wwwroot by default)
I want to modify the deployment.cmd file in Azure so that I can add my custom steps post #1.
Where am I stuck?
I have FTPed maven and unpacked maven under D:\home\maven folder. I have set the correct environment variables by using a XDT file (attached). Yet, when I do mvn -version, I get the following error:
java.lang.NoClassDefFoundError:
org/apache/maven/exception/ExceptionHandler
..
..
caused by ClassNotFound ..
I don't have the complete trace handy. This class is there in maven-core which is there under the lib folder (I verified).
Could it be because of permissions? Cloud is cloudy to me o_O
After I get this to work, I need to add custom steps to deployment.cmd. Is there any specific language which I need to use or windows commands?
XDT file content for env variables (JAVA_HOME is already set)
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document- Transform">
<system.webServer>
<runtime xdt:Transform="InsertIfMissing">
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="M2_HOME" value="D:\home\maven\apache-maven-3.3.9" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
<add name="MAVEN_HOME" value="D:\home\maven\apache-maven-3.3.9" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
<add name="Path" value="%Path%%JAVA_HOME%\bin;%M2_HOME%\bin;" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</environmentVariables>
</runtime>
</system.webServer>

I tried to reproduce the issue, but failed. According to the kudu wiki page for Xdt transform samples, the environment variables seems not support reference each other which had been defined above the current environment varable.
So please change the XDT file content like below that works fine after I test on an Azure Web App instance for Java.
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<runtime xdt:Transform="InsertIfMissing">
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="M2_HOME" value="D:\home\maven\apache-maven-3.3.9" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
<add name="MAVEN_HOME" value="D:\home\maven\apache-maven-3.3.9" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
<add name="PATH" value="%PATH%;D:\home\maven\apache-maven-3.3.9\bin" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</environmentVariables>
</runtime>
</system.webServer>
</configuration>
Then I ran the command mvn -version on Kudu CMD tool, it works fine.

Related

WASX7109E: Insufficient data for install task "MapResRefToEJB

I have a web application which is installed on Websphere with WAR file. I am trying to automatically deploy the webapplication on websphere through a python script. The script is as follows:
###cat deplApps.py
import time
#the 3 arguments are jvm name, ent app name, and path to war file
print "Args are:" , sys.argv
SERVERMBEAN = AdminServerManagement.queryMBeans("AppSrvNode01", sys.argv[0] , "Server")
if SERVERMBEAN == [] :
print "Server is in stopped state"
else :
AdminServerManagement.stopSingleServer("AppSrvNode01", sys.argv[0] )
print "sleeping for 10 seconds"
time.sleep(10)
AdminApplication.updateApplicationUsingDefaultMerge( sys.argv[1], sys.argv[2] )
AdminConfig.save()
time.sleep(10)
Sync1 = AdminControl.completeObjectName('type=NodeSync,process=nodeagent,node=AppSrvNode01,*')
AdminControl.invoke(Sync1, 'sync')
print "sleeping for 120 seconds before starting the server"
time.sleep(120)
AdminServerManagement.startSingleServer("AppSrvNode01", sys.argv[0] )
When I run the script to deploy the war file on Websphere I get the following error:
Exception: <type 'com.ibm.ws.scripting.ScriptingException'> com.ibm.ws.scripting.ScriptingException: WASX7109E: Insufficient data for install task "MapWebModToVH
ADMA0010E: Validation error in task Selecting virtual hosts for Web modules. A virtual host is not specified for web module Work Queues with URI agriworxAPP.war,WEB-INF/web.xml."
WASX7017E: Exception received while running file "/apps/deploy/deplApps.py"; exception information: com.ibm.ws.scripting.ScriptingException: WASX7109E: Insufficient data for install task "MapWebModToVH
When I searched for the error it said I have to provide the ibm-web-bnd.xml ibm-web-ext.xml in the WAR file, So I provided the fillowing ibm-web-bnd.xml and ibm-web-ext.xml files inthe WAR file;
ibm-web-bnd.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="default_host"
<resource-ref>
<description>Work Queues</description>
<res-ref-name>jdbc/WorkQueuestDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>/>
</web-bnd>
ibm-web-ext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<default-error-page uri="error.jsp"/>
<jsp-attribute name="useThreadTagPool" value="true" />
<jsp-attribute name="verbose" value="false" />
<jsp-attribute name="deprecation" value="false" />
<jsp-attribute name="reloadEnabled" value="true" />
<jsp-attribute name="reloadInterval" value="5" />
<jsp-attribute name="keepgenerated" value="true" />
<jsp-attribute name="trackDependencies" value="true" />
<reload-interval value="9"/>
<auto-encode-requests value="true"/>
<auto-encode-responses value="false"/>
<enable-directory-browsing value="false"/>
<enable-file-serving value="false"/>
<pre-compile-jsps value="false"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="true"/>
</web-ext>
Now I am getting the following errorL
Exception: <type 'com.ibm.ws.scripting.ScriptingException'> com.ibm.ws.scripting.ScriptingException: WASX7109E: Insufficient data for install task "MapWebModToVH
ADMA0010E: Validation error in task Selecting virtual hosts for Web modules. A virtual host is not specified for web module Work Queues with URI agriworxAPP.war,WEB-INF/web.xml."
In my case, I was having this error because my app required some bindings to be made. As I wanted to install the app with all the default configurations I just needed to add the parameter -usedefaultbindings.
AdminApp.install("/work/shared/myApp.ear", "-appname myApp -node DefaultNode01 -server server1 -nouseMetaDataFromBinary -usedefaultbindings")
This error has nothing to do with .bnd or .ext files. The command AdminApplication.updateApplicationUsingDefaultMerge as it name stats is used to update existing app, not to install new one. If you want to install you need to use AdminApplication.installXXX commands. Check https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/rxml_7libapp.html So you need to utilize AdminApplication.checkIfAppExists command and based on that either install or update app.
VH is virtual host on your WAS, typically default_host. Sometimes it is used to customize installation see this https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/rxml_taskoptions.html#rxml_taskoptions__cmd61 but I dont know how the AdminApplication is actually utilizing it.

Can't run Core Java web application into Azure Web app

I have written a core java web application using maven-archetype-webapp and trying to deploy the jar file and web.config in a azure windows based webapp but not able to access the url. I only have home page inside my application. and following below steps. I am able to run it in my local system and can see the homepage.
azure-webapp-maven-plugin added in POM and build with mvn azure-webapp:config, then inside configuration tag I added below tag.
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
Created a web app in Windowsusing Java 8 and Tomcat 8.5
Deployed jar file and web.config file inside wwwroot directory
Web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\TestWebApp.jar"">
</httpPlatform>
</system.webServer>
</configuration>
Folder Structure
Azure directory structure
Local system Output:
Thanks #soumen for the solution.
Deployed the war file inside wwwroot -> webapps folder in azure
webapp. Before deploying deleted the Root folder inside webapps, after
my deployment new root folder was automatically generated, now I can
access the url.
I take it as an answer, hoping to help other members.

IBM WebSphere deploy Angular 5 application and getting 404 on refresh

I build full stack applications with Angular (currently version 5) Usually the backend is Windows Server and it uses IIS , so thus I know to deploy a web.config file with the rewrite module code.
Problem is that the site is a SPA , and it needs to always point at index.html, no matter what the URL says...
As I said, I'm used to windows , but the backend is Java with IBM Websphere
Anyone know what I need to have done in order to have a properly working Angular application?
Example, the configuration for WINDOWS is a web.config like this below, but this is Websphere with a Java application and I assume the backend is Linux/unix
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/MyApp/" />
<!--<action type="Rewrite" url="/" />-->
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You'll need to add the following to web.xml, which is packaged in the WEB_INF directory within the .war file of your app:
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
Which tells the app server to show the resource at the application's context root when issuing a 404 error.

How do I request UAC administrative privileges with a JavaFX desktop application bundle?

I need to elevate the permissions of a JavaFX desktop application. Not the .jnlp or the web version. This program will be deployed to desktops so
<fx:deploy
...
>
<fx:application
...
/><fx:resources>
...
</fx:resources>
<fx:preferences
...
/>
<fx:info
...
/><fx:permissions elevated = "true"/> <!--THIS DOESN'T WORK!!!-->
</fx:deploy>
won't work. I can get the program to run fine in my IDE, and when I deploy and set the properties of the application shortcut to run the program as administrator in Windows, that works fine too.
Evidently, according to my employer, anyway, it is too much to expect a user to do that (change the shortcut properties to launch the program as administrator) so I need another solution.
So what do I need to do to always make a JavaFX application request administrative privileges?
EDIT:
Also, using AccessController.doPrivileged(...) does not work either.
You can use lanuch4j that compile jar file to exe.
add filename.manifest to basic/warpper manifest:
it will work well as administrator on windows.
I have tested on my javafx program.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable" uiAccess="False" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

Flex AMF Data/Services Error

After stumbling my way through setting up a BlazeDS service, I was finally able to get the list of services through the Flex Builder Data/Services Wizzard. However when testing any of the services, I get the Error popup of
> "InvocationTargetException:There was an error while invoking the
> operation. Check your operation inputs or server code and try invoking
> the operation again.
>
> Reason: java.io.FileNotFoundException:
> http://127.0.0.1:8080/portlets-0.0.1-SNAPSHOT/messagebroker/amf/
I could not find anyone else with a similar issue, and am unfamiliar with services setup. Below are my configurations. Any help would be greatly appreciated.
I can post config files if it will help, i was getting improper code format errors trying to insert them in this single post.
This service I am testing does not reach the function in the server, it is throwing this error before getting that far...
I have also noticed that I cannot run the flex application through a web browser using the standard run configuration in eclipse as it tries to target:
[http://127.0.0.1:8080/portlets-0.0.1-SNAPSHOT/messagebroker/amf/FlexMissionsOverview/MissionsPortlet.html][1]
Which throws a 404 error on tomcat since the file does not exist there. Are these possibly connected?
Any help would be greatly appreciated.
Added Details based on feedback:
Yes, the project name is "FlexMissionsOverview" with a Base Flex Application Called "MissionsPortlet"(.mxml).
The webapp is deployed to "webapps/portlets-0.0.1-SNAPSHOT/"
Compiler settings below:
-services "C:\liferay\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\portlets-0.0.1-SNAPSHOT\WEB-INF\flex\services-config.xml" -locale en_US
-show-deprecation-warnings=false
-show-binding-warnings=false
Note: I am setting my project back up to where I had gotten to by the time of this post, if anything changes I will make another edit.
services-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<service-include file-path="messaging-config.xml" />
</services>
<factories>
<factory id="spring" class="flex.samples.factories.SpringFactory"/>
</factories>
<services>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
</adapters>
<default-channels>
<channel ref="my-amf" />
</default-channels>
</service>
</services>
<channels>
<channel-definition id="my-amf"
class="mx.messaging.channels.AMFChannel">
<endpoint
url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
class="flex.messaging.endpoints.AMFEndpoint" />
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
</channels>
<logging>
<!-- You may also use flex.messaging.log.ServletLogTarget -->
<target class="flex.messaging.log.ConsoleTarget" level="Error">
<properties>
<prefix>[BlazeDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>true</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.</pattern>
<pattern>Service.</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging>
</services-config>
Pointing to the file directly on the tomcat server seems to work fine for testing the Flex Application via Eclipse, but I am still getting the same "FileNotFoundException" When trying to test the BlazeDS Services in the Data/Services Wizard in FlashBuilder.
Is there any indication of what the FileNotFoundException is coming from when trying to test the services? It may be some of the config information, but I am not positive, since I am used to these Exceptions saying what file it could not find.
The only class that I have in my project that is referenced above is the two listener classes, the other classes I believe come from my maven dependencies.

Categories