Wednesday, August 25, 2021

hibernate: java.lang.IllegalArgumentException: org.hibernate.QueryException: Unable to resolve path


 >PROBLEM


java.lang.IllegalArgumentException: org.hibernate.QueryException: Unable to resolve path [e.title], unexpected token [e] [select e from br.com.adr.model.entity.security.uni.RoleEntity WHERE e.title = :title]



>SOLUTION


Original code:

String sql = "select e from " + this.entityName + " WHERE e.title = :title";

Query query = em.createQuery(sql, RoleEntity.class);

query.setParameter("title", title);


Fixing the code:

Missing the 'e' entity alias:

String sql = "select e from " + this.entityName + " e WHERE e.title = :title";


>ENV

Windows 10
JSF 2.2
WildFly 21

Tuesday, August 24, 2021

JEE: Using JSF, Primefaces and p:growl the messages return duplicated (twice).

 

>PROBLEM

Using JSF, Primefaces and p:growl the messages return duplicated (twice).





This kind of issue may have alternative reasons.
On this post it is shown two of them:
- The simple case
and
- The modal case


>SOLUTION #1 - SIMPLE CASE

Find the p:grow element.

Switch the p:growl attribute from:

<p:growl id="growl" showDetail="true"/>

to:

<p:growl id="growl" showDetail="false"/>


Supposing the java code is something like this:

public String remove() {
FacesMessage success = null;
try {
bsn.delete(toEntity());
success = new FacesMessage(FacesMessage.SEVERITY_INFO, "SUCCESS: ID " + this.id + " removed", null);
FacesContext.getCurrentInstance().addMessage(null, success);
clean();
return ModelConfigSvc.SUCCESS;
} catch (BsnException e) {
success = new FacesMessage(FacesMessage.SEVERITY_ERROR, "deletion failed",null);
FacesContext.getCurrentInstance().addMessage(null, success);
return ModelConfigSvc.FAIL;
}
}


or
public String remove() {
FacesMessage success = null;
try {
bsn.delete(toEntity());
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "SUCCESS: ID " + this.id + " removed", null));
clean();
return ModelConfigSvc.SUCCESS;
} catch (BsnException e) {
success = new FacesMessage(FacesMessage.SEVERITY_ERROR, "deletion failed",null);
FacesContext.getCurrentInstance().addMessage(null, success);
return ModelConfigSvc.FAIL;
}
}






>SOLUTION #2 - MODAL CASE

Scenario:
There is a page that lists entities and it may trigger modal pages to update, delete, etc.
In such cases, the modal message may aggregate to the origin page's message, in this case the listing page.

A fast way to fix this leads us to switch the return value to keep the modal opened and not returning to the listing page, so the message doesn't accumulate twice, one from the modal (p:messages) and the other from the listing page (p:growl).

So, it is changed from:
return ModelConfigSvc.SUCCESS;

To:
return ModelConfigSvc.FAIL;

Below, it is shown the detailed information using the "deletion" to illustrate the example.






Issue to be fixed - doubled messages when the modal is closed after the deletion





THE CODE

faces-config.xhtml



roleList.xhtml





roleDeletion.xhtml exibted as modal







FIXING THE ISSUE


RoleDeletion.java







Return value switched to fix the issue

RoleDeletion.java 





Issue fixed






>ENV


Windows 10
JSF 2.2
WildFly 21





Saturday, August 21, 2021

JEE: Caused by: java.lang.IllegalArgumentException: UT010009: Servlet Faces Servlet of type class javax.faces.webapp.FacesServlet does not implement jakarta.servlet.Servlet

 

>PROBLEM


The application fails when deployed on the server (Wildfly/jBoss) return the following message:

  Caused by: java.lang.IllegalArgumentException: UT010009: Servlet Faces Servlet of type class javax.faces.webapp.FacesServlet does not implement jakarta.servlet.Servlet



>SOLUTION


Check the following configuration:

- JDK'S version

- Libraries' versions (Maven's dependencies, etc.)

If the configuration seems correct, try to downgrade (or maybe upgrade) the server's version of JBoss or Wildfly.

For instance, from v.23 to v.21 or lower.

The application server's JEE version must be compatible with the project's libraries versions.

        Check WildFly's JEE versions on its download page.



>ENV

JDK 8/11

Wildfly 21

Eclipse

Windows 10

Tuesday, August 17, 2021

iptables: No chain/target/match by that name.


>PROBLEM

When running a "iptables conntrack" command, for instance like this:
    iptables -A INPUT -p tcp --dport 8081 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
 
returns the error message:
  
  iptables: No chain/target/match by that name.


>SOLUTION

The solution may contemplate alternatives due different causes.
This post shows two of them.

>using linux on a openvz container

OpenVZ servers share a kernel with the host, and as a result, you cannot load any kernel modules, and do some other tasks.

Ask your service provider to turn on the NetFilter for the server.


>linux, but not a container

Check this link.


>ENV

OpenVz container


Wednesday, August 4, 2021

debian 10: nginx fails to install after system upgrade


 >PROBLEM


Scenario:

After performing an upgrade using:

apt update

apt upgrade


nginx returns installing issues and fails to start, returning an error message like this:


Aug 04 13:28:47 myserver.com systemd[1]: Failed to start A high performance web server and a reverse proxy server.

dpkg: error processing package nginx-full (--configure):

 installed nginx-full package post-installation script subprocess returned error exit status 1

dpkg: dependency problems prevent configuration of nginx:

 nginx depends on nginx-full (<< 1.14.2-2+deb10u4.1~) | nginx-light (<< 1.14.2-2+deb10u4.1~) | nginx-extras (<< 1.14.2-2+deb10u4.1~); however:

  Package nginx-full is not configured yet.

  Package nginx-light is not installed.

  Package nginx-extras is not installed.


>SOLUTION

1. Check the installed packages:

  dpkg -l nginx*

Returns:

||/ Name           Version          Architecture Description
+++-==============-================-============-=========================================================
iU  nginx          1.14.2-2+deb10u4 all          small, powerful, scalable web/proxy server
ii  nginx-common   1.14.2-2+deb10u4 all          small, powerful, scalable web/proxy server - common files
un  nginx-doc      <none>           <none>       (no description available)
un  nginx-extras   <none>           <none>       (no description available)
iF  nginx-full     1.14.2-2+deb10u4 amd64        nginx web/proxy server (standard version)
un  nginx-light    <none>           <none>       (no description available)
root@again4u:/opt# dpkg remove nginx-1.14.2


2. Purge the packages:

  apt purge nginx-common nginx-full


3. Testing the removal:

  dpkg -l nginx*
root@again4u:/opt# dpkg -l nginx*
dpkg-query: no packages found matching nginx*

Shall return "no packages found..."


4. Deactivate the firewall, temporarily.


5. Reinstall nginx.

  apt install -f nginx
  

6. If reinstallation fails returning the same previous issue, uninstall nginx again, repeating the steps above and reboot the server.

If using a remote server, use the provider's interface to reboot it.

Deactivate the firewall, temporarily, and install nginx again:

  apt install -f nginx



7. Test the installation.

  systemctl status nginx

If successful, return something like this:

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-08-04 13:54:48 EDT; 22min ago
     Docs: man:nginx(8)
 Main PID: 723 (nginx)
    Tasks: 3 (limit: 4915)
   Memory: 16.3M
   CGroup: /system.slice/nginx.service
           ├─723 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           ├─726 nginx: worker process
           └─727 nginx: worker process


8. Start the firewall.


>ENV

debian 10

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