Sunday, July 30, 2023

[java] [maven] [dropwizard] DropWizard HelloWorld API from scratch



[0] Preparation.

[1] Make project directory

[2] Create pom file

[3] Create source directory

[4] Complete the pom file

The full pom file would be as follows:

[5] Add Dropwizard files

  • Configuration Class File
  • Application Class File
  • Representation Class File
  • Resource Class File
  • Health Check Class File (optional)
  • Config File

[5.1] Configuration

Location:src\main\java\com\mycompany\helloworld\HelloWorldConfiguration.java

[5.2] Application

Location:src\main\java\com\mycompany\helloworld\HelloWorldApplication.java

[5.3] Representation

Location:src\main\java\com\mycompany\helloworld\api\HelloWorld.java

[5.4] Resource

Location:src\main\java\com\mycompany\helloworld\resources\HelloWorldResource.java

[5.5] HealthCheck

Location:src\main\java\com\mycompany\helloworld\health\HelloWorldResource.java

[5.6] Config

Location:config.yml

[6] Compile and run

Read More

[java] [maven] [dropwizard] Running a Dropwizard application in IntelliJ IDEA, Eclipse and NetBeans

 .

Dropwizard is a framework for building RESTful web services in Java. Similar to Spring Boot, Dropwizard applications are packaged into an executable fat JAR file. In addition to executing a Dropwizard application from the command line, you can increase your productivity by configuring your IDE to do that for you. I’m going to be looking at how to run a Dropwizard application in IntelliJ IDEA, Eclipse and NetBeans.


To execute a Dropwizard application, its main method needs to be called with the correct arguments. When you execute a JAR file from the command line, the JVM reads the entry point to your application from the MANIFEST.MF file. It contains key-value pairs and the key we’re interested in is Main-Class. In a Dropwizard application, this is set to your Applicaiton class.

.

https://blog.indrek.io/articles/running-a-dropwizard-application-in-intellij-eclipse-and-netbeans/

Read More

[java] [maven] [dropwizard] Dropwizard with JDBI

[0] Preparation.

[1] Clone project

[2] Compile Maven project

Note: you may get error like "Blocked mirror for repositories". This is due to the use of unsecured http. Open pom.xml file and replace "http://" with "https://"

[3] Run migration (h2 database)

Note: you may get error like "Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException". This is due to the JAXB APIs considered to be Java EE APIs and therefore are no longer contained on the default classpath in Java SE 9. In Java 11, they are completely removed from the JDK.

Add the following codes to the dependency section of pom.xml file

[4] Run application

The application will be opened at port 8082 (refer below console output)

Read More

[java] [maven] [dropwizard] [mysql] Dropwizard on host with MySQL on docker

[0] Preparation.

[1] Clone project

[2] Change directory to the project root

[3] Compile Maven project

If you get error invalid target release 11, it could be that your java sdk is not 11. Install JDK 11 first and then set JAVA_HOME path for the JDK 11.

[4] Setup MySQL to run in Docker

Note:you may need to check the name of the container by running docker console command first.

docker ps
  

[5] Run migration

[6] Run application

[7] Test

[8] Check MySQL Database using container terminal

[9] Check MySQL Database using DBeaver on host

Read More

[java] [maven] [intellij] How to Write Unit Tests in Java

[0] preparation.

[1] Git clone project.

[2] Change directory to the project root.

[3] Open project using IntelliJ IDE.

.

.

follow the next steps at https://www.freecodecamp.org/news/java-unit-testing/


REF:




Read More

[docker] [dockerhub] Create a new Docker Image, Run as Container

Start working in a new project directory.

Create demo index.html file.

Create Dockerfile and copy the index.html into the container. (save as .Dockerfile)

Build image.

Run container from image.




Read More

[docker] [dockerhub] Pull Docker Image from Docker Hub and Run it

Pull Image from Docker Hub.

Run the downloaded Docker Image & Access the Application.

Browse the application at http://localhost/hello.





Read More

Saturday, July 29, 2023

[java] [maven] [pom] what is Project Object Model (POM) file?

 




Maven projects, dependencies, builds, artifacts are modeled and described by an XML file called a Project Object Model. 

The POM tells Maven what sort of project it is dealing with and how to modify default behavior to generate output from source. 

In the same way a Java web application has a web.xml that describes, configures, and customizes the application, a Maven project is defined by the presence of a pom.xml. 

It is a descriptive declaration of a project for Maven; it is the figurative “map” that Maven needs to understand what it is looking at when it builds your project.


Reference:

Maven: The Complete Reference - 3.2. The POM

Maven Getting Started Guide

Introduction to Maven


Read More

Friday, July 28, 2023

[java] [maven] [dropwizard] [docker] helloworld dropwizard-0-9-2 docker build and run

Note: the following notes is based on windows powershell environment

[0] Continue from the previous post

 

[1] Create Dockerfile at project root

[2] Build image

[3] Run container from image

[4] Browse the page.

http://localhost:8080/hello-world

http://localhost:8080/hello-world?name=Successful+Dropwizard+User





Read More

[java] [maven] [dropwizard] helloworld dropwizard-0-9-2 from scratch

This exercise attempt to recreate the dropwizard helloworld app using PowerShell console, notepad, Java and Maven.

Note: the following notes is based on windows powershell environment

[1] make new project directory



[2] change directory to the project directory



[3] create pom file



[4] create source code directory



[5] change directory to source code directory



[6] create package directory



[7] change directory to package directory



[8] create java file (HelloWorldCofiguration.java)



[9] create java file (HelloWorldApplication.java)



[10] create java file in sub folder (resources/HelloWorldResource.java)



[11] create java file in another sub folder (api/Saying.java)



create yml file at project root (hello-world.yml)



compile package



run jar file


Read More

[java] [maven] [dropwizard] helloworld dropwizard-0-9-2

Note: the following notes is based on windows powershell environment


[1] clone github repo



[2] change directory into the project directory



[3] get maven package



[4] run jar file




REF: 
Read More

Wednesday, July 26, 2023

[docker] [minikube] Create a Deployment

 

[0] Create a minikube cluster

Refer: https://technotes.razzi.my/2023/07/docker-minikube-installation.html


[1] Create a deployment


[1].Use the kubectl create command to create a Deployment that manages a Pod. The Pod runs a Container based on the provided Docker image.


[2].View the Deployment:


[3].View the Pod:


[4].View cluster events:


[5].View the kubectl configuration:


[2].Create a Service

[1].Expose the Pod to the public internet using the kubectl expose command:


[2].View the Service you created:


[3].Run the following command:


.

.

References: 


 


Read More

[docker] [minikube] installation

 

Note:

minikube installation requires hyper-v

however hyper-v may not be available on certain windows version e.g. windows 10 home edition

the following is the alternative approach using docker

[0] Run Docker

Run Docker as administrator

[1] Install minikube via Chocolatey

 minikube start --driver=docker



[2] Open Dashboard

minikube dashboard


http://127.0.0.1:61358/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/workloads?namespace=default

Dashboard:



References:

https://kubernetes.io/docs/tasks/tools/



Read More

[java] [maven] [dropwizard] HelloWorld demo REST service

 


[1] Clone DropWizard HelloWorld demo from github

git clone https://github.com/timmackinnon/dropwizard-helloworld.git



[2] Build (maven) application

cd into the folder dropwizard-helloworld

run maven command

mvn package





[3] Run (java) application

java -jar target/dropwizard-helloworld-1.0-SNAPSHOT.jar server hello-world.yml



[4] Test via browser

http://localhost:8080/hello-world



http://localhost:8080/hello-world?name=Successful+Dropwizard+User





Read More

[java] [maven] Create Your First Maven Project

 




[0] Pre-requisite

[0.1] Java 

https://technotes.razzi.my/2023/01/java-jdk-install-java-8-or-java-18-jdk.html

[0.2] Maven

https://technotes.razzi.my/2023/01/java-maven-installation.html


[1] Create New Project

Select menu File/New/Project...



Type the name of the project



Click Create.

Maven will automatically create POM and Java file.



[2] Run

select menu Build/Build Project...



Alternatively, right-click main.java file, select menu run







Read More

Monday, July 3, 2023

[laravel] [jetstream] installation

[1] Create Laravel project

Launch a terminal and run the following command:

[2] Install JetStream LiveWire Frontend Framework

After the project has been created, you can navigate to the application directory and start Laravel Sail:

Reference

Laravel Jetstream: https://jetstream.laravel.com/3.x/introduction.html

Read More

[laravel] [sail] [breeze] [bootcamp] chirper project setup

For Windows user:

The following command is linux-based which may not be properly executed under windows environment. It is recommended that Windows Subsystem for Linux (WSL) is installed and used for this exercise. Refer https://learn.microsoft.com/en-us/windows/wsl/install

[1] Get chirper docker project

Launch a terminal and run the following command:

[2] start project

After the project has been created, you can navigate to the application directory and start Laravel Sail:

When developing applications using Sail, you may execute Artisan, NPM, and Composer commands via the Sail CLI instead of invoking them directly:

[3] Installing Laravel Breeze

Open a new terminal in your chirper project directory and install your chosen stack with the given commands:

Breeze will install and configure your front-end dependencies for you, so we just need to start the Vite development server to automatically recompile our CSS and refresh the browser when we make changes to our Blade templates:

In case vite is injecting wrong url eg using ip address 0.0.0.0 , add the server hrm entries in the vite.config.js file as follows:

Reference

Laravel Bootcamp: https://bootcamp.laravel.com/blade/installation

Sail Service: https://laravel.com/docs/10.x/installation#choosing-your-sail-services

Read More

Friday, June 23, 2023

[uipath] [studio] installation [community]

1] Download and install



 .

2] Wait while the product installs.



3] Installation done.


4] Run.


(You need to login to the cloud account first.)


(If you click on the Tutorials button, you will be forwarded to https://docs.uipath.com/studio/standalone/2023.4/user-guide/tutorials)


5] Start your journey



6] Create a new process.







7] Quick Tour.




Read More

Wednesday, June 21, 2023

[aspnet] [4.x] ASP.NET (Razor) Web Pages - Creating WebPagesMovies site [tutorial] [visualstudio] [2017]

1. Create ASP.NET (Razor) Web Site

1.1. Select menu File/New/Project...


1.2. Select Razor v3 ASP.NET Web Site (C#)

Save project as WebPagesMovies 


1.3. Project creation is done.



Visual Studio 2017 created startup folders and files.


1.3. Open Web.config

The webconfig file contains a connection string to an sdf file

Download the sdf file:

https://archive.org/download/aspnet_tutorial/WebPagesMovies.sdf

Put the file into the App_Data folder.

(The App_Data folder might have contained a database file StarterSite.pdf. As for now, ignore it.)

2. Add an ASP.NET (Razor) Web Page

In the Project Explorer, right-click the Project Name item, select Add/Add_New_Item ...



Create an empty Razor C# file with the name Movies.cshtml

Put the following codes:

Run the project

click the Web Launch button

Wait for the web browser to open the page.



Note

To switch the connection to an sql server,edit as follows:

(The sql connection string above connects to the server hosted by somee.com)

Replace the connection name in the script file Movies.cshtml i.e replace the string "WebPagesMovies" with "SQLServerConnectionString" as shown below:

The followings are the sql scripts to create and populate Movies table:

.
Read More

[aspnet] [error] Unable to connect to the configured development Web server

 .

error message


Unable to connect to the configured development Web server.


Failed to register URL "http://{ip_addr}:{port}/" for site "{project_name}" application "/". Error description: Access is denied. (0x80070005)

.

solution:

Run Visual Studio as Administrator.

.

Read More

Tuesday, June 20, 2023

[aspnet] ASP.NET Overview

 .

ASP.NET is a free web framework for building great websites and web applications using HTML, CSS, and JavaScript. You can also create Web APIs and use real-time technologies like Web Sockets.

ASP.NET Core is an alternative to ASP.NET. See the guidance on how to choose between ASP.NET and ASP.NET Core.

Get started

Install Visual Studio Community edition, a free IDE for ASP.NET on Windows.

Websites and web applications

ASP.NET offers three frameworks for creating web applications: Web Forms, ASP.NET MVC, and ASP.NET Web Pages. All three frameworks are stable and mature, and you can create great web applications with any of them. No matter what framework you choose, you will get all the benefits and features of ASP.NET everywhere.

Each framework targets a different development style. The one you choose depends on a combination of your programming assets (knowledge, skills, and development experience), the type of application you're creating, and the development approach you're comfortable with.

.

Below is an overview of each of the frameworks and some ideas for how to choose between them. If you prefer a video introduction, see Making Websites with ASP.NET and What is Web Tools?

FrameworkIf you have experience inDevelopment styleExpertise
Web FormsWin Forms, WPF, .NETRapid development using a rich library of controls that encapsulate HTML markupMid-Level, Advanced RAD
MVCRuby on Rails, .NETFull control over HTML markup, code and markup separated, and easy to write tests. The best choice for mobile and single-page applications (SPA).Mid-Level, Advanced
Web PagesClassic ASP, PHPHTML markup and your code together in the same fileNew, Mid-Level

Web Forms

With ASP.NET Web Forms, you can build dynamic websites using a familiar drag-and-drop, event-driven model. A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.

Learn more about Web Forms

MVC

ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards.

Learn more about MVC

ASP.NET Web Pages

ASP.NET Web Pages and the Razor syntax provide a fast, approachable, and lightweight way to combine server code with HTML to create dynamic web content. Connect to databases, add video, link to social networking sites, and include many more features that help you create beautiful sites that conform to the latest web standards.

Learn more about Web Pages

Notes about Web Forms, MVC, and Web Pages

All three ASP.NET frameworks are based on the .NET Framework and share core functionality of .NET and of ASP.NET. For example, all three frameworks offer a login security model based around membership, and all three share the same facilities for managing requests, handling sessions, and so on that are part of the core ASP.NET functionality.

In addition, the three frameworks are not entirely independent, and choosing one does not preclude using another. Since the frameworks can coexist in the same web application, it's not uncommon to see individual components of applications written using different frameworks. For example, customer-facing portions of an app might be developed in MVC to optimize the markup, while the data access and administrative portions are developed in Web Forms to take advantage of data controls and simple data access.

Web APIs

ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.

.



.

Read More