Friday, July 16, 2021

Git - Fix Corrupted Object Issue - Simple solution for: error: object file .git/objects ... fatal: loose object ...is corrupt


>PROBLEM

Git pull command fails returning error message of corrupted file:


git pull

error: object file .git/objects/dd/4b0b1a777609ba3f787823e566bfc989905319 is empty

fatal: loose object dd4b0b1a777609ba3f787823e566bfc989905319 (stored in .git/objects/dd/4b0b1a777609ba3f787823e566bfc989905319) is corrupt



>SOLUTION

1.. Copy the corrupted file from another local repository.
If there isn't another, you may clone one.


2. Issue the pull command again.


>ENV

windows 10


 







Wednesday, March 31, 2021

Maven: [ERROR] Child module..does not exist @


 >PROBLEM


mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=ejb-javaee7


Returns:

[ERROR] Child module..does not exist @



>SOLUTION

Check your pom.xml.

Also, check the mirror's configuration in the maven's settings.xml file.


Example: 

C:\Users\MYLOGIN\.m2\settings.xml


<mirrors>

<mirror>

<id>client-repo</id>

<mirrorOf>*</mirrorOf>

<url>http://xyz.core.cliente:8099/nexus/content/groups/my-group/</url>

</mirror>

</mirrors>


Comment, or remove the mirror that is not providing connection.

If it is a project mandatory resource, then report.


>ENV

Windows10

(Same for *nix or apple except the paths)


Friday, March 12, 2021

JavaScript: error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'

>PROBLEM


After adding an implementation to bind using ngModel , for instance:

  <p>

    <label for="example-ngModel">[(ngModel)]:</label>

    <input [(ngModel)]="currentItem.name" id="example-ngModel">

  </p>


Return the error message:

  error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'



>SOLUTION

@SEE: this issue may also be caused by other factors, check:
angular-ngform-error-ng8002-cant-bind.html


Make sure that the app.module.ts has the following configuration:


import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { FormsModule } from '@angular/forms'; // <--- JavaScript import from Angular


@NgModule({

  declarations: [

    AppComponent,

// ...

  ],

  imports: [

    BrowserModule,

    FormsModule,

    AppRoutingModule

  ],

  providers: [],

  bootstrap: [AppComponent]

})

export class AppModule { }



In the app.component.ts (or whatever) file, check the import and make sure the constructor() and ngOnInit() are both declared:


import { Component,  OnInit } from '@angular/core';  // minimal

//import { Component,  OnInit, Output, Input, EventEmitter } from '@angular/core';  // usual 


  constructor() { }

  ngOnInit(): void {

  }


>MORE


>ENV

node.js 14.x.x

windows



Tuesday, March 9, 2021

JavaScript: TypeScript: This condition will always return 'true' since the types 'string' and 'EventEmitter' have no overlap.ts(2367)


 >PROBLEM


The code below returns the error message:

This condition will always return 'true' since the types 'string' and 'EventEmitter<string>' have no overlap.ts(2367)



*** BAD

  crossOffItem(event: EventEmitter<string>): void {

      const ritems = this.items.filter( it => it !== event);

      this.items = ritems;

  }




>SOLUTION


TypeScript complains that the types are not explicitly equivalent or comparable.


*** OK

  crossOffItem(event: EventEmitter<string>): void {

      const ritems = this.items.filter( it => it !== event.toString());

      this.items = ritems;

  }



POOR SOLUTION


  crossOffItem(event: EventEmitter<string>): void {

      const val = event.toString();

      const ritems = this.items.filter( it => it !== val);

      this.items = ritems;

  }


>ENV

Node.js v.14.15.4

Wednesday, March 3, 2021

Oracle Cloud: Linux VM denies access returning "oracle cloud public key WARNING: UNPROTECTED PRIVATE KEY FILE" message

>PROBLEM

You are using Windows and the procedures suggested by Oracle's documentations to connect the Oracle Cloud Linux VM fail returning the message:

oracle cloud Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

>SOLUTION

Faster than "fighting" for an ideal solution via Windows, perform the procedure on Linux environment using a Docker container or a virtual machine (VirtualBox, VMware, etc.). 


>ENV

Oracle Cloud Linux VM
Windows 10
Debian 10/VMware

Tuesday, March 2, 2021

legacy: Netbeans v.6.7.1 Installation - JDK not found issue

 

>PROBLEM

Attempt to execute the installer fails returning message that JDK was not found.


>SOLUTION

This procedure avoids messing with the configuration of your system.

Java installers usually use the following default paths:
C:\Program Files\Java
C:\Program Files (x86)\Common Files\Oracle\Java\javapath

The Netbeans v6.7.1 installer uses by default this:
C:\ProgramData\Oracle\Java\javapath

To avoid changing the System's configuration, the installation may be done as below.

1. Java setup for Netbeans v.6.7.1 

Netbeans v6.7.1 searches "java.exe" by default under the following path:
  C:\ProgramData\Oracle\Java\javapath\java.exe
Check if it is present on the system.

If present, check the java's version:
  C:\ProgramData\Oracle\Java\javapath\java.exe java -version
The Netbeans 6.7.1 accepts Java 8 version.

If not, copy from another folder on the system the "java.exe" for Java 8.
Try the usual default places referred above.
Copy the java executables to the netbean's default path (better all of them, just in case):
java.exe
javaw.exe
javaws.exe

2. Extracts the bundle from the Netbeans executable.
netbeans-6.7.1-ml-windows.exe --extract

3. Run the bundle extrated to start the installer.
java -jar bundle.jar





Saturday, February 20, 2021

Git: FAILURE DUE TO CORRUPTED FILE: remote: error: inflate: data stream error ... remote: error: unable to unpack ... remote: fatal: loose object ... error: remote unpack failed:

 

>PROBLEM

An attempt to update the local repository using pull and push fails returning the following message:

...
! [remote rejected] master -> master (unpacker error)
remote: error: inflate: data stream error (unknown compression method)
remote: error: unable to unpack a798a0e5cdf6ab498ea641c3d8d7b5763dc901d0 header
remote: fatal: loose object a798a0e5cdf6ab498ea641c3d8d7b5763dc901d0 (stored in //10.0.0.7/j/git/code/objects/a7/98a0e5cdf6ab498ea641c3d8d7b5763dc901d0) is corrupt
error: remote unpack failed: unpack-objects abnormal exit


$git checkout -f HEAD
error: unable to read sha1 file of css_grid.diff (a798a0e5cdf6ab498ea641c3d8d7b5763dc901d0)
error: inflate: data stream error (invalid distance too far back)
error: corrupt loose object '8711ded8021f5a4f59db8899e25c30655e80e803'
fatal: loose object 8711ded8021f5a4f59db8899e25c30655e80e803 (stored in .git/objects/87/11ded8021f5a4f59db8899e25c30655e80e803) is corrupt

Another attempt to clone the repository also fails, returning:

git clone \\10.0.0.7\j\git\code
Cloning into 'code'...
done.
error: unable to read sha1 file of css_grid.diff (a798a0e5cdf6ab498ea641c3d8d7b5763dc901d0)
error: inflate: data stream error (invalid distance too far back)
error: corrupt loose object '8711ded8021f5a4f59db8899e25c30655e80e803'
fatal: loose object 8711ded8021f5a4f59db8899e25c30655e80e803 (stored in L:/transp/1___downloads/code/.git/objects/87/11ded8021f5a4f59db8899e25c30655e80e803) is corrupt
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'


>SOLUTION

The attempt to clone was used to make sure that the corruption happened on remote repository.
After some research, the best documentation to fix this was "Recovering from repository corruption" but also comments that against corruption the best alternative is a backup.
Although having backups, it didn't help in this case because the backups also had exactly the same issue since a backup is a copy. Because it is not an incremental copy, the backup was useless.

SAVING THE PAST


Faster than trying to fix it for the sake of time saving, the corrupted remote repository was renamed from "code" to "code_corrupted_200220" and saved its copy.

ren code code_corrupted_200220
or
mv code code_corrupted_200220 (linux)

This backup may be used to get some previous commit, or even an attempt to fix it if really necessary just because it is required an old version of a file. Since "clone" command was able to clone to local repository although the warning, this corrupted remote repository is still useful to recover old stuff.

GOING AHEAD WITH THE FUTURE

It was created a new remote repository:
mkdir clone
cd clone
git init --bare

A new remote repository with a new log  history.
The old one is preserved in the backup mentioned above, just in case.

Next step is to push the local repositories.
The procedure was usual except that it is required to set upstream, resembling the procedure when a remote repository is switched (git remote remove origin, git remote add origin new_path).

git add *
git commit -am "MACHINE_NAME: corrupted remote repository switching"
git pull origin master
git push --set-upstream origin master

The same procedure was repeated to all local clients.

One day, if fixing the corruption is worthy, we may try the "Recovering from repository corruption" instructions, but till there, maybe Git will bring redundancy option to duplicate the tree.
In such cases it would be useful to have two files in different positions on the disk, in order to recover the information from a particular damaged disk position. This should be really an option because it would double the resources' requirement, but sometimes it is a desirable option if hardware has the power to supply this redundancy without being noticeable and disk space is not a restriction.

The full disk was checked successfully. No errors found, except this occurrence.

Murphy's day.  :-)


>ENV


Windows 10
git v.2.30.1.windows.1


Monday, February 15, 2021

How to use VS Code with Multiple Configurations with Backup


>PROBLEM


You need to work with different environments and workspaces for different purposes when working with different programming languages or different contexts.

For each context or environment, you've installed the desired extensions.

Also, it is interesting to keep a backup of the environment to save time.


What does happen next?

If you have just one configuration setup and many needs, the VS Code configuration begins growing, eventually getting heavy, slow, and taking too much memory.

Also, the extensions' default shortcuts begin to conflict with each other.


>SOLUTION

There are at least three approaches:

1. Versioning control using branches, or

2. Separate configuration folders, or

3. Option 1 plus option 2.


Versioning control using branches

The VS Code default folder that holds its configuration setup is under

      "C:\Users\YOUR_LOGIN\.vscode" folder.

Create a git repository there.

For each kind of environment desired, create a specific branch.

The master branch would aggregate everything, but in this case, there is no use unless you do want to keep a backup of just one setup.



Separate configuration folders

It is possible to switch environments using commands.
To do this, it is necessary to create a symbolic link to the current default extensions folder used by VS Code by default.

The default folder is at:

%USERPROFILE%\.vscode\extensions

Before creating the symbolic link, move the default extension folder to the new place desired, then create it:

mklink /D %USERPROFILE%\.vscode\extensions "NEW_PATH_DESIRED\extensions"

Ex.:
mklink /D C:\Users\YOUR_USER\.vscode\extensions "D:\ide_home\vscode\Code\extensions"



Option 1 plus option 2

You may combine the two options above, but better if the branches keep a keyword to avoid losing control.

The best of all is that you never lose your env, never need to reconfigure, and may switch fast the environments preserving then VS Code app from getting messed and slow.



ATTEMPT FAILURE NOTE


The attempt using "--user-data-dir" and/or  "--extensions-folder" flags (options) was not successful by the time I've tried using VS Code  v.1.53.2.





Wednesday, February 3, 2021

Blue Screen with one of the following messages: windows system error STATUS_WAIT_2 0x80070002 or windows system error STATUS_WAIT_3 0x80070003

>PROBLEM


When rebooting the machine, returned blue screen with the following message:

  windows system error STATUS_WAIT_3 0x80070003


Another attempt, returned another message:

  windows system error STATUS_WAIT_2 0x80070002

  

>SCENARIO



The machine was very, very slow, and once in a while appeared "bad clusters". This situation took several weeks. During all this time, the checklist below passed:



HD fragmentation: OK

HD S.M.A.R.T. status and test: OK

Scandisk: no errors, OK

Antivirus: disabled during the tests.

Unexpected processes consuming CPU's resources: none

Internet connection: disabled

All programs closed, just the usual services were turned on.

Hardware temperature: OK

Windows Registry: OK



Suddenly, when a reboot is done, the blue screen with the messages.


All attempts possible were performed — all "Windows Recovery" options failed, returning messages like "not possible", "done but failed", and things like that. Fixing reboot, cloning a new reboot partition from a backup HD, attempt to restore an image or restore the system from a "restore point" and etc. had failed.




>SOLUTION


The HD was removed from the slot and inserted back twice.


An intermittent bad contact caused maybe by slight oxidation, dust, vibration, etc. was causing the unexpected "bad blocks".

In this scenario, the Windows system made an automatic update that was not able to get to the end.

Considering the two problems together plus interrupted update procedure, the mess was complete.


The solution came, after solving the contact issue, let Windows finishes the update. Long and twice, but the issue was solved but the system was inconsistent, missing several DLLs, requiring more one more solution.


This time at least was possible to restore to a previous point before the unlucky Windows update and perform again that required update.



When rare events happen to get together at the same time, just Murphy explains!  :-)


Eventually, the system was up and running again!

Well done Windows!!! Wow!!!


>ENV

Windows 10

Saturday, January 23, 2021

Git: Updates were rejected because a pushed branch tip is behind its remote counterpart

 

>PROBLEM


Git push fails returning "Updates were rejected because a pushed branch tip is behind its remote counterpart...".


 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to .. SOME DIR PATH

hint: Updates were rejected because a pushed branch tip is behind its remote

hint: counterpart. Check out this branch and integrate the remote changes

hint: (e.g. 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.



>SOLUTION


Following the hint suggested in the output:

  git push --help


The --force option solves:

  git push --force origin master

  

Because it was behind the counterpart, it may cause some side effect on log.

When performed the command, everything was fine, no issues, but another client had to push with --force flag too, but no further issues.



>ENV

Windows 10

Git version 2.19.1.windows.1


Tuesday, January 19, 2021

Slow Machine? Warn Up - Check this before it is too late


 >PROBLEM


Defragmentation is OK, there is no strange process taking the CPU for itself, no virus, but the desktop or notebook is very slow, much more than usual and, it seems that it get worse every month.

Also, you have noticed that the system requires HD fixes, leading to scans to fix block references, more frequently than usual.


>SOLUTION


"Your HD, in this case is very fond of you!"  :-)

It probably has been trying to warn you that it is supposed to end its life soon.

Time to make backup of all your stuff to an external HD or to make a revision of your data's backup routines to make sure everything is up to date.

Consider making a clone of your HD to be used when the current one is dead, or to replace it.

There are good apps for this, free or paid:

Free: HD Clone, Disk Genius
Paid: DriveClone, EaseUS Partition Master

TIP

If you have a big number of files, not qualitatively but quantitatively, not big files in size but numerous files, this condition stress the HD. That way, if the HD is old, having many hours of intense activities (working during the day and scheduled backups during the night), bad blocks are generated more frequently, leading to the required scans asked by the system.

If you have split your HD into two partitions, for instance, "C:" for Windows and "D:" for data, you get a better chance to solve this issue and gain more time until the HD replacement by moving your data on "D:" partition to another disk and deleting D:.
In this case, the HD will be less required and the issue may slow down, giving you an extra time before the HD substitution, something that may save you time, money and opportunity.

I've solved recently an issue like this just deleting the data partition. The HD got half work to do, so the situation became bearable. On the remaining free space, I cloned the "C:", getting to "C:" partitions on the same disk, but one of them disable at a time. If the HD's initial boot is preserved, when the active "C:" partition is gone, you may switch to the other just activating it. After you finish your work, you may clone the active "C:" partition to replace the defective one.
This saved me many hours during an urgent work that I couldn't stop for long maintenance and enabled me to deliver the task on time.

Always consider using different partitions for the system and the data, even if working with other S.O. different of Windows.





>ENV

Windows 10

Git rebase fails to continue

 

>PROBLEM


You perform "git rebase":
git pull --rebase

And returns:

First, rewinding head to replay your work on top of it...
Applying: room1 branch by room1
.git/rebase-apply/patch:23: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M       about.diff
Falling back to patching base and 3-way merge...
Auto-merging about.diff
CONFLICT (content): Merge conflict in about.diff
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 room1 branch by room1
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

Next, you solve the conflict.
Details here

After, you try to continue the rebase, but the git refuses still requiring merging.


>SOLUTION

If the conflict was already solved, you may use skip option, as shown in the message above returned by git:
git rebase --skip

If you've performed this operation over master branch, may have consequences as information loss.

Check details here.


>ENV

Windows 10

Monday, January 18, 2021

git: 'credential-cache' is not a git command. See 'git --help'.

 

>PROBLEM


git: 'credential-cache' is not a git command. See 'git --help'.


>SOLUTION


Edit .git\config fille and remove:


[credential]

helper = cache







>ENV

Windows 10


Tuesday, December 15, 2020

MariaDB: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


>PROBLEM


This procedure resets the MariaDB root password when it is not possible to access the database returning:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)





 

>SOLUTION


- Stop database:
sudo systemctl stop mariadb


- Test:
sudo systemctl status mariadb

You shall get;
Status: "MariaDB server is down"
To return to console, use Ctrl+C


- This command shall return empty:
sudo pgrep mysqld


- Starting the database using safe mode:
sudo mysqld_safe --skip-grant-tables --skip-networking &
or
sudo mysqld_safe --skip-grant-tables &

"Enter" to return to prompt.


USING A TEMPORARY PASSWORD

- Entering the database prompt without user or password:

mysql -u root

use mysql;
flush privileges;
update user SET PASSWORD=PASSWORD('secret') WHERE USER='root';
GRANT ALL PRIVILEGES ON root.* TO 'root'@'localhost' WITH GRANT OPTION;
flush privileges;
quit


- kill all mysqld processes
sudo pgrep mysqld


- Kill by the PID numbers returned, for example:
sudo kill -9 1234
sudo kill -9 4567

- Start the database:
sudo systemctl start mariadb



WHEN THE DATABASE FAILS TO START
 
During the start, if it hangs, it is necessary to kill all processes. 
It happens when some process is left behind, not being killed.
Unfortunately, sometimes when killing the processes doesn't work because another new process starts just after, I just got solution rebooting the machine even though using killall, etc.
 

- To check:
sudo systemctl status mariadb




TESTING AND SWITCHING TO DEFINITIVE PASSWORD

 

- Access the database again to test the "secret" temporary password and also to change to the definitive password:

mysql -u root -p
pass: secret

use mysql;
flush privileges;
UPDATE mysql.user SET authentication_string = PASSWORD('MY_DEFINITIVE_PASSWORD') WHERE User = 'root' AND Host = 'localhost';
GRANT ALL PRIVILEGES ON root.* TO 'root'@'localhost' WITH GRANT OPTION;
GRANT RELOAD ON *.* TO 'root'@'localhost';
flush privileges;
quit

 

- Access the database again to test the definitive password:
mysql -u root -p
pass: MY_DEFINITIVE_PASSWORD


***NOTE:

If after switching to the definitive password, the problem comes back denying access, it is because the characters used in the password caused the issue.
Avoid password like this:
Abc1234#-_ (the -_ didn't work during my attempts)
For sure, use a password with just numbers and letters.
To get confidence, repeat the procedure.
If you desire to use special chars, you may try after making sure that you got success at least once, that way you may discover which special char to avoid in your password.

 

>ENV

debian 10/9
10.x , 10.3.27-MariaDB



DIFFERENT BEHAVIORS DUE TO ENVIRONMENT DIFFERENCES

This procedure was executed several times successfully, but you may get some issue with some command shown above.
Below, there are some alternatives, not all of them of course, that you may try if some command fails.

set password for 'root'@'localhost' = password('secret');
- or
ALTER USER 'root'@'localhost' IDENTIFIED BY 'secret';

 

ADDITIONAL SOURCES

www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password

robbinespu.github.io/eng/2018/03/29/Reset_mariadb_root_password.html

 

ALTERNATIVE SITE

alsdias.blogspot.com/2020/12/mariadb-error-1045-28000-access-denied.html

 

@SYSREF:

y;reset root password<memo<mariadb;. 

 

Monday, December 14, 2020

Wi-Fi modem/router fails to connect via wi-fi or RJ-45

 

>PROBLEM


The "ZTE MF253L LTE Wireless" Wi-Fi modem/router sometimes fails to accept Wi-Fi connections and comes with issues when using RJ-45.

A very odd defect that occurred after some years of usage.


>SOLUTION


Sometimes it is interesting to improve a modem/router that it is not that good than buying a new one.

ZTE MF253L has not a wide signal range but works well.

Instead of buying another modem/router, I decided to use a tp-link Wireless N 450Mbps router, model TL-WR940N, connected to the ZTE's internet output, using the RJ-45 cable.

The TL-WR940N model has a good signal range.

Now, I connect the notebooks direct to the tp-link router, instead of to the ZTE's, solving the connection issues. No more problems, at all.

Sometimes, when the ZTE's direct connection is not failing, it is possible to use it without the tp-link, but it is not an advantage at all, but remains as an alternative in case of a casual tp-link failure. 

When the provider's connection fails, the Window's wi-fi connections keeps the tp-link router active waiting and as soon as the connection is on again and nothing is changed on the notebooks connected to the tp-link.

This saves time when the failures are short.

If not, you may connect to the tp-link another modem/router using another number, a second option when you have it, without changing clients' configurations. If you have many machines, it helps a lot.

For some reason, sometimes Windows fails to reconnect the Wi-Fi, forcing to do a reboot.
This workaround also avoids this reboot.







Thursday, November 26, 2020

Git: ! [remote rejected] master -> master (unable to migrate objects to permanent storage) error: failed to push some refs to 'ssh://REPOSITORY_PATH_HERE'

>PROBLEM

Attempt to push to git repository fails, returning the following message:

git push

Returns:

 ! [remote rejected] master -> master (unable to migrate objects to permanent storage)

error: failed to push some refs to 'ssh://REPOSITORY_PATH_HERE'


>SOLUTION

Check permissions on the remote server's repository.
For instance, supposing:

/home/git/myProject


Test, using the following command:

chmod -R 777 /home/git/myProject


Then, go to the client and try to push again.
If the issue is gone, set the proper permissions of remote server's repository

>ENV

Linux (remote git repository)
Windows (client)

Sunday, September 27, 2020

Online Tool to Convert Text to HTML with Pre-defined Tags And Selectors

>PROBLEM


You want to copy a code snippet and paste into an HTML page that has its own CSS selectors.

For example, you are working on Eclipse, VSCode, Atom, Sublime, etc. and you wish to copy and paste the snippet below to your post in HTML.

server {
	server_name marketing.example.com marketing.example.org marketing.
	example.net;
	rewrite ^ http://www.example.com/marketing/application.do permanent;
}
server {
	server_name communication.example.com communication.example.org
	communication.example.net;
	rewrite ^ http://www.example.com/comms/index.cgi permanent;
}
server {
	server_name www.example.org www.example.net;
	rewrite ^ http://www.example.com$request_uri permanent;
}


>SOLUTION


You need a Text to HTML converter that enables to use your CSS selector.

You may try ultering.com/it4us/converter, a free online tool, that offers fast shortcuts. For instance, paste the text in the box and try CTRL+.







Saturday, September 26, 2020

nginx install: debian: Job for nginx.service failed because the control process exited with error code

 

>PROBLEM

Installing nginx:

apt install nginx

Returns:

  

Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-09-26 22:49:18 UTC; 7ms ago
     Docs: man:nginx(8)
  Process: 21405 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 21404 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Sep 26 22:49:17 mind4y.com nginx[21405]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Sep 26 22:49:17 mind4y.com nginx[21405]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Sep 26 22:49:17 mind4y.com nginx[21405]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Sep 26 22:49:18 mind4y.com nginx[21405]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Sep 26 22:49:18 mind4y.com nginx[21405]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Sep 26 22:49:18 mind4y.com nginx[21405]: nginx: [emerg] still could not bind()
Sep 26 22:49:18 mind4y.com systemd[1]: nginx.service: Control process exited, code=exited status=1
Sep 26 22:49:18 mind4y.com systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Sep 26 22:49:18 mind4y.com systemd[1]: nginx.service: Unit entered failed state.
Sep 26 22:49:18 mind4y.com systemd[1]: nginx.service: Failed with result 'exit-code'.
dpkg: error processing package nginx-full (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
 nginx depends on nginx-full (<< 1.10.3-1+deb9u4.1~) | nginx-light (<< 1.10.3-1+deb9u4.1~) | nginx-extras (<< 1.10.3-1+deb9u4.1~); however:
  Package nginx-full is not configured yet.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.
 nginx depends on nginx-full (>= 1.10.3-1+deb9u4) | nginx-light (>= 1.10.3-1+deb9u4) | nginx-extras (>= 1.10.3-1+deb9u4); however:
  Package nginx-full is not configured yet.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 nginx-full
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)


>SOLUTION


The issue is caused by port collision. In this case Apache is already using port 80.

The tip is given by the log at line:
nginx[21405]: nginx: [emerg] listen() to 0.0.0.0:80

Switch Nginx or Apache to another port.
In this case, Nginx is switched to port 81.

1. Edit:

/etc/nginx/sites-enabled/default


Switch from:

server {
listen 80 default_server;
listen [::]:80 default_server;

To:

server {
listen 81 default_server;
listen [::]:81 default_server;

 

2. Start nginx

systemctl start nginx


3. Test:

nginx -t


>EXTRA


If desired to reinstall Nginx, uninstall first:

apt update
apt purge nginx
apt autoremove

- verifying dependencies:
apt -f install


>ENV


debian 9


Sunday, September 6, 2020

Clients fail to Connect Debian on VMWare Virtual Machine


>PROBLEM

VMWare has ping to host but host has not ping to the VMWare running Debian.


>SOLUTION

There are three things to observe.


First, you must make sure that the VMWare network interface configuration is correct.
Summarizing: it is required two interfaces at least.
One for the Internet that it is mapped to NAT, and a second to access a local network, for instance, that shall be mapped to the local interface on your host. If Windows, you may access the network interfaces using the command: ncpa.cpl.

Map in the network interfaces using the same order.
For instance, if the guest is a Debian and has eth0 (Internet) and eth1(local), map the network adapters in VMWare's settings using the same order. 








Second, check the network icon to make sure it active and not "unmanaged".



If it is deactivated (unmanaged), do:

sudo vim /etc/NetworkManager/NetworkManager.conf

Set false to true:



Update, restarting service:

service network-manager restart


More detailed information, you get in this video.


Third, restart the virtual machine without using Ctrl+E. Use its shutdown button.
Try to ping your VM:
ping 10.0.0.XX

If it fails, restart Windows. 


IMPORTANT NOTE

Remember two extra concerns:

- Firewall configuration (host and guest/VM)

- VPN 
Sometimes the VPN impedes the access.
Test disconnecting the VPN.


>ENV

Windows 10
VMWare 8 running Debian 7 or 10
VMWare 15.5 running Debian 7 or 10





Thursday, August 13, 2020

When you type a command and opens Windows Store or another

 

>PROBLEM

For instance, on console, you type python and opens instead Windows Store panel or another program.


>SOLUTION

- Go to:

C:\Users\your_user_login_here\AppData\Local\Microsoft\WindowsApps


- Possibly, there is an equivalent command shadowing the one you really wish.

Delete it or rename it.
That's it.



Saturday, July 11, 2020

Angular: fallbackLoader option has been deprecated


>PROBLEM

ng serve
...
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
...
webpack: Compiled successfully.


>SOLUTION

If using angular-cli, do:

npm uninstall -g angular-cli
npm install -g @angular/cli

If desired to perform just local changes, take out the "-g" option.

Sometimes, when a project is recently created using deprecated packages, it is faster to recreate the project using the new env, up to date.


>env
node.js
angular

Sunday, June 7, 2020

GPG error: ... The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8C718D3B5072E1F5


>PROBLEM

When you run the command:

apt-get update

Returns the following message:

Get:1 http://repo.mysql.com/apt/debian stretch InRelease [21.6 kB]
Ign:1 http://repo.mysql.com/apt/debian stretch InRelease
Fetched 21.6 kB in 0s (87.0 kB/s)
Reading package lists... Done
W: GPG error: http://repo.mysql.com/apt/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8C718D3B5072E1F5
W: The repository 'http://repo.mysql.com/apt/debian stretch InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.



>SOLUTION


ATTEMPT #1 - UPDATING

apt-key adv --keyserver keyring.debian.org --recv-keys 8C718D3B5072E1F5

Check:
apt-get update

If the issue is not solved, try next alternative.



ATTEMPT #2 - DELETING VIA COMMAND

apt-key del 8C718D3B5072E1F5

Check:
apt-get update

If the issue is not solved, try next alternative.



ATTEMPT #3 - DELETING APT SOURCE FILES

Prerequisite:  supposing that the application is not installed and last removal left garbage behind.

Remove the apt's source files.

>Example:

Get a list of apt's sources:
ls /etc/apt/sources.list.d/*

Returns:
/etc/apt/sources.list.d/mysql.list  /etc/apt/sources.list.d/mysql.list.save

Create a temporary file to enable rollback if the procedure fails and causes malfunction:
mkdir /home/todel

Remove the respective sources causing the issue from apt's folder:

mv /etc/apt/sources.list.d/mysql.list /etc/apt/sources.list.d/mysql.list.save /home/todel


>ENV

debian 9

Saturday, May 16, 2020

JPA entity removal fails silently


>PROBLEM


The JPA remove command was silently ignored.
There was no delete statement on server's output even though the show_sql was enabled:
 
<property name="hibernate.show_sql" value="true"></property>
 
 
The issue was around an OneToMany relation where:
todo 1 --- * todoitem
 

Attempt to delete an instance on any side fails silently, without having the respective "delete" command on the server's output and no exception message of any type.

 

>SOLUTION

 
First, I switched the many side's code suggested by the Wildfly18/JBoss documentation in its examples from:
 
//    @Override
//    public void delete(Todoitem todoitem) {
//        if (todoitem == null) {
//            return;
//        }
//        if (!emPg.contains(todoitem)) {
//            todoitem = emPg.merge(todoitem);
//        }
//        emPg.remove(todoitem);
//        emPg.flush();
//        emPg.clear();
//    }
    

To an equivalent form:
 
    @Override
    public void delete(Todoitem todoitem) {
        if (todoitem == null) {
            return;
        }
        Todoitem ti = emPg.find(Todoitem.class, todoitem.getId());
        if(ti == null) {
            return;
        }
        emPg.remove(ti);
        emPg.flush();
        emPg.clear();
    }
 

Unfortunately, I got the same result - removal silently ignored.
 

Then, I suspected of the database, since hibernate handles its own keys. I had done many tests during implementation...
To be sure about the consistency issues, I've decided to empty the database deleting the content of both sides of the relation.
Then I created new entity instances and relations using the application's resources (no SQL command) since everything was working well except for entity removal.
After, I checked the database relations using SQL command to make sure everything was fine, and it was.
 
Next, I tried a new test again but this time it was successful.

Then I reverted the code, uncommenting the commented code and vice-versa and tested again.
The test failed again, returning same result — silently ignoring remove.

I set back the code to the previous condition testing again to confirm results.
The confirmations was successful, confirming suspicion of two issues, database and code implementation.
 
Since good news, I repeated the same to the "One" side (code below - the commented code is the initial one inherited from Wildfly 18 documentation, as above mentioned). 
 
From:
//    @Override
//    public void delete(Todo todo) {
//        if(todo == null) {
//            return;
//        }
//        if (!emPg.contains(todo)) {
//            todo = emPg.merge(todo);
//        }
//        //todoitemDao.deleteAll(todo);
//        emPg.remove(todo);
//        emPg.flush();
//    }
 
 
To:
    
    @Override
    public void delete(Todo todo) {
        if (todo == null) {
            return;
        }
        Todo t = emPg.find(Todo.class, todo.getId());
        if(t == null) {
            return;
        }
        emPg.remove(t);
        emPg.flush();
        emPg.clear();
    }
 

 
Issue solved. Success.
 

IMPORTANT NOTE:
 
Check the removal tests by using the SQL statements straight on the database.
Sometimes the instance seems not being removed due to cache issue or code implementation fault, requiring to be treated apart.


>ENV


- JSF
- Wildfly 18 (JPA default implementation - Hibernate)
- PostgreSQL 10


>NOTE

Published also on Stackoverflow

Wednesday, May 6, 2020

WILDFLY/JBOSS: WFLYJPA0061: Persistence unitName was not specified and multiple persistence unit definitions


  

>PROBLEM

Creating a persistence.xml file having two persistence units caused the following Wildfly's error message:

Caused by: java.lang.IllegalArgumentException: WFLYJPA0061: Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment "todos.war". Either change the application deployment to have only one persistence unit definition or specify the unitName for each reference to a persistence unit.

The persistence.xml configuration used was:


<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
   xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
        
    <persistence-unit name="primary">
       <jta-data-source>java:jboss/datasources/TasksJsfQuickstartDS</jta-data-source>
       <properties>
          <!-- Properties for Hibernate -->
          <property name="hibernate.hbm2ddl.auto" value="create-drop" />
          <property name="hibernate.show_sql" value="false" />
       </properties>
    </persistence-unit>

    <persistence-unit name="pgTestoneDS">
       <jta-data-source>java:jboss/datasources/pgTestoneDS</jta-data-source>
       <properties>
<!--           <property name="hibernate.hbm2ddl.auto" value="create-drop" /> -->
<!--           <property name="hibernate.show_sql" value="false" /> -->
       </properties>
    </persistence-unit>

</persistence>

 

>SOLUTION

After some failures, I've decided to repeat the same configuration but doing the things in a different order.
The following order was successful:

1. Refactor the code that concerns the primary persistent-unit (or the the initial persistent-unit, whatever the name it has).

2. Create a qualifier to this first perstent-unit.

3. Refactor the dao layer in order to apply the its qualifier where the entity maneger is injected.

4. Recompile the project and perfome a full deploy.

5. Start the server and test.

6. Stop the server

7. If not successful, fix the code revising from step 1.

8. if successful, add the second persistent-unit to persistence.xml file.

9. Create the  database manager class, its qualifier, the entities and dao layer always using the respective qualifier for the second persistent-unit to differ from the initial code implemented for the first persistent-unit.

10. Recompile the project and perfome a full deploy.

11. Start the server and test.





Source code available at the link below.


>WHAT NOT TO DO

This site is dedicated to provide straight problem/solution approach, but sometimes it is valuable to lean from the mistakes but this kind of approach doesn't fit here.
To get more details and source code, point to WILDFLY/JBOSS: WFLYJPA0061: Persistence unitName was not specified and double persistence unit definitions



>ENV

Windows 10
Wildfly 18
JEE/CDI/JPA

 

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...