Saturday, November 25, 2017

MySQL server fails to start

>PROBLEM

After server reboot MySQL fails to start.
For instance:
  /etc/init.d/mysql restart
or
  service mysql stop
  service mysql start
 
Returns "failed" message.


>SOLUTION

1. Create data backup:
  cp -R /var/lib/mysql /var/lib/mysql_171115

2. Run the following cmds:
  chown -R mysql:mysql /var/lib/mysql
  mysql_install_db --user=mysql -ldata=/var/lib/mysql/

The last cmd output may show you the reason.
- Example:
  root@setgetsrv:/home/alsdias/dev/scripts# mysql_install_db --user=mysql -ldata=/var/lib/mysql/
  Installing MySQL system tables...
  171125 12:02:54 [Warning] The syntax '--log' is deprecated and will be removed in a future release. Please use '--general-log'/'--general-log-file' instead.
  171125 12:02:54 [Warning] The syntax '--log' is deprecated and will be removed in a future release. Please use '--general-log'/'--general-log-file' instead.
  171125 12:02:54 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
  171125 12:02:54 [Note] /usr/sbin/mysqld (mysqld 5.5.55-0+deb7u1-log) starting as process 12458 ...
  171125 12:02:54 [ERROR] /usr/sbin/mysqld: unknown variable 'log_slow_verbosity=query_plan'
  171125 12:02:54 [ERROR] Aborting

3. Solving.
- The output shows issue with:
log_slow_verbosity = query_plan
- then, comment the line:
#log_slow_verbosity = query_plan

>ENV
debian whezzy
MySQL 5.X

Friday, October 13, 2017

Spring Boot: the client fails to find the service returning 404.


>PROBLEM

The application starts successfully, but the client fails to access the service getting 404.

Controller's original code:
@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {

    @Autowired
    IHelloRepository helloRepository;

    @GetMapping("/hellos")
    public List getAllHellos() {
        Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
        return helloRepository.findAll(sortByCreatedAtDesc);
    }



>SOLUTION

***WRONG:     @GetMapping("/hellos")
***RIGHT:        @GetMapping("/hellos/")

@RestController
@RequestMapping("/api")
@CrossOrigin("*")
public class HelloController {

    @Autowired
    IHelloRepository helloRepository;

    @GetMapping("/hellos/")
    public List getAllHellos() {
        Sort sortByCreatedAtDesc = new Sort(Sort.Direction.DESC, "createdAt");
        return helloRepository.findAll(sortByCreatedAtDesc);
    }


>ENV

Java 1.8
SpringBoot 1.5.6

Sunday, October 1, 2017

node.js: Error: Cannot find module .. bin/www


>PROBLEM

When the server is started using:
  npm start app.js
it returns the following error message:

  Error: Cannot find module 'L:\work\devcli_\javascript\node\work\ndprj01\ndprj01\bin\www'
      at Function.Module._resolveFilename (module.js:489:15)
      at Function.Module._load (module.js:439:25)
      at Function.Module.runMain (module.js:609:10)
      at startup (bootstrap_node.js:158:16)
      at bootstrap_node.js:598:3
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! ndprj01@0.0.0 start: `node ./bin/www "app500c6sql"`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the ndprj01@0.0.0 start script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


>SOLUTION

Edit "package.json" file.
The error tell at:
  Error: Cannot find module 'L:\work\devcli_\javascript\node\work\ndprj01\ndprj01\bin\www'
that it is a problem concerning "bin\www".
Find "bin\www" and take it out.

- Before:

{
  "name": "ndprj01",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "async": "^2.5.0",
    "bluebird": "^3.5.0",

- After:
{
  "name": "ndprj01",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node "
  },
  "dependencies": {
    "async": "^2.5.0",
    "bluebird": "^3.5.0",






>ENV
windows
node.js

Saturday, September 30, 2017

node and npm: cleaning message "requires a peer of..."


>PROBLEM

Working with node, you perform some installation which not fulfill full installation.
Some unmet dependency keeps hanging a boring warning.
In this examples was:

npm WARN grunt-execute@0.2.2 requires a peer of grunt@~0.4.1 but none was installed.



>SOLUTION

Try to clean the unmet dependency manually.
Open the file package.json and remove the respective package.

In this case was "grunt-execute: 0.2.2".



After removal:



Results:




>ENV

Windows
node





Friday, August 25, 2017

node enoent: no such file or directory package.json



>PROBLEM

The package description is missing.
When it is not found, returns this message:
... ENOENT: no such file or directory ... package.json

npm WARN enoent ENOENT: no such file or directory, open '$HOMEDIR\package.json'


>SOLUTION

Use "npm init" create the package description.
This command asks some questions.
  npm init

To avoid interactive questions, use:
  npm init -y
  npm will assume some default values.

>>Example using the interactive mode with Git

1. Before executing the command, get your git's repository path, do:
  git remote -v

The output as example:
$git remote -v
origin  J:\git\dev\javascript (fetch)
origin  J:\git\dev\javascript (push)


2. Issue init.
The output was copied here as example:
$npm init

This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ˆC at any time to quit.
package name: (bin714)
version: (1.0.0)
description: lab project based on bin714
entry point: (app.js)
test command: appt
git repository: J:\git\dev\javascript
keywords: node,http,server,example,template
author: alsdias plus others
license: (ISC)
About to write to L:\work\devcli_\javascript\node\work\bin714\package.json:

{
  "name": "bin714",
  "version": "1.0.0",
  "description": "lab project based on bin714 ",
  "main": "app.js",
  "scripts": {
    "test": "appt"
  },
  "repository": {
    "type": "git",
    "url": "J:\\git\\dev\\javascript"
  },
  "keywords": [
    "node",
    "http",
    "server",
    "example",
    "template"
  ],
  "author": "alsdias plus others",
  "license": "ISC"
}


Is this ok? (yes)
yes

>ENV
windows
node.js

Friday, August 18, 2017

Using an existing x509 certificate and private key to generate Java keystore to deploy https apps using SSL/TLS


>PROBLEM
You have the certificates and key generated by a CA and need to generate a keystore file to run a java application.


>SOLUTION

This example uses the certificates generated by sslforfree.

1. create a sandbox subfolder to generate the keystore file under the CA's folder where the certificates are stored.
  mkdir certificates\ssforfree\mysandbox


2. copy the CA's key and the certificate to the sandbox.
  cd certificates\ssforfree
  cp mysite_certificate.crt mysandbox
  cp mysite_private.key mysandbox
  cd certificates\ssforfree\mysandbox
  
  openssl pkcs12 -export -out keystore.p12 -name "myAlias" -inkey mysite_private.key -in mysite_certificate.crt
password?: mypass (the same pass used to generate the CA's certificates and key)
  
  where name = alias, the spring boot keyAlias value, the openssl friendly name.


3. set the application property file under the spring boot project.

Example using application.yml:

server:
  port: 8443 #default HTTPS
  ssl:
    #enabled: true
    key-store: keystore.p12
    keyStoreType: PKCS12
    keyAlias: myAlias 
    key-store-password: MY_PASSWORD_USED_WHEN_GENERATED_THE_CERTIFICATES_AT_CA_SITE


4. compile the spring boot project.
  mvn clean install
  

5. copy the keystore.p12 generated at "step 2" to the spring boot project's target folder.
  cp certificates\ssforfree\mysandbox\keystore.p12 myproject\target


6. run the application.
  cd target
  java -jar myapp-1.0.war
  

Saturday, August 5, 2017

How to download a project subdirectory from GitHub



This page contains the procedures which really worked for me, collected during my researches.
The snippets are real code which may be used to check the procedure in your environment.


1. using SVN

1.1. For URLs containg tree/master

If the URL contains "tree/master"
  https://github.com/eugenp/tutorials/tree/master/spring-boot

then replace it for "trunk":
  https://github.com/eugenp/tutorials/trunk/spring-boot

1.1.1. To downlod without the ".svn" subdir, use:
  
  svn export https://github.com/eugenp/tutorials/trunk/spring-boot

Final result:



1.1.2. To downlod with the ".svn" subdir, use:
  
  svn checkout https://github.com/eugenp/tutorials/trunk/spring-boot

Final result:





2. Using chrome extension

Install "GitZip for github" extension.

Why Should I use Angular 2 , or not?








When writing code I usually think about the following issues, among others:

- Is it a sensitive code?

- Where should it be processed?

- Is it a "light code" not requiring resources intensively that could decrease considerably the service performance like  memory/throughput/CPU processing usages?
(the old and famous triad performance requirements)

JavaScript is gorgeous and its main "purpose" was born for client processing using a browser.
Asynchronous calling is widely used to reduce heavy roundtrips where the full page is processed by a server returning its full content, instead it is processed just the minimum stuff required.
Very clever! Very necessary!

We, developers, started programming widely using the client's power processing, asynchronous callings and callbacks, and such intense activity leads us to skip accidentally about some concerns like, for instance, security.

Considering that standard JavaScript model process its code on client, it is not recommended to expose sensitive code, but due to constant coding habits, sometimes some sensitive code leaks to layers where it shouldn't be.

Angular 2, or later versions like Angular 4, uses a client-server architecture, usually supported by Node.js.
That way, this practice may help you avoiding the issue commented above, but you still have to remember that a client-server communication has its security considerations.
You may get some additional comments about this pointing to this link.

On the other side, Angular 1 carries the standard way of JavaScript programming, which makes easier to leak information, while Angular 2 or later, using annotations, requires the server side necessarily on the purpose of its injection resources.

This advantage has a setback, since nothing is totally good or bad.
If working with another server, not Node.js, it will be required two servers.

Well, this additional requirement may be compensated by reducing traffic on the main server, since part of the callings will be attended by the other one processing Angular 2 code.

On the other side, sometimes it is desired simplicity, lower processing, like avoiding additional steps like transpilation, injection, etc. In such cases, Angular 1 may fit like a glove, since sensitive codes are not exposed into client-processed scripts.

So, it is just a question of what is more recommended for each case.
Remember, since there are no miracles, when something does an extra thing it also requires extra resources.

Eventually, a last concern still remaining.
Sometimes, you may have sensitive code but that it doesn't mean that you really need Angular 2.
If the respective feature (use case) that code belongs to has low usage frequency, it may be used the traditional approach (full roundtrip) to spare project time and server resources without major issues about performance and etc. There is still another possibility. You may use the traditional asynchronous call by Angular 1 to process the sensitive code on the server.
If the page rendered on the client is compatible with the target devices, like mobile's platforms, the solution becomes another possible alternative.

Project design is a matter of weighing pros and cons considering possible refactoring costs in the future and cross-platform issues.




Thursday, August 3, 2017

Spring Boot: HTTPS and HTTP with Redirection Configuration (SSL/TLS)





To enable an application using Spring Boot to use secure connection, follow the steps described
below.


1. Generate the certificate.

Use Java's keytool utility to generate a self-signed certificate or by one.
For self-signed certificate, do:

  keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650


This command generates the file keystore.p12, a PKCS12 keystore containing the certificate in it and using "tomcat" as alias.

Output example:

$ keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
Password?: tomcat Again: tomcat Your first and last names? [Unknown]: john doe Organizational unit? [Unknown]: unitOne Your company's name? [Unknown]: myEnterprise Your city or locality? [Unknown]: Rio de Janeiro Your state? [Unknown]: RJ Your country - two letters? [Unknown]: BR

This command generates a PKCS12 keystore, denoted by keystore.p12.
Move the generated file to project's root dir.
Example:
- windows:
move keystore.p12 $PROJECT_ROOTDIR
- *nix:
mv keystore.p12 $PROJECT_ROOTDIR


2. Set project's configuration file.
If using yaml and MySQL, it could be something like shown below, otherwise, if using ".properties" just convert to its notation using dots ('.').  Example: server.contextPath=/

server:
  contextPath: /
spring:
  profiles: 
    active: dev  #if using profile
---
spring:
  profiles: dev, default
server:
  port: 8443 #default HTTPS
  ssl:
    key-store: keystore.p12
    key-store-password: tomcat
    keyStoreType: PKCS12
    keyAlias: tomcat
datasource:
  setget:
    url: jdbc:mysql://localhost:3306/myproject
    username: adminName
    password: myPass
#    driverClassName: org.gjt.mm.mysql.Driver
    driverClassName: com.mysql.jdbc.Driver
    defaultSchema: mySchema
    maxPoolSize: 20
    hibernate:
#      dialect: org.hibernate.dialect.MySQLDialect
      dialect: org.hibernate.dialect.MySQL5Dialect
      hbm2ddl.method: update
      show_sql: true
      format_sql: true


3. Create a @SpringBootApplication class:

br.com.setget.control.TomcatTwoConnectorsApplication

package br.com.setget.control;

import org.apache.catalina.Context;
import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class TomcatTwoConnectorsApplication {

@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}

private Connector initiateHttpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(8080);
connector.setSecure(false);
connector.setRedirectPort(8443);
return connector;
}

}

3b. If it is used a not proper configuration class, the application may fail to start.
In such cases, it may return a message file when the http redirection fails, for instance, like this:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; 
nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling


This procedure was created based on the documentation below wich may be used as complementary searching source.
Thanks to the authors.

https://drissamri.be/blog/java/enable-https-in-spring-boot/

https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors

Wednesday, August 2, 2017

Thymeleaf: DefaultHandlerExceptionResolver : Failed to bind request





>PROBLEM

The page fails to render and returns the following error:



2017-08-02 19:41:27.258 WARN 13112 --- [nio-8080-exec-9] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to bind request
element: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type
'br.com.setget.model.User'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed
to convert from type [java.lang.String] to type [java.lang.Long] for value 'admin@email'; nested exception is
java.lang.NumberFormatException: For input string: "admin@email"


>SOLUTION

Check the thymeleaf's html code.
HTML input tags are responsible to upload values to the server.
If the input tag is not conform to thymeleaf semantic, it may cause this kind of issue.
In this example the defective code found was:

<div>
<input type="text" placeholder="username" name="user">
</div>
<div>
<input type="password" placeholder="password" name="password">
</div>


The defective code was corrected and replaced by the following:

<div>
<input type="text" id="email" name="email" th:placeholder="email" th:field="*{email}" /></br>
</div>
<div>
<input type="password" id="password" placeholder="password or create one" name="password" th:field="*{password}">
</div>


>ENV
Spring Boot 1.5.4.RELEASE
Thymeleaf 3.0.6.RELEASE
java 8

Monday, July 31, 2017

spring security fails checking password



>PROBLEM

The security layer fails to authenticate an user without any apparent reason.


>SOLUTION
There are many possible reasons.
Among other possibilities, check:

1. Fields' length checking.
Check the fields' lengths against the model class.
They must match.

2. Check the password's field configuration.
Usually, encryptors generates encrypted strings with length=64, so the database shall provide compatible value.


>ENV
spring boot 1.5.4.RELEASE
java 8
maven
eclipse

Sunday, July 30, 2017

spring boot: required a bean of type ... that could not be found , Consider defining a bean of type


PROCEDURE TO GUIDE YOU THROUGH HARD ISSUES ... MYSTERIOUS ONES
IN THE CONTEXT DESCRIBED HERE, AND POSSIBLY EXTENSIBLE TO OTHERS


>PROBLEM

Attempt of injecting a bean using Spring Boot and Maven fails with the following message:

Parameter 0 of method setStrongEncryptor in br.com.adr.thylab2.service.security.EncryptionSvcImpl required a bean of type 'org.jasypt.util.password.StrongPasswordEncryptor' that could not be found.
Action:
Consider defining a bean of type 'org.jasypt.util.password.StrongPasswordEncryptor' in your configuration.


>SOLUTION

1. First check your scan configuration.

Go to the class that it is used to start the app.
At @SpringBootApplication annotation check value offered to "scanBasePackages" if it contains a parent path for the class where the problem happens. Sometimes, a class becomes out of the subdirectory tree referenced by the scan value. If there isn't a parent path to the complaining class, add it.
@SpringBootApplication(scanBasePackages={"br.com.adr.thylab2", "my another package here"})

Example:

@SpringBootApplication(scanBasePackages={"br.com.adr.thylab2"})
public class Thylab2App extends SpringBootServletInitializer {
public static final String VERSION = "2.0.0-RELEASE";

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Thylab2App.class);
}
        public static void main(String[] args) {
             SpringApplication.run(Thylab2App.class, args);
        }    
}

2. Check your @Service or @Component annotations in the related classes, those with relationships concerned to the issue.
Is it missing an annotation?
Is it annotated as it should be?


3. Is the missing bean defined?
An alternative is to supply the missing bean using a common class.
For instance:

@Configuration
public class CommonBeans {

    @Bean
    public StrongPasswordEncryptor strongEncryptor(){
        StrongPasswordEncryptor encryptor = new StrongPasswordEncryptor();
        return encryptor;
    }
}


4. Check the library versions.
For instance, if using Maven, go to pom.xml and try to update the version of the related packages, or yet, try to downgrade.
Sometimes, one library causes issues with certain versions of another ones.


5. Eventually, rollback and proceed a step-by-step checking.
If the problem still persists, the issue may be caused by more than one issue, which exception thrown on the stack may interfere with the final results to help finding the solution.
This approach is radical but very effective.

First, you make the famous "backup" of the current project. Just do it, please!
A simple copy of it is enough.
If using versioning, for instance Git or SVN, you may get a previous point prior to the introduction of the new stuff related to the issue. This is the whole point, no matter which version control system you are working with!

5a. Check if your classpath contains the necessary references.
A simple way of doing this is including some testing code that references it.
For instance, if using Spring Boot, you could simply do, like below, in a straight manner in order to skip another possible setbacks to check if your classpath is properly configured.

@SpringBootApplication(scanBasePackages={"br.com.adr.thylab2"})
public class Thylab2App extends SpringBootServletInitializer {
public static final String VERSION = "2.0.0-RELEASE";

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Thylab2App.class);
}

  public static void main(String[] args) {

StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword("");

             SpringApplication.run(Thylab2App.class,  args);
        }    
}

5b. Bring to the code one interface/class set at a time.
Begin with the simplest classes, bringing just one interface/class set, and testing.
Test one after the other, never more than one by its turn.
You'll probably note that this procedure will show more than one issue, but working one by one, helps the compiler to guide you to the solution.

I do sincerely hope that this "laborious and boring" procedure may help you, but surely helped me when I was desperately lost, more than once, trying to find out a mysterious issue.  :-)


>ENV
spring boot 1.5.4.RELEASE
java 8
maven
eclipse

Wednesday, July 19, 2017

MySQL 5.5 ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails


>PROBLEM

Running the script like this:
  \. myScript.sql
fails and returns the message:
  ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

Nevertheless, if running the command straight on the console, it may work.



>SOLUTION

This issue was solved checking the file's encoding versus the database encoding and matching them.
So, the database was UTF-8, and the script was using the same encoding.



>ENV
Windows
MySQL 5.5

Sunday, July 9, 2017

spring: thymeleaf: There was an unexpected error (type=Not Found, status=404)



>PROBLEM

Pointing to URL returns 404.


Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Jul 09 11:37:35 BRT 2017



There was an unexpected error (type=Not Found, status=404).
No message available





>SOLUTION

The web site server will typically generate a "404 Not Found" message when the resource is not found, like a broken or dead link.

So, go to the Controller class and check the right link to be used.




Attention to the detail that sometimes, the application is not configured to use an extra identification in the URL. This is the case in this example.

Usually, the app's access is done using its name, like this:
  
   http://localhost:8080/appName/index

If the configuration does not use it, then we go straight to the controller's reference, like this:

  http://localhost:8080/index




















Friday, July 7, 2017

spring: thymeleaf: Neither BindingResult nor plain target object for bean name



>PROBLEM

The request returns the following error message:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Jul 07 17:02:46 BRT 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (login)




>SOLUTION

In this example, it missing the object requested by the html template at:



Check your parameters on the respective method in the controller's class.



Fixing the bug, including the missing parameter:




Problem solved.


>ENV
Java
Spring boot
Thymeleaf
Eclipse

Thursday, July 6, 2017

spring: thymeleaf: SpringInputGeneralFieldAttrProcessor Error



>PROBLEM

Running spring and thymeleaf, returns the following error page:


Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Jul 06 17:16:04 BRT 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (login)




>SOLUTION

Since the log is pointing to login, open the class which should have the respective attribute.
To find out, go to the page which is returning the error. The page may be found in the controller.
In this example we get:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String addNewLogin(Login login) {
return "login";
}

Opening the page, check the object pointed by thymeleaf's "th:object" property in form tag.
In this example is "th:object="${login}".
The error message means that the parser is complaining that it was not found the attribute login for Login class.








Opening the respective Login class, you get instead of "login" the "signin" attribute.


]


Switch the wrong attribute by the correct one, as below:









 Now refresh page, and that's it!  :-)


>ENV
Java
Spring boot
Thymeleaf
Eclipse

Friday, June 23, 2017

eclipse warning: An internal error occurred during: "Computing Git status for repository MiniTools". Unexpected internal error near index ...



>PROBLEM

Any change in the project caused the following message:
  An internal error occurred during: "Computing Git status for repository MiniTools".
  Unexpected internal error near index 8
  \target\

>SOLUTION
The error comes from the backslashed used in .ignore file.
Switch the backslashes to slashes.
WRONG: \target\
RIGHT: /target/

>ENV
Git
Eclipse Mars
Windows




Sunday, June 11, 2017

How to fix WordPress when it stops working after plugins' updates





>PROBLEM
The scenary: the WordPress dashboard alarms that it is required to update some plugins.
Then you update the first plugin, the second, the third and suddenly the site stops working, returning code HTTP 500 or another message, and you loose access to it.
If there is no access, there is no dashboard to handle the situation.

>SOLUTION
Sometimes happens that a plugin's update conflicts with others or your site's environment, like php's version, etc.
A solution consists moving all plugins to another folder out your WordPress's folder on the server.
After that, try to access your site and in case of success you may be sure that it was a plugin conflict.
Now, we need a method to restore the plugins at the same time we discover which of them is responsible for the site's crash.

>FIXING
The idea is to move all the plugins to a temporary folder, and then, after you've gained access again to your site, you may point to the dashboard.
At the dashboard, go to plugins and installed plugins.
You'll get a page with many warnings since the plugins directory is empty.
Refresh the page, getting a blank page like that when you started your site from scratch.
Don't panic.

Now, let's discover which plugin is responsible for the issue.
Pick one plugin's folder at once and copy it back from the temporary folder to the original source's folder, for instance:

from
  /temp/akismet
to
  /public_html/yourSite//wp-content/plugins/akismet

After that, go back to your dashboard and refresh the "installed plugins" page.
The plugin is gonna appear there as usual. Activate it.
If plugin activates succesfully, go to the next.
Repeat the same procedure for each plugin until you get the one that crashes your site.
When this happens, usually you'll have to repeat the whole process again, moving out all the plugins and reintroducing one by one and testing.

The one which crashed your site will be skipped, including the future installations, until you discover the reason of the issue.
Sometimes it is due an old environment requiring update or upgrade, a more "drastic update", like php version.

In order to make the things easier when using ftp connections, you may use command line which helps to make things faster.
Here is some code snippet suggestion:

- moving all at once:
rnfr /public_html/pomar/wp-content/plugins
rnto /temp/plugins

- moving from original source place to a temporary folder:
rnfr /public_html/pomar/wp-content/plugins/akismet
rnto /temp/akismet

- moving back from the temporary folder to the original folder:
rnfr /temp/akismet
rnto /public_html/pomar/wp-content/plugins/akismet

- to create a temporary folder, do:
mkd /temp

- for more information check:
https://en.wikipedia.org/wiki/List_of_FTP_commands
https://www.cs.colostate.edu/helpdocs/ftp.html
http://ftpguide.com/

>ftp command summary
@FROM: https://en.wikipedia.org/wiki/List_of_FTP_commands

abor # abort a file transfer
abor # abort an active file transfer.
acct* # send account information
appe # append to a remote file
appe # append.
cdup # change remote working directory to parent directory
cdup # change to parent directory.
cdup # cwd to the parent of the current directory
cwd # change working directory
cwd # rfc 697: change working directory.
dele # delete a remote file
dele # delete file.
eprt # rfc 2428: specifies an extended address and port to which the server should connect.
epsv # rfc 2428: enter extended passive mode.
feat # rfc 2389: get the feature list implemented by the server.
help # return help on using the server
help # returns usage documentation on a command if specified, else a general help document is returned.
list # list remote files
list # returns information of a file or directory if specified, else information of the current working directory is returned.
mdtm # return the modification time of a file
mdtm # rfc 3659: return the last-modified time of a specified file.
mkd # make a remote directory
mkd # make directory.
mlsd # rfc 3659: lists the contents of a directory if a directory is named.
mlst # rfc 3659: provides data about exactly the object named on its command line, and no others.
mode # set file transfer mode
mode # set transfer mode
mode # sets the transfer mode (stream, block, or compressed).
nlst # name list of remote directory
nlst # returns a list of file names in a specified directory.
noop # do nothing
noop # no operation (dummy packet, used mostly on keepalives).
opts # rfc 2389: select options for a feature (for example opts utf8 on).
pass # authentication password.
pass # send password
pasv # enter passive mode.
port # open a data port
port # specifies an address and port to which the server should connect.
pwd # print working directory on remote machine
pwd # print working directory. returns the current directory of the host.
quit # disconnect.
quit # terminate ftp session and exit
rein* # reinitialize the connection
rest # rfc 3659: restart transfer from the specified point.
retr # retrieve a copy of the file
retr # retrieve a remote file
rmd # remove a directory.
rmd # remove a remote directory
rnfr # rename from
rnfr # rename from.
rnto # rename to
rnto # rename to.
site # send site specific command to remote server
site # sends site specific commands to remote server (like site idle 60 or site umask 002). inspect site help output for complete list of supported commands.
size # rfc 3659: return the size of a file.
size # show size of remote file
stat # return server status
stat # returns the current status.
stor # accept the data and to store the data as a file at the server site
stor # store a file on the remote host
stou # store a file uniquely
stou # store file uniquely.
stru # set file transfer structure
stru # set file transfer structure.
syst # return system type
syst # return system type.
type # set file transfer type
type # sets the transfer mode (ascii/binary).
user # authentication username.
user # send new user information
xcup # rfc 775: change to the parent of the current working directory
xmkd # rfc 775: make a directory
xpwd # rfc 775: print the current working directory
xrmd # rfc 775: remove the directory

Sunday, January 29, 2017

Cygwin - Unrecognized TERM type


>PROBLEM

Type a command, for instance man or vi, the command fails with the following message:

  Unrecognized TERM type




>SOLUTION


The issue came from an attempt to switch the initial folder using "--dir" mintty's flag in the "Cygwin64 Terminal.lnk".
It was done something like this:

D:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico --dir  /cygdrive/D/work/devmob2_/cygwin/home/train -w max

The command above was replaced by its default (except -w flag):

D:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -w max -

Instead, the initial folder was set using windows' HOME envvar.

To set windows HOME envvar:
  sysdm.cpl
Add:
  HOME=/cygdrive/l/work/devmob2_/cygwin/home

virtualbox6: debian: netbeans install issues: "dpkg: warning: 'ldconfig' not found in PATH or not executable" and "pkg-deb: error: archive 'apache-netbeans_....deb' uses unknown compression for member 'control.tar.zst', giving up"

  >PROBLEMS/SOLUTIONS You desire to install  Netbeans  on a Debian O.S. using the VirtualBox v.6 because the VirtualBox v.7 fails on your...