I can not find keycloak web resources deployed in tomcat - java

I deployed keycloak in tomcat with eclipse Luna based on this tutorial: https://reachmnadeem.wordpress.com/2015/01/14/deploying-keycloak-in-tomcat/#comment-245
I have it running in my machine and have no problem. Now I have to edit the login form based on my company design. But I do not have local files .css and .htmls to do it.
This is the parent project and some war configuration.
<parent>
<artifactId>keycloak-parent</artifactId>
<groupId>org.keycloak</groupId>
<version>1.1.0.Final</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>keycloak-war</artifactId>
<packaging>war</packaging>
<name>Keycloak Server</name>
<description />
Do I have to donwload the war project, the parent project? I do not know where to start.

First of all please be informed that it is recommended to use standalone Keycloak server - http://keycloak.github.io/docs/userguide/keycloak-server/html/server-installation.html)
And here some details how you are able to customize themes - http://docs.jboss.org/keycloak/docs/1.0-alpha-3/userguide/html/themes.html

You can unzip the keycloak-forms-common-themes-1.1.0.Beta2.jar and under login you can change the css and images and redeploy it

Related

How to know if a project is spring boot or not

I went through a project structure in STS where I could see a MVC pattern where controller, service,Dao , entity classes were there. But looking at pom.xml got to know that it is a web application project. But how to confirm that it is not a spring boot application..?
I m new to spring boot. All I found is there were no starter dependencies in pom.xml or any dependency has word "boot" & there was not a main method where a spring boot project starts.
So my question is which particular dependency/ parameters differentiates spring boot application from a non spring boot application ?
In general in the first part of the pom.xml you can see this tag:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
Check the pom.xml. see if it includes the spring boot dependency or any other Spring boot dependency flavors like Spring-boot-starter, spring-boot-autoconfigure,spring-boot-web etc....
Basically anything with group ID
"org.springframework.boot"
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
Additionally also look for the #SpringBootApplication annotation on top of the main class.
If you're running a Gradle project, you might see something like this inside of one of your build.gradle (or [projectName].gradle) files.
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
Or maybe
apply plugin: 'org.springframework.boot'
The above advice to search globally for org.springframework.boot is sound, just wanted to stress there might not be a pom.xml (or any .xml) files present.

Java - IntelliJ Community Maven Web App

I'm trying out Java coming over from .NET and want to make a simple page that does the following:
Implements RESTful API
Connects to a MySQL Database
Implements Role-based Security
I tried out Eclipse but wasn't met with much success, plus the code completion was very slow compared to VS2017. So I'm trying out IntelliJ Community. I've built a Maven project, but my URL is not running, also it looks like I'm not getting any code completion in my .java files. It did not build the app directories automatically.
My POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.johnnytest.webapp</groupId>
<artifactId>jerseyexample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jerseyexample Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>snapshot-repository.java.net</id>
<name>Java.net Snapshot Repository for Maven</name>
<url>https://maven.java.net/content/repositories/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.26</version>
</dependency>
</dependencies>
<build>
<finalName>jerseyexample</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/</url>
<!--<username>joe</username>-->
<!--<password>joe</password>-->
</configuration>
</plugin>
</plugins>
</build>
</project>
My web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.johnnytest.app</param-value>
<load-on-startup>1</load-on-startup>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
My Java file:
package com.johnnytest.app;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
#Path("/test")
public class MainApp {
#GET
#Path("/{param}")
public Response getMessage(#PathParam("param") String message) {
String output = "Jersey says " + message;
return Response.status(200).entity(output).build();
}
}
Also it's running Tomcat 7, and I've installed 9 on my system. Is there any way to get it to run on my existing Tomcat install? When I go to any URL on localhost:8080 I just get a blank page in Safari. Running on OSX Sierra.
Launch at Command line
if you didn't do it already, download Apache Maven 3.5.0 and add the /bin directory to the system PATH variable.
Enter the directory where the pom.xml file is and run the following:
mvn clean package
mvn tomcat7:deploy
mvn tomcat7:start
The first command will build the code and produce a Java WAR archive in the subdirectory target/.
The second command will deploy the WAR archive to Tomcat application server.
The third command will start Tomcat and expose the server as per configuration (localhost:8080).
Don't worry about the command tomcat7, even if you're using Tomcat 9 it should be fine.
Launch within IntellJ
Maven management in IntelliJ is not really optimal, but on the right side you should see a Maven Projects pane (if you don't, select "Tools -> View tool buttons" menu). Click and expand.
Under Lifecycle you will find the standard Maven goals, so double clicking on clean and then package will produce the WAR file in a similar manner as explained in the previous section.
Under Plugins you will find the Maven goals ruled by the Tomcat plugin. Expand and double click tomcat7:deploy and tomcat7:start.
A quick parallel with ASP.NET
If you come from .NET, just think of Tomcat as the Java version of IISExpress that comes bundled with VisualStudio. It is a application server where you deploy the application code and which emulates a webserver service for development.
There are many parallels and also many discrepancies. In general, an application lifecycle in .NET is much more contained, you rarely need anything else beyond VisualStudio and MSBuild, I think. In Java, many things have been created and evolved through the decades thanks to the community: we have different build systems (Maven, Ant, Gradle), the best tooling is command line and there are multiple ways to achieve the same goal.
For example, you are using the Jersey REST library with an underlying app server below (Tomcat), but you could also deploy to a NIO server (Grizzly). If you use extended frameworks like Spring, you generally don't even worry about these things because switching from one way to the other is just a matter of importing a module in your pom.xml instead of another.
Hope this helped you and gave you some directions.

How to use custom module.xml and deploy after custom module of JBOSS EAP6.4 with Spring Boot Application

We are using artesia 3rd party product for our project and it is deployed in JBOSS EAP6.4, I want to use spring boot in our project and when I write sample REST webservices I am able to access the REST web service via URL.
As per the documentation of our product if we need to customize the project we need to write our custom war by specifying below two JBOSS files inside META-INF folder
jboss-all.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="artesia.ear" />
</jboss-deployment-dependencies>
</jboss>
so our custom logic should begin after successful start of artesia.ear.
our jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment>
<dependencies>
<module name="deploy" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Above deploy module contains all jars necessary for the project to run.
When I follow the same and created the war without spring in it, it was successful and there are no issues, we are able to use to customize war.
Now I want to do the same in Spring-boot 1.4.1 application, where my spring boot app should start after artesia.ear starts successfully and apart from spring jars my spring-boot app should use jars from module.xml.
I have placed the above two xml's inside META-INF of spring boot application but it is failing when deployed in JBOSS EAP6.4
Below is the error that I get
jboss-server.log
What I need to do to use same for my spring-boot app
EDIT 1:
I tried by placing both jboss files under WEB-INF folder of spring-boot application but still the facing the same issue
We need to make sure that META-INF and WEB-INF folders are lying side by side instead of keeping META-INF folder inside classes folder of WEB-INF which is where default spring-boot META-INF folder resides.

Module project is not declared as war package, but get error 'web.xml is missing and <failOnMissingWebXml> is set to true' in eclipse

Module project was declared as war package before in pom.xml, then I removed row <packaging>war</packaging>, I can get expected XX.jar successfully when I run command line mvn install, however, I'm still get error web.xml is missing and <failOnMissingWebXml> is set to true in eclipse.
I have applied 'Force update of snapshot/releases' several times but it's meaningless.
pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xx</groupId>
<artifactId>xxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>xxx</artifactId>
<name>xxxx</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>xxxx</groupId>
<artifactId>xxxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I found there is web service descriptor however there shouldn't be. I didn't find any way I can delete the descriptor I copy all source files to another folder, create another workspace in eclipse and import the project. All works well.
I had a similar problem - maven project that due to some refactoring went from war package to jar. Was surprisingly difficult to clear the dang marker "web.xml is missing but failOnMissingWebXml is true".
I checked thru the .classpath and .project files - the project in particular had several WST natures that I deleted. After that, I finally deleted the project from Eclipse but left the files on disk, then re-imported the existing maven project into Eclipse. This worked, I think the delete cleared all the hidden metadata.
Just had the same issue - you need to generate a web.xml file.
Right click on Deployment Descriptor in Project Explorer.
Select Generate Deployment Descriptor Stub.
It will generate WEB_INF folder in src/main/webapp and an web.xml in it.
Thanks

Deploy Jenkins CI to Heroku

Is there a way to run Jenkins CI as an Heroku app?
It is possible to run Java Apps on heroku but I cannot find description of how to make Jenkins run on Heroku anywhere.
Very grateful for hints.
Easy enough to load Jenkins as a heroku app
1) pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Just need a plain and mostly empty pom.xml for Orchard to detect that this is a Java application
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>helloworld</artifactId>
</project>
A Procfile that looks like this:
Only listen on http; disable ajp and https
web: java -jar jenkins.war --httpPort=$PORT --ajp13Port=-1 --httpsPort=-1
The jenkins.war file.
The real problem becomes that jenkins uses the local filesystem for storage and the local storage is not persistent in the Heroku environment so you have to manage your configuration regularly or using the github storage add-on.

Categories

Resources