Wednesday, January 12, 2022

docker: Angular client fails to call web service on docker


 >PROBLEM


You've have an Angular project that uses a web services, for instance Java Spring Boot, that works on the environment that is was created, but when the projects (the client and the WS) are migrated to Docker containers, they fail to communicate.

>SOLUTION


If the usual call using localhost fails, replace it with “host.docker.internal”.

  // usual, outside docker
  //private serverUrl = 'http://localhost:8081'

  // docker, if it fails localhost
  private serverUrl = 'http://host.docker.internal:8080'


Detailed procedure here:

>ENV

Windows 10
Docker
Angular 7..13
Node.js 12..16

Tuesday, January 11, 2022

node.js: angular: An unhandled exception occurred: require() of ES Module node_modules/@angular/compiler-cli/bundles/index.js


 >PROBLEM


- After the following procedure:


ng new myproject

npm install rxjs

npm audit fix --force

ng serve


- The angular application fails to start returning the following message:


An unhandled exception occurred: require() of ES Module node_modules/@angular/compiler-cli/bundles/index.js 

/data/prj/node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js not supported. 

Instead change the require of index.js in 

/data/prj/node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js to a dynamic 

import() which is available in all CommonJS modules. 

See "/tmp/ng-Fe4Op7/angular-errors.log" for further details. 





>SOLUTION


Avoid using --force argument with "npm audit" with this versions (detailed below under ENV topic) until the bug is fixed.

Use just: 

npm audit fix


>ENV

Windows 10

Angular CLI: 13.1.2

Node: 16.13.1

Package Manager: npm 8.1.2

OS: win32 x64


Saturday, January 8, 2022

maven: Error: Could not find or load main class...Caused by: java.lang.ClassNotFoundException:...

 

>PROBLEM


Attempt to run a mvn command, for instance:

  mvn -version

  

Returns:

  <!--Could not find or load main class ...

  Caused by: java.lang.ClassNotFoundException: ...-->



>SOLUTION


Check your envvars (environment variables).

The configuration shall be something like this:


M2_HOME = C:\apache-maven

MAVEN_OPTS=-Xms256m -Xmx512m

Path=%Path%;%M2_HOME%\bin


For some mistake, you may have a misconfiguration. For example:


***WRONG:

MAVEN_OPTS=-%M2_HOME%\bin



>ENV

Windows 10

apache-maven





@CTL: y;faq-Error: Could not find or load main class...Caused by: java.lang.ClassNotFoundException:<memo<maven;.

Tuesday, January 4, 2022

angular: Cannot parse arguments. See below for the reasons. Argument --ssl could not be parsed using value "true\r".Valid type(s) is: boolean

 

>PROBLEM


Angular project fails starting and returns the following error message:


Cannot parse arguments. See below for the reasons.

Argument --ssl could not be parsed using value "true\r".Valid type(s) is: boolean



>SOLUTION


It happens when a project using Windows encoding is deploy on *nix environment due the carriage return (CR) differences.

Convert the CRs to unix format.

There are many ways of doing that:


1. If using Git, when it is installed, during its install wizard, there are options to set automatically de CR format.


2. Free apps like SciTE, Notepad++, VSCode and etc. have encoding and CR converters.


>ENV

windows 10

angular



@CTL:
y;faq-Cannot parse arguments. See below for the reasons. Argument --ssl could not be parsed using value "true\r".Valid type(s) is: boolean<memo<angular;.

Monday, January 3, 2022

docker: angular service returns ERR_EMPTY_RESPONSE

 

>PROBLEM


Attempt to access an Angular project running from a docker fails, returning on the browser "ERR_EMPTY_RESPONSE".


>SOLUTION


Add --host argument to the "ng serve" command to start the service.


- before:

ng serve --port 4400 --ssl true


- after:

ng serve --port 4400 --ssl true --host 0.0.0.0

also tested OK with:
ng serve --port 4400 --ssl true --host=0.0.0.0


>ENV

windows 10
angular 16


>ref

tipsfordev.com/localhost-didn-t-send-data-err-empty-response-and-curl-52-empty-reply-from-server


@CTL:

y;faq-angular: ERR_EMPTY_RESPONSE<memo<docker;.

Sunday, January 2, 2022

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.

 

>PROBLEM


Attempt to map a volume fails retuning:


docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.


>SOLUTION


WRONG:

docker run -it --name extodo alsdias/express_todo -v C:\data:/home


RIGHT:

docker run -it --name extodo -v C:\data:/home alsdias/express_todo


>ENV

w10

docker


eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...