IHostBuilder not working while IWebHostBuilder in Linux in aspnet core 3.1 web api application - startup

I have .net core web api project. I am running my application in both Windows and Linux
Problem is My application get starts and works in both linux and windows with IWebHostBuilder while equivalent(what i think so) code for using IHostBuilder didn't start my application in linux.
Please somebody give idea what wrong i am doing
Following currently works
public static IWebHostBuilder BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args).
ConfigureKestrel(serverOptions =>
{
}).UseIISIntegration()
.UseStartup<StartupShutdownHandler>();
Following doesn't works in linux
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serveroptions => { }).UseIISIntegration().UseStartup<StartupShutdownHandler>();
});

Problem was in my linux service file about the --service.urls argument.
I were using --service.urls argument while recommended way is to use --urls.
Details are mentioned at https://github.com/dotnet/aspnetcore/issues/20566

Related

Need to check how to use sikuli with Selenium in Docker

I am using Selenium and Sikuli in Windows and Ubuntu in Java programing.
For example, I am giving other sample code.
package com.sikuli.demo;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.openqa.selenium.chrome.ChromeDriver;
public class SikuliDemo {
public static void main(String[] args) throws FindFailed {
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
String filepath = "D:\\Guru99Demo\\Files\\";
String inputFilePath = "D:\\Guru99Demo\\Files\\";
Screen s = new Screen();
Pattern fileInputTextBox = new Pattern(filepath + "FileTextBox.PNG");
Pattern openButton = new Pattern(filepath + "OpenButton.PNG");
WebDriver driver;
// Open Chrome browser
driver = new ChromeDriver();
driver.get("http://demo.guru99.com/test/image_upload/index.php");
// Click on Browse button and handle windows pop up using Sikuli
driver.findElement(By.xpath(".//*[#id='photoimg']")).click();
s.wait(fileInputTextBox, 20);
s.type(fileInputTextBox, inputFilePath + "Test.docx");
s.click(openButton);
// Close the browser
driver.close();
}
}
I need to execute code in Docker (installed Docker on Ubuntu machine).
Using one docker file as of now.
docker pull selenium/standalone-chrome
If you can suggest how to integrated Sikuli in any docker image it will great. (like selenium-chrome base image..need to integrate Sikuli with the same)
Basically, i have created few keyword driven framework which is using Selenium and Sikuli. But, if I need to execute in docker. need to check how both selenium and sikuli work together.
Since you have tests running on Ubuntu you know how to install Sikuli.
Do same installation for the docker using dokerfile
Then make sure your docker has real UI - not headless. You need this since Sukuli is real UI automation tool and needs UI to run against

Puppeteer: Download Chromium for different platforms

I'm building a UI-automator with Puppeteer and I'm shipping it as a Electron-packaged app. It works nice-and-smooth except for this issue:
Chromium is not downloaded exception is thrown when the app is executed on a platform different than the one the app has been packaged on.
Better said, I'm developing on a Linux environment and I'm packaging my app for both Linux and Windows, Linux app works fine, Windows app doesn't.
The problem is: Chromium is downloaded at npm install time, and it's done selectively based on the current platform. Being current platform Linux, this very version of Chromium is then shipped regardlessly on every platform's app.
I should be able to do one of the following:
Download all-platform Chromium when npm install (on dev machine)
Download Chromium selectively at packaging time (still on dev machine)
Force my users to download Chromium at runtime (at first usage for example)
The problem is I haven't found any Puppeteer configuration I can use for such purpose.
Thanks
The Chromium download is done by node_modules/puppeteer/install.js during npm install. You could call this code from your application's build scripts. For example:
const Downloader = require('puppeteer/lib/Downloader');
const revision = require('puppeteer/package').puppeteer.chromium_revision;
Downloader.createDefault().downloadRevision('win64', revision, () => undefined)
.then(() => { console.log('Done!') })
.catch(err => { console.log('Error', err) })
An update to #Pasi's answer, the following works for "puppeteer": "^1.15.0"
const puppeteer = require('puppeteer');
const browserFetcher = puppeteer.createBrowserFetcher({ platform: 'win64' });
const revision = require('puppeteer/package').puppeteer.chromium_revision;
browserFetcher.download(revision)
.then(() => console.log('Done'))
.catch(error => console.log('Error', error))

springBoot application on Jboss EAP, servlet context not lodaed

I have a very simple spring boot application that I want to deploy to Jboss EAP. Here is my simple application class:
#SpringBootApplication
public class MayurApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(MayurApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<MayurApplication> applicationClass = MayurApplication.class;
}
#RestController
class GreetingController {
#RequestMapping("/hello/{name}")
String hello(#PathVariable String name) {
return "Hello, " + name + "!";
}
}
and my pom.xml is also very basic. When I run this application on Tomcat, using the embedded Tomcat what ships with spring boot. Everything works like charm in just one click. I can access http://localhost:8080/demo/hello/World and it works too.
Now I tried to make it Jboss EAP compatible war, I disabled the Tomcat by excluding from spring-boot-starter-web, and convert it into a war project. (as suggested by article http://spring.io/blog/2014/03/07/deploying-spring-boot-applications).
I also added:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>,
as it was complaining.
Now after all this, it compiles fine and creates a war too. When I copied this war to jboss deployment, I can see it successfully deployed on console.
But the rest api http://localhost:8080/demo/hello/World just does not work and constantly throws error on browser:
JBWEB000068: message /demo/hello/World
JBWEB000069: description JBWEB000124: The requested resource is not available.
What am I doing wrong?
Found this in Spring Boot Reference Guide, add the below line in application.properties file
server.servlet-path=/*
tested this in jBoss EAP 6.2 and worked fine.
Answer is here : Spring Java Config vs Jboss 7
Apparently "/" does not work on Jboss EAP 6.3 , but "/*" works.
and they seems to have fixed it with wildfly 8
You mentioned JBoss 6 in you tags. Based on my experience Spring Boot Autoconfigure and JBoss 6 (specifically) is a no-go. If Hot Deploy is turned on or perhaps some other condition JBoss VFS performs some aggressive scanning of all jars in the war file. Once it starts to scan the classes in the autoconfigure module, it will abort due to an error akin to ClassNotFoundException. If you are using Autoconfigure, one solution might be to place the spring modules in the Container's lib. But this would make deployment unwieldy. I did not see this behavior on JBoss 7 nor Wildfly 8.

Installutil keeps telling me "No public installers found". Any ideas?

I am trying to install a Windows service just created in Visual Studio 2008. The Install.log file tells me the following again and again:
No public installers with the RunInstallerAttribute.Yes attribute could be found in the [correct path to my assembly] assembly.
My service has an installer "serviceInstaller1" which is Public and has the correct service name. It also has a serviceProcessInstaller1 that is also Public.
Why can't InstallUtil find the installer in my service assembly?
Turns out everything works when the service.exe is on the C drive.

Experience with running Jetty 7 or 8 from ant?

Is there a way to run jetty 7 or 8 from ant? There's an ant plugin that works fine with the (pre-eclipse) version 6 only, but the eclipse versions seem only available in standalone form.
Quote from http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty
Jetty has a slogan, "Don't deploy your application in Jetty, deploy Jetty in your application." What this means is that as an alternative to bundling your application as a standard WAR to be deployed in Jetty, Jetty is designed to be a software component that can be instantiated and used in a Java program just like any POJO. Put another way, running Jetty in embedded mode means putting an HTTP module into your application, rather than putting your application into an HTTP server.
This means that you can just add a single java class in your project, compile and run with something like:
<target name="run.jetty">
<java class="myjettyrun/RunJetty" classpathref="classpath.run.jetty"/>
</target>
And the RunJetty.java would look something like this:
package myjettyrun;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class RunJetty {
public static void main(String[] args) throws Exception {
Server server = new Server(80);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar("distrib/wars/root.war");
server.setHandler(webapp);
server.start();
server.join();
}
}
This has been tested with Jetty 8. Make sure you have all the required jetty jars (jetty-webapps, jetty-server) and possibly jsp support (eg. jsp-2.1-glassfish) with their dependencies in classpath.run.jetty.
In http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty you can find more examples on how to run jetty in different situations.

Resources