>PROBLEM
node.js: express: req.session returns "undefined".
console.log(req.session)
- Returns:
undefined
>SOLUTION
The session block declaration shall come before the routing blocks.
node.js: express: req.session returns "undefined".
console.log(req.session)
- Returns:
undefined
The session block declaration shall come before the routing blocks.
Scenario by example:
On a linux(debian, ubuntu, etc) system you want to discover the postgresql service, its version and how to stop/start.
1. whereis
2. locate
3. ps aux
Ex.: ps aux | grep postgres
/usr/lib/postgresql/13/bin/postgres -D /var/lib/postgresql/13/main -c config_file=/etc/postgresql/13/main/postgresql.conf
4. systemctl
returns all registerd services
systemctl stop ssh
systemctl disable ssh
systemctl enable ssh
systemctl start ssh
systemctl status ssh
service postgresql status
service postgresql start
service postgresql stop
linux/debian
On Windows, after running a git command, it is thrown the following warning:
hint: core.useBuiltinFSMonitor will be deprecated soon; use core.fsmonitor instead
hint: Disable this message with "git config advice.useCoreFSMonitorConfig false"
core.fsmonitor
If set to true, enable the built-in file system monitor daemon for this working directory (git-fsmonitor--daemon[1]).
Like hook-based file system monitors, the built-in file system monitor can speed up Git commands that need to refresh the Git index
(e.g. git status) in a working directory with many files.
The built-in monitor eliminates the need to install and maintain an external third-party tool.
- Documentation:
https://git-scm.com/docs/git-config#Documentation/git-config.txt-corefsmonitor
Run the desired option:
git config core.fsmonitor true
or
git config core.fsmonitor false
*** IMPORTANT NOTE:
Run the command on the git's root folder.
Make sure that the git folder is not another git subdirectory of a root git folder.
Example:
+-- project
.git
myStuff
+-- project2
.git
myStuff2
git version 2.36.0.windows.1
Windows 10
Attempt to run an Eclipse project returns the following error:
Error: Could not find or load main class antlr.debug.misc.ASTFrame
Caused by: java.lang.ClassNotFoundException: antlr.debug.misc.ASTFrame
0. Pre-requisite: make sure your pom.xml configuration is correct.
1. On Eclipse, using the Project Explorer (or Navigator), delete the following configuration files:
.settings
.classpath
2. Eclipse will complaing throwing an error pop-up. Ignore closing it.
3. Using the Project Explorer (or Navigator), point to the project's root and save it again.
This will generate again the deleted files.
4. Check if there are errors and fix them.
maven
eclipse
java17
The pom.xml shows the following error message:
Execution default-testResources of goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:testResources failed: Unable to load the mojo 'testResources'
(or one of its required components) from the plugin 'org.apache.maven.plugins:maven-resources-plugin:3.2.0'
(org.apache.maven.plugins:maven-resources-plugin:3.2.0:testResources:default-testResources:process-test-resources)
If the pom.xml was previously working fine, just update the maven project.
If using Eclipse, do:
Point to the project root on "Project Explorer" or equivalent, choose on the context menu mave, Updata Project (or ALT+F5)
spring
java
Running the executable jar with dependencies generated by maven plugin fails throwing the error message:
java -jar myApp-0.0.1-SNAPSHOT-jar-with-dependencies.jar
- Returns:
..Caused by: java.lang.ClassNotFoundException..
1. Check the main class path in the pom.xml file.
Note: there are alternative plugins to generate executable jars.
See more at:
How to Create an Executable JAR with Maven
Below is shown one of the options:
Starting a project using Maven, JEE/Spring, and MongoDB driver (mongo-java-driver) throws the following exception:
...[cluster-ClusterId{value='62586e27f362ec2cd1336bda', description='null'}-localhost:27027] # INFO # org.mongodb.driver.cluster # method: info # Exception in monitor thread while connecting to server localhost:27027
com.mongodb.MongoSocketOpenException: Exception opening socket
...
Caused by: java.net.ConnectException: Connection refused: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method)
Although connection refusal may have many causes, this post will treat one of them that maybe it is your issue.
The "mongo-java-driver" tries to start MongoDB connection automatically as soon as the application starts if it finds MongoDB's configuration in .properties or .yml files.
It happens when we start a project using this default feature but later we decide to customize it, and there is no need for this feature anymore.
So, just remove or comment on the lines in the configuration file.
For instance, if .yml, do this:
spring:
profiles: prod
jpa:
database: default
# data:
# mongodb:
# host: localhost
# port: 27027
# database: mydatabase
If .properties:
#spring.data.mongodb.host=localhost
#spring.data.mongodb.port=27017
#spring.data.mongodb.database=mydatabase
SpriingBoot 2.X
Java 17
MongoDB 5
- pom.xml:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.10</version>
</dependency>
>PROBLEM
web service returns with 404
If you have already checked the protocol, then check if the @ResponseBody annotation is missing.
- BEFORE:
@PostMapping(value = {"/reset/{token}"})
public ResponseDTO resetPassword(HttpServletRequest request, @PathVariable String token) {
ResponseDTO dto = request(request, token);
dto.setData("hello there!");
return dto;
}
- AFTER:
@PostMapping(value = {"/reset/{token}"})
@ResponseBody
public ResponseDTO resetPassword(HttpServletRequest request, @PathVariable String token) {
ResponseDTO dto = request(request, token);
dto.setData("hello there!");
return dto;
}
spring boot 2
java 17
Eclipse returns the following error after altering data on preferences (menu, Windows, Preferences):
Store preferences has encountered a problem. An internal error occurred during "Store Preferences". The system was not able to find the filepath
Using Eclipse's sonarlint , a rule was removed and it is wished to be restored.
Hibernate fails when the application starts throwing the following messages:
Caused by: org.postgresql.util.PSQLException: ERROR: must be owner of table server 2022-02-16 22:18:43 # [restartedMain] # WARN # o.h.t.s.i.ExceptionHandlerLoggedImpl # method: handleException # GenerationTarget encountered exception accepting command :
Error executing DDL "alter table public.provider
add column provider_details_pk int8" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
alter table public.provider
add column provider_details_pk int8" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
alter table public.server
add column provider_pk int8" via JDBC Statement
The tables were create via terminal using postgres' admin account that it is now allowed to remote access due to security issues.
Drop the tables that have the owner access issue using the terminal and the admin's account, the same used to create them.
Recreate the tables using another account that has remote access priviledges.
Debian 10
PostgreSQL 10
Windows 10
1. Open Git Bash console.
2. Perform the command below to enable read and write;
chmod 776 your local path here/known_hosts
3. Keep the git bash console opened, test running a git command again.
For instance:
git ls-remote
The problem is gone as the figure shows where it points to "solved".
[REF]: faq-Failed to add the host to the list of known hosts
- 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.
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
Attempt to run a mvn command, for instance:
mvn -version
Returns:
<!--Could not find or load main class ...
Caused by: java.lang.ClassNotFoundException: ...-->
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
Windows 10
apache-maven
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
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.
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;.
Attempt to access an Angular project running from a docker fails, returning on the browser "ERR_EMPTY_RESPONSE".
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
windows 10
angular 16
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;.
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.
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
w10
docker
VMware Workstation and Device/Credential Guard are not compatible
If using VMWare v.15, upgrade it to v15.5
w10
vmware15
You need to access the issues from closed sprints.
You have a Angular project using SaSS.
Starting the server, returns the following message:
SassError: Expected newline
Correct the .sass files converting to Sass syntax.
- syntax:
https://sass-lang.com/documentation/syntax
- Example:
Following the instructions in Vue's documentation after issuing the command:
npm run service
returns the following:
Local: "http://[C:]:3000/"
Naturally, this address fails.
Windows 10
Tested with Vue 2 and 3
>PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...