Running Solr on Azure Web Apps - java

I have tried to run it in azure web app, but it doesn't work.
Here is my configuration. Maybe someone know how achieve this.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%HOME%\site\wwwroot\webapps\solr-6.0.0\bin\solr.cmd"
arguments="start -p %HTTP_PLATFORM_PORT%"
startupTimeLimit="20"
startupRetryCount="2"
stdoutLogEnabled="true">
<environmentVariables>
<environmentVariable name="JAVA_HOME" value="D:\Program Files\Java\jdk1.8.0_73" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Here is the Error Message:
The handle could not be opened
during redirection of handle 0.
The handle could not be opened
during redirection of handle 0.
ERROR: Java 1.8 or later is required to run Solr. Current Java version is:

There are two ways for setting up the Java version on Azure WebApp.
Configuring the web.config file in the Kudu Console via the url https://<your-webapp-name>.scm.azurewebsites.net/DebugConsole as your said. However, please set the JAVA_HOME environment variable with the value D:\Program Files (x86)\Java\jdk1.8.0_73 if your webapp not enable 64-bit for the option PLATFORM of Azure portal, see the figures below.
Fig 1. The Platform option of the tab CONFIGURE on Azure old portal
Fig 2. The PLATFORM option of the Appication settings on Azure new portal
Directly setting up in the Application settings on Azure new portal, please see the figure below and refer to the blog.
Fig 3. The Java version option of the Application settings on Azure new portal
Update
You can try to add the line below at the line 65.
set "JAVA_HOME=D:\Program Files\Java\jdk1.8.0_73"

Related

Selenium WebDriverManager - Exception when running on Linux Server

I am new to Selenium and having some issues.
I am using the WebDriverManager in connection with Selenium. This is my code:
WebDriverManager.chromedriver().setup();
When I run the code on my local system (Windows 10 OS), everything runs perfectly fine. When I run my code as a web application on our Linux Server (Ubuntu 18.04, Tomcat 9), I get the following exception:
io.github.bonigarcia.wdm.config.WebDriverManagerException: Exception reading resolution cache as a properties file
at io.github.bonigarcia.wdm.cache.ResolutionCache.<init>(ResolutionCache.java:86)
at io.github.bonigarcia.wdm.WebDriverManager.getResolutionCache(WebDriverManager.java:1490)
at io.github.bonigarcia.wdm.WebDriverManager.clearResolutionCache(WebDriverManager.java:780)
at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:1263)
at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:1060)
at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:393)
....
Caused by: java.io.IOException: No such file or directory
at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.base/java.io.File.createNewFile(File.java:1035)
at io.github.bonigarcia.wdm.cache.ResolutionCache.<init>(ResolutionCache.java:75)
I am using Selenium 4.2.1 and Webdriver 5.1.0.
On our Linux server, I have installed Google Chrome as described here. When running
google-chrome --version
-> Google Chrome 102.0.5005.115
I get the shown result, so I think Chrome should be installed correctly.
Has anybody an idea?
It seems it is failing to create the resolution cache, which is a properties files created by default in the following path: ~/.cache/selenium. You can try to create manually that path (although WebDriverManager should have been able to create when it does not exist).
In any case, to debug it properly, you need to check the WebDriverManager traces. For that, you need need to include a Logback configuration file (for example, like this) in your project classpath. The name of this file should be src/test/resources/logback-test.xml (if you want logs only for your tests) or src/test/resources/logback.xml (if you want logs for both tests and application code). Then, you can to use the following line to set the level to TRACE:
<logger name="io.github.bonigarcia" level="TRACE" />
For further info about logging with with SLF4J and Logback you can see the following tutorial.

The lib and classes folders are staged and deployed with IntelliJ but gcloud command does not include them

I have a Java 8 Spring Boot GAE Standard App and I use IntelliJ IDE (Cloud Code plugins for GAE applications).
I use AppEngine-web.xml.
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<sessions-enabled>true</sessions-enabled>
<runtime>java8</runtime>
<application>***</application>
<service>***</service>
<version>***</version>
<url-stream-handler>urlfetch</url-stream-handler>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
<async-session-persistence enabled="true" />
<instance-class>F2</instance-class>
<resource-files>
<include path="/**.json" />
</resource-files>
<use-google-connector-j>true</use-google-connector-j>
<env-variables>
<env-var name="GOOGLE_APPLICATION_CREDENTIALS"
value="WEB-INF/***.json" />
</env-variables>
</appengine-web-app>
When I deploy my GAE app using IntelliJ, these folders are generated in my staging, and everything works well;
Here is a snapshot of my Run Configuration on IntelliJ
The issue arises when I deploy it using gcloud command:
gcloud app deploy src/main/webapp/WEB-INF/appengine-web.xml --version=something --promote --stop-previous-version --verbosity=debug
Here is the generated staging folder:
I have .gitignore file in my app root; I removed that to check if it is creating the issue and no luck and I also did the same with .cloudignore.
gcloud deploy skips files and the output is like:
DEBUG: Loading runtimes experiment config from [gs://runtime-builders/experiments.yaml]
INFO: Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]
DEBUG:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\runtime_builders.py", line 269, in _Read
with contextlib.closing(storage_client.ReadObject(object_)) as f:
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\storage\storage_api.py", line 317, in ReadObject
object_=object_ref, err=http_exc.HttpException(err)))
BadFileException: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
DEBUG: Experiment config file could not be read. This error is informational, and does not cause a deployment to fail. Reason: Unable to read the runtimes experiment config: [gs://runtime-builders/experiments.yaml], error: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py", line 146, in _ServerSideExperimentEnabled
runtimes_builder_root)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\runtime_builders.py", line 524, in LoadFromURI
.format(uri, e))
ExperimentsError: Unable to read the runtimes experiment config: [gs://runtime-builders/experiments.yaml], error: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
WARNING: <application> and <version> elements in `appengine-web.xml` are not respected
INFO: Executing staging command: [C:\Program Files\Common Files\Oracle\Java\javapath\java.exe -classpath C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar com.google.appengine.tools.admin.AppCfg --enable_new_staging_defaults stage E:***\src\main\webapp c:\users\***\appdata\local\temp\tmp1nhtxn\tmpoizcfc]
DEBUG: Executing command: [u'C:\\Program Files\\Common Files\\Oracle\\Java\\javapath\\java.exe', u'-classpath', u'C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\google_appengine\\google\\appengine\\tools\\java\\lib\\appengine-tools-api.jar', u'com.google.appengine.tools.admin.AppCfg', u'--enable_new_staging_defaults', u'stage', u'E:***\\src\\main\\webapp', 'c:\\users\\***\\appdata\\local\\temp\\tmp1nhtxn\\tmpoizcfc']
INFO: ------------------------------------ STDOUT ------------------------------------
Reading application configuration data...
Beginning interaction for module ***...
0% Scanning for jsp files.
2021-12-22 15:11:47.738:INFO::main: Logging initialized #167ms to org.eclipse.jetty.util.log.StdErrLog
2021-12-22 15:11:48.115:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=0ms
0% Generated git repository information file.
Success.
Temporary staging for module *** directory left in C:\Users\***\AppData\Local\Temp\tmp1nhtxn\tmpoizcfc
------------------------------------ STDERR ------------------------------------
2021-12-22 15:11:47.221:INFO::main: Logging initialized #725ms to org.eclipse.jetty.util.log.StdErrLog
--------------------------------------------------------------------------------
I've managed to replicate this similar issue on a same project. This is because Java 8 may be considered a legacy version, but best practice still applies and that is to use App Engine Maven Plugin when submitting deployments. Full documentation could be found through this link.
I've changed the gcloud command:
gcloud app deploy src/main/webapp/WEB-INF/appengine-web.xml
--version=something --promote --stop-previous-version --verbosity=debug
To this:
mvn clean package appengine:deploy
This process would take some time as it would clean and reinstall packages before deploying your project.
Here's a Github link similar to your project that you can try on your end as this one works for me.
EDIT:
Google App Maven plugin for Java 8 is still updated regularly based on this Github link.
The standalone App Engine SDK, and the Maven plugin (com.google.appengine:appengine-maven-plugin) which is based on it, are now shut down. You must use Cloud SDK tooling and migrate to the Cloud SDK-based Maven plugin (com.google.cloud.tools:appengine-maven-plugin). Full description and steps could be found through this link on how to use Maven.
That is why it is very important that we use mvn clean package appengine:deploy.
I would also include a code snippet from pom.xml containing the configurations that you need to set:
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<projectId>GCLOUD_CONFIG</projectId>
<version>GCLOUD_CONFIG</version>
<deploy.promote>true</deploy.promote>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
</configuration>
</plugin>
Full documentation can be found through this link containing sample Java codes for handling requests
Also, Intellij is also using a plugin for Google Cloud called Cloud Code, which is a similar plugin with Maven.
I've tried deploying an app.yaml file and got this error:
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT:
WEB-INF/appengine-web.xml is required for this runtime.
Overall, it's not possible to use gcloud tool if you want to deploy a Java 8 project. If you really want to use gcloud, you need to upgrade to Java 11.
Here are the additional references that I've used to replicate this project:
https://cloud.google.com/appengine/docs/standard/java/runtime
https://cloud.google.com/appengine/docs/standard/java/config/appref

How to troubleshoot Microsoft Azure WebApp on java? How to access logs?

I have a java-application (standard springboot from default tutorial: https://spring.io/guides/gs/spring-boot-for-azure/ ) that I "successfuly" deploy to my WebApp (created during deployment) via Eclipse/maven plugin azure-webapp:deploy
Once deployed, files are inside the WebApp, I can see them. If start-up is successful I do get running application, but if it is not - I do not know how to troubleshoot. I don't know where to find error logs, what caused the problem and as consequence, how to solve it.
as an example of how to make it fail, add this line:
throw new RuntimeException("Doomed to fail");
I tried enabling logs from "diagnostic logs tab" and expected to see them under LogFiles/Applications but that folder remains empty.
How do I troubleshoot java-application that fails to start in WebApps of Azure?
edit: additional example of Exception to troubleshoot:
public static void main(String[] args) {
throw new RuntimeException("start failure #21");
//SpringApplication.run(Application.class, args);
}
It sounds like you followed the springboot tutorial Deploying a Spring Boot app to Azure to build the GitHub project microsoft/gs-spring-boot and deploy to Azure, but not works.
Here is my steps which I also followed the tutorial, but deployed via my own way.
I created a directory SpringBoot on my local machine, and to do the commands cd SpringBoot and git clone https://github.com/microsoft/gs-spring-boot.
Then, to build it via commands cd gs-spring-boot/complete and mvnw clean package
Note: I reviewed the sections of the tutorial under Create a sample Spring Boot web app which seems to do on Linux, but the web.config file in microsoft/gs-spring-boot/complete is ready to Azure WebApp for Windows. However, there is not any comments to describe the deployment target that be Azure WebApp for Windows or Linux.
So I used my existing WebApp for Windows to test my deployment. I open my Kudu console in browser via the url https://<webapp name>.scm.azurewebsites.net/DebugConsole and drag the files complete/web.config and complete/target/gs-spring-boot-0.1.0.jar to site/wwwroot as the figure below. Then, I started my webapp, and it works fine.
Note: Please check the JAVA_HOME environment variable which has been configured on Azure via command echo %JAVA_HOME% as the figure below.
If not, you need to set Java runtime in the Application settings tab of Azure portal.
Or you can also configure the web.config file to replace the reference %JAVA_HOME% with an existing Java runtime installed in the path D:\Program Files\Java of Azure WebApp, as below.
<?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" -->
<httpPlatform processPath="D:\Program Files\Java\jre1.8.0_181\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\gs-spring-boot-0.1.0.jar"">
</httpPlatform>
</system.webServer>
</configuration>
I didn't manage to find logs in windows based machine, but If you enable logs on linux-based-machine you will see them in the "Diagnostic logs" output. There is a catch though.
There is 230 timeout. It will wait full "timeout" time, until producing logs in the log file, after which you can access them via log file or through "Diagnostic logs". Make sure to enable logging before you start application. This applies to linux based machine, I don't know if it can apply to windows based machine.
Then it waits for an answer trigger. Answer trigger, as it turns out, is a phrase in console output "Application is started in X seconds". I increased the timeout to 500 seconds, because although it starts in 60 seconds on my local machine, it takes 430 seconds on remote-linux-based machine of Microsoft Azure*
Second, I changed the name of my main class from "GameStart" to "Application" and after that it actually caught the trigger. After that the application started. Nowhere in manuals did I find the "until timeout - no logs" and "trigger phrase" clauses mentioned.
ps: For reference, it took me 20 to upload application, 5 minutes to start it. I was using centralUS server, cuz centralEU did not work out for me, as it was even longer, although I'm in central EU myself
-
*using test account. It might happen that on payed account number are either different or similar.

How do I stop a service during uninstall with WiX Toolset (MSI Installer)?

I am using WiX Toolset to create a MSI installer. This installs a Java application which has a native wrapper that gets installed as a service.
I have got this to install fine but when I try and uninstall it the Restart Manager detects files in use and displays a dialog saying that a reboot is required.
The Windows service runs the native wrapper bin\wrapper-windows-x86-64.exe. The component configuration for this is:
<DirectoryRef Id="bin97543xxxx">
<Component Guid="cb21cd16-4bb9-4e57-a13c-4d064f01cd43" Id="bin_wrapper_windows_x86_64_exe189026768">
<File KeyPath="yes" Source="bin\wrapper-windows-x86-64.exe" DiskId="1" Name="wrapper-windows-x86-64.exe" Id="fl_bin_wrapper_windows_x86_64_exe189026768"/>
<RemoveFile Name="wrapper.log" On="uninstall" Id="rm_fl_bin_wrapper_log123456789"/>
<ServiceInstall Name="Test App" Description="Test App" Arguments="-s "..\conf\wrapper.conf" wrapper.console.flush=true" Type="ownProcess" Vital="yes" Start="auto" Account="LocalSystem" ErrorControl="ignore" Interactive="no"/>
<ServiceControl Id="StartService" Name="Test App" Start="install" Stop="both" Remove="uninstall" Wait="yes"/>
</Component>
</DirectoryRef>
This native wrapper will launch the JVM java.exe with some other JARs and native DLLs. These JARs and DLLs are defined as separate components such as:
<DirectoryRef Id="bin_wrapper_lib172428748">
<Component Guid="91ea3118-769e-4100-80a2-f09a586500a5" Id="bin_wrapper_lib_wrapper_jar565349582">
<File Source="bin\wrapper\lib\wrapper.jar" DiskId="1" Name="wrapper.jar" Id="fl_bin_wrapper_lib_wrapper_jar565349582"/>
</Component>
</DirectoryRef>
When I try and uninstall the program it detects files in use by java.exe even though when the service stops it will stop the JVM. I have verified this by manually stopping the service before trying to uninstall. Also to note is that if I continue then all the files are removed succesfully, just the Windows service is still there (but marked as deleted). The MSI logs show this:
Action start 15:48:40: InstallValidate.
...
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Detected that application with id 3636, friendly name 'java.exe', of type RmCritical and status 1 holds file[s] in use.
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
...
MSI (s) (AC:68) [15:48:59:078]: RESTART MANAGER: The user chose to go on with the installation, although a reboot will be required.
...
The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.
I've seen some similar questions on SO and the WiX Toolset users mailing list but nothing that really helps. A lot of people are trying to use custom actions and have been told to use the ServiceControl instead which I am already using.
I also saw someone mention the "files in use logic" which I assume is what the Restart Manager is doing. There was a suggestion to add the related files into the component with the ServiceControl element but that doesn't seem right here (or at least I'm not sure how to do it and still follow the best practices around separating components).
Can anyone point me in the right direction?
Possibly a related post - WiX: Avoid showing files-in-use dialog and just prompt for reboot at end of install
Set MSIRESTARTMANAGERCONTROL=Disable. If that doesn't work, drop the FileInUse dialog from your MSI ;)

New relic on Heroku, how to get it to work?

I have deployed a Scala, play framework, application on Heroku.
And I have added the new relic add-on to my app.
I have followed the Java guide as Scala runs on the Java VM.
$ heroku addons:add newrelic:standard
-----> Adding newrelic:standard to ... done, v7 (free)
Unziped newrelic to newrelic in the application
$ git add newrelic
$ git commit -m 'add newrelic'
$ heroku config:add JAVA_OPTS='-Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:newrelic/newrelic.jar'
$ git push heroku master
Now to the problems. First when I accessed the add on I had to create a new account on new relic with new password and it wanted my credentials? Is this correct? Shouldn't my Heroku account suffice, I later think it started to work.? Strange process so now I believe I have two accounts. In Herokus page my account is standard hourly and in new relics it's standard lite.
I don't understand how to see my performance stats. I actually think that the new relic isn't set up correctly?
One absurd thing is the new relics homepage which says not sufficient permissions on everything except "tell a friend and earn bucks" not even support works WTF.
I have attached two screenshot with my credentials masked. can anyone comment if they look like they should or if the new relic has set up itself incorrectly?
You should be able to use New Relic through the heroku interface without creating a separate account.
Once you're app is deployed with the agent, and has gotten a few requests you should start seeing data in the interface.
The agent does create a log (I believe you can get output via heroku logs) so that might also help you troubleshoot it.
I'd suggest opening a support ticket on http://support.newrelic.com.
This could be happening because your hosted application does not have the right credentials (e.g license key) provided by newrelic.
Did you update the default newrelic.yml file obtained from the 'newrelic.jar' extract? You can obtain your app's license key in the account settings menu when accessing newrelic through the heroku interface (your 1st screenshot). Then set the following config vars on heroku;
NEW_RELIC_LICENSE_KEY="your license key"
NEW_RELIC_APP_NAME="your app name"
Don't forget to set the appropriate RACK_ENV config var too e.g RACK_ENV=production
Then update your newrelic.yml file by finding and changing the following lines;
license_key: '<%= license_key %>' to license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
app_name: My Application to app_name: '<%= ENV["NEW_RELIC_APP_NAME"] %>'
app_name: My Application (Development) to app_name: '<%= ENV["NEW_RELIC_APP_NAME"] (Development) %>'
app_name: My Application (Staging) to app_name: '<%= ENV["NEW_RELIC_APP_NAME"] (Staging) %>'
Here is a sample newrelic.yml file with environment vars set.
You should be able to access new relic from heroku interface after you've pushed your changes.
Check whether you find anything in the heroku logs with heroku logs. Also, you can increase the log level of new relic by setting the system properties newrelic.config.log_level and newrelic.debug. Also note that after creation of a new account or after password changes it takes a while until the changed credentials are propagated.
To set a finer log log level:
$ heroku config:set JAVA_OPTS=”-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8 -javaagent:target/staged/newrelic-agent-2.20.0.jar -Dnewrelic.bootstrap_classpath=true -Dnewrelic.config.file=./conf/newrelic.yml newrelic.config.log_level=finer newrelic.debug=true”
Make sure to not run with that in production. It produces quite a lot of logs.
See our blog post about how to setup New Relic with Play 2.1/Scala on Heroku: http://techblog.nezasa.com/2013/08/performance-monitoring-of-nezasa-with.html
When I attempted to use New Relic on Heroku I was prompted to enter credit card information
$ heroku addons:add newrelic:standard
but I just exited out and the logging for my Rails application is working*. Note that depending on your New Relic settings you may just be logging locally (default for development mode does not log to the cloud but is accessible locally).
Sorry to pollute this thread with Ruby stuff, but you may find something similar with regards to Heroku and New Relic.
*update: I had the same issue again when deploying another application and realized that to use the Heroku New Relic add-on you have to provide credit card information, but if you just directly instrument your application you do not have to give credit card information. YOu do have to have created an account already, though.

Categories

Resources