Saturday, April 4, 2020

session_start(): Failed to read session data joomla

In this post we will resolve problem that occures ofently:
This problem is due essentially to MySQL connection
1- Verify your SQL connection (Servie is up)
2- Connect with your joomla user to database
   mysql -u your_user -p 
   Enter your password
3- You may have this errror
    ERROR 1524 (HY000): Plugin '*F70658E9BDD2910AC33ACDA164605DFC1DA70A68' is not loaded

4- All right: this proble occures when MySQL password encryption is not supported.
    4.1- Login with root
           
 mysql -u root -p Enter your password;
use mysql;
update user set authentication_string=PASSWORD("your_password") where User='joomla_user';
update user set plugin="mysql_native_password" where User='joomla_user';
flush privileges;
quit;


--> Now refresh your website page and it works

Sometimes we need to restart MySQL for unknown bug, then u can run:
1- mysqladmin.exe -u root -p shutdown
   <Enter your root password>
2-  mysqladmin.exe -u root -p start
   <Enter password>
End go to 4th statement above.

Tested on MySQL 5.7.17 Community Server
             Windows 10 [version 10.0.18362.720]
             Php 7.1.3
             Joomla 3.9.16

Sunday, March 29, 2020

Html CSS background transition using jQuery

Supposing we have to animate body background-image change, this small code can help:

<script>
 
var bgs = ['background-image-1','background-image-2','background-image-3];/*Must be filled with images urls*/
var nbBgImages = 3; /*Must be changed if we have more or less then 3 images*/
</script>
Note:
background-image-1, background-image-2, background-image-1,....,background-image-N must have this form:
url(image-url)

Let's continue javascript and then we'll add a litte css style:
Assuming we are using jQuery we add this script inline or in separate js file:

 
(function($) {
var currentShowingBg = 1;
setInterval(changeBgImage, 7000);
function changeBgImage(){
$("body").css("background-image", bgs[currentShowingBg]);
++currentShowingBg;
if(currentShowingBg >= nbBgImages) currentShowingBg = 0;
}
})(jQuery);


all right now with js
Let's add transitions :
<style>
 
body{

background-repeat:no-repeat;>
background-position:center;
background-color:black !important;
-webkit-transition-property: background-image;
-webkit-transition-duration: 4.0s;
-webkit-transition-timing-function: ease-out;
}

</style>
Now it works ! you can stop here

Let's optimize !
There s a little shity problem with previous code: in case we have big images, latence time spend in images download will affect transitions.

A little trick is to load all images inside the html code but HIDDEN, then knowing that ready function of jquery launched only when DOM is loaded entierly we'll avoid the problem:
Let's add this html:

 
<div style="display:none">
<img src="image1"/>
<img src="image2"/>
<img src="image3"/>

</div>


all right.
See you in j2ee snippets that's better.


Wednesday, December 4, 2019

MySQL SQLSTATE[HY000] [1524] Plugin is not loaded

Hello,
Sometimes when working with PDOConnections to Mysql this errors is thrown,

..... In PDOConnection.php line XXXX:
  SQLSTATE[HY000] [1524] Plugin '*9CBB2AF8EB953A91706ADC84736447DE04E311E9' is not loaded
Note that, connection to database through command line or phpmyadmin web interface is possible and don"t raise exceptions

This error is probably due to password ecnryption method in Mysql
Follow these few steps
Connect to mysql using root:

>mysql -u root -p
-----Provide your password-----
>use mysql;
>update user set authentication_string=PASSWORD("USER_PASSWORD") where User='YOUR_USER';
>update user set plugin="mysql_native_password" where User='YOUR_USER';  # THIS LINE
>flush privileges;
>quit;


Monday, July 1, 2019

Tuto Spring Boot Webservice / JPA Repository / Oracle / Maven / Eclipse

This tutorial aims to build a simple web service using spring boot .
Let's start by ddownload our start package from :
https://start.spring.io/

We will call our project solvability <=> Artifact a sub functionnality of an extranet web services portal tn.cnss.extranet.employeur <=>Group
We will also choose maven to manage dependencies, tests and continuous dev/deployement actions




fig 1- Starting springboot package


Now w will import our project in eclipse environnement :
File > Import maven project



fig 2- Import project in eclipse



fig3- Before maven configuration

Once the project was imported, we will configure maven configuration in eclipse by indicating our M2_HOME
by default maven is configured to store dependencies on /user_home/.m2/repository as shown in this image


And after modification:


fig4- After maven changes

Now we will add our unique additional dependency (oracle driver)
Here ive already in my repo oracle 11.2.0.4 driver
For those who don't have oracle driver installed :
 1- Start by downloading the ojdbc (or copy it from sqldeveloper tool if you use it)
2- run this command :
mvn install:install-file -Dfile=<path-to-oracle-driver-file>

Once all is done we add the dependency tag in our pom file

        <dependency>

            <groupId>com.oracle</groupId>

            <artifactId>ojdbc</artifactId>

            <version>11.2.0.4</version>

        </dependency>



fig5- Oracle dependency






fig6- application.properties file


Now let's continue:
We have to setup our /src/main/resources/application.properties file; and put some needed parmaters:
in our case:
spring.datasource.url=jdbc\:oracle\:thin\:@ip.ip.ip.ip:\port\:SID
spring.datasource.username=user_name
spring.datasource.password=user_password
spring.jpa.properties.hibernate.show_sql=true_or_false
spring.jpa.properties.hibernate.use_sql_comments=true_or_false
spring.jpa.properties.hibernate.format_sql=true_or_false
server.port = our_webservice_port_number
logging.level.org.hibernate=ERROR_see_hibernate_logging_level
NB: ERROR is less verbose



Note now our application can start without errors.

Let's continue
Now we will create our RestController (Entry points for remote invokations)
A RestController is a java class annotated with @RestController
(Reference to org.springframework.web.bind.annotation.RestController)

To make our code structured we can create a package controller under our project






fig7- controllers package



And then we create our controller  under the new created  package
In our case we will check the solvability of a customer we will need two params
root number and key (consistency)
we will invoke that method from "APP_URL/check-solvability " with simple http GET request

So we use
@GetMapping annotation

So the behavior of our code  could be
 /**
  * Check if customer is solvable or no
  * @param root
  * @param key
  * @return true or no
  */
 @GetMapping( "/check-solvability/{rootValue}/{keyValue}") 
 public String getCustomerFinancialSituation(@PathVariable String rootValue, @PathVariable String keyValue ){
  //Some logic here 
  //For exemple if we will return true always
   JSONObject output = new JSONObject();
   output.put("result", "ok");
   output.put("value","1");
   return output.toString();
 
 }

Let's instroduce a business layer (it's logic that the business rules are delegated to a seperated class  
And we create our business layer or business package 
and business implementations package

fig8- business package

And we create this interface that will be implemented by the financial dev team 


fig9- business interface

Let's continue
Once interface is created we can proceed to business injection in the main controller, this can be done by these two lines
 @Autowired
 private FinancialBusiness financialBusiness;

fig10- business injection


Lets's continue

Now we create implementation package for business, and a specific implementation for our previously ceated interface Financial business




fig11- business interface implementation


if you want to interoduce repositories cantact me for more advanced example.








Wednesday, June 19, 2019

Remmina login failed for display 0 Centos client / xrdp server on Centos 7

Hello,
When trying to connect my desktop pc (CentOS 7 ) to my new Laptop (CentOS 7) vusing Remmina, i've faced this problem :
Login successfull and then a message window saying:
sending login info to session manager, please wait
login failed for display 0

is shown.

I tried  to change xrdp.ini file by modifying some parameters such as max_sessions or bpp values but the error persists to update my remmina version or to changs session manager params .....

When i used windows mstsc i discovered that is works fine, rdesktop works fins also(but loud)  I was certain that the problem was remmina's one ...


Solution was very simple for Remmina after 2 days   😕😕😕😕😕
i've just changed
color depth combobox value in my case to 24bpp (max_bpp=32 in /etc/xrdp/xrdp.ini) 

Now it works fine and with correct desktop refresh speed