How to redirect to new url with preset cookies in gwt?

I have a GWT page with just a button, I want when I click on the button it automatically logins to another website page with my username and password.

I have done it as below :
When I click on the button it uses an RPC and logins to the remote website in my server side and returns its cookies to my client side.

how can I use returned cookies in client side to login that URL? when I open that address in my browser still I see the login page.

here is part of my code:

public void onClick(ClickEvent event) {
            loginService.login("myusername", "mypassword", new AsyncCallback<HttpRequestResult>() {

                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub
                    Window.alert("login failed");

                public void onSuccess(HttpRequestResult result) {

               // check if login was successfull ...
                    String url = "";
           , "_self", result.getCookies());

Thank you

Log4j rolling file appender: include LAST timestamp in filename

I fiddled around with a rolling file appender with autocompress to .gz, which gave me a lot of files like this:

  • foo_bar_1.gz
  • foo_bar_2.gz

and so on.

Next I changed the filePattern to “%d{yyyy-MM-dd}_%d{HH-mm-ss}.log.gz” which included a timestamp into the filename. Unfortunately our system management division can’t use the timestamp, as this timestamp does not reflect the LAST insertion into the log (or at least the timestamp when rolling and compressing occured).

Is there any way to make Log4j2 to change the filename of the logfile (and of course of the compressed file) to the timestamp of the last insertion?

Two version of same libary with same package name in one application

I need to connect single app to two different application. First application is using protocol P in version 1 second is using same protocol in version 2. Libraries are incompatible so I have to use both in my app. Problem is that they are using same package e.g. and architecture (class names, packages) are the same.

Is it possible to use both of them in same app?

Cannot unzip files with kotlin

There are multiple files in a .zip file, which I’m trying to get. Trying to unzip the files provides a java.lang.IllegalStateException: zis.nextEntry must not be null. How to do it the right way?

    fun unzip(zipFile: File, targetDirectory: File) {
        val zis = ZipInputStream(
        try {
            var ze: ZipEntry
            var count: Int
            val buffer = ByteArray(8192)
            ze = zis.nextEntry
            while (ze != null) {
                val file = File(targetDirectory,
                val dir = if (ze.isDirectory) file else file.parentFile
                if (!dir.isDirectory && !dir.mkdirs())
                    throw FileNotFoundException("Failed to ensure directory: " + dir.absolutePath)
                if (ze.isDirectory)
                val fout = FileOutputStream(file)
                try {
                    count =
                    while (count != -1) {
                        fout.write(buffer, 0, count)
                        count =
                } finally {
                    ze = zis.nextEntry
        } finally {

Liferay LDAP authentication ignoring password

i’ve configured an LDAP authentication on my Liferay Portal 6.2 CE.

The problem i figured out is that when users login, my portal ignore completely the password check.

This is the current user mapping:

Username: sAMAccountName
Email: userPrincipalName
Password: unicodePwd
Name: givenName
Second name: middleName
Surname: sn
Fullname: cn
Gruppo: memberOf

Moreover, the portal is configured to ignore Liferay internal password authentication, delegating to LDAP:


How to use :: operator as this reference

Converting a list of objects Foo having an id, to a Map<Integer,Foo> with that id as key, is easy using the stream API:

public class Foo{
    private Integer id;
    private ....
    getters and setters...

Map<Integer,Foo> myMap =, (foo) -> foo));

Is there any way to substitute the lambda expression: (foo) -> foo with something using the :: operator? Something like Foo::this

Hibernate: no persistent classes found for query class but mapping is correct

This question has been asked many times, but I have not encountered a solution for my problem as on first sight everything seems right. Perhaps it is a configuration problem.

When I try to execute a query I get a warning in the console that says no persistent classes found for query class but no error is thrown, and no data is retrieved from database although it should return over 30 entries:

09:56:58,203 INFO  [org.hibernate.Version] (default task-46) HHH000412: Hibernate Core {5.2.11.Final}
09:56:58,206 INFO  [org.hibernate.cfg.Environment] (default task-46) HHH000206: not found
09:56:58,348 INFO  [org.hibernate.annotations.common.Version] (default task-46) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
09:56:58,397 WARN  [org.hibernate.orm.connections.pooling] (default task-46) HHH10001002: Using Hibernate built-in connection pool (not for production use!)
09:56:58,398 INFO  [org.hibernate.orm.connections.pooling] (default task-46) HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/db_motor?useSSL=false&autoReconnect=true]
09:56:58,398 INFO  [org.hibernate.orm.connections.pooling] (default task-46) HHH10001001: Connection properties: {user=admin, password=****}
09:56:58,398 INFO  [org.hibernate.orm.connections.pooling] (default task-46) HHH10001003: Autocommit mode: false
09:56:58,400 INFO  [org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (default task-46) HHH000115: Hibernate connection pool size: 10 (min=1)
09:56:58,647 INFO  [org.hibernate.dialect.Dialect] (default task-46) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
09:56:58,958 WARN  [org.hibernate.hql.internal.QuerySplitter] (default task-46) HHH000183: no persistent classes found for query class: SELECT respuestas FROM mr.hibernate.beans.MR_RespuestasHBean respuestas
09:56:58,959 INFO  [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-46) HHH000397: Using ASTQueryTranslatorFactory

It seems the warning about not found is not of any influence if I interpret information found on this website correctly.

The hibernate.cfg.xml:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    <session-factory name="session_factory">
        <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
        <property name="connection.password">admin</property>
        <property name="connection.pool_size">10</property> <!-- not for production -->
        <property name="connection.url">jdbc:mysql://localhost:3306/db_motor?useSSL=false&amp;autoReconnect=true</property>
        <property name="connection.username">admin</property>
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.format_sql">true</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.use_sql_comments">true</property>
        <mapping class="mr.hibernate.beans.MR_RespuestasHBean"/>

A part of the mapped class:

package mr.hibernate.beans;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.ColumnTransformer;

@Table(name = "T_RESPUESTAS")
public class MR_RespuestasHBean implements Serializable {

    private static final long serialVersionUID = 3892055031093758454L;

    @Column(name = "COD_RESPUESTA", nullable = false, length = 9)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long codigoRespuesta;

    @Column(name = "DESC_RESPUESTA", nullable = false, length = 250)
    @ColumnTransformer(read = "RTRIM(DESC_RESPUESTA)")
    private String descripcionRespuesta;


The code used to get the query is this:

    session = getSession(HibernateUtil.configurationFileMySql);

    StringBuffer hql = new StringBuffer();

    StringBuffer select = new StringBuffer();
    select.append("SELECT respuestas");

    StringBuffer from = new StringBuffer();
    from.append(" FROM "+ MR_RespuestasHBean.class.getName() +" respuestas");


    Query<MR_RespuestasHBean> query = session.createQuery(hql.toString());

    listado = query.list();

If I change MR_RespuestasHBean.class.getName() by MR_RespuestasHBean.class.getSimpleName(), an error is thrown:

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: MR_RespuestasHBean is not mapped

Some information on the environment:

  • JBoss EAP7
  • Hibernate 5.2.11
  • JDK8
  • MySql connector 6.0.6
  • The Hibernate part is in an EJB3 project

Any clues on what is wrong with my set-up and causing the problem is very much appreciated of course.

Parallel implementation of bubble sort

The main idea of this project is to parallel bubble sort. my approach to this project is,to create one big array and then divide it in to parts ( 4 or 5) based on the number of threads. for instance if the size of the array is 10, i divide it into 2 sub arrays, 0-4 and 5-9, then one thread has to scan the big arrays, and if the value is between 0-4 , assign the the the first sub arrays, if not assign to the next sub-array. then apple the bubble sort algorithm to all sub-arrays simultaneously. finally, all the sub arrays should be added to a thread safe queue.
for now i have three class, the main class where i created the array, the U tiles class for shuffling the array, find the min and max of the array and the bubble sort class that has a bubble sorting algorithms.
my challenge for now is, how divide the big array into small sub-arrays and fill the sub-array with values.
i will appreciate all suggestions and helps. under is my classes.


import javax.xml.transform.sax.SAXSource;
import java.util.Random;

public class Main {

    public static void main(String[] args) {       

        // filling the array with integer values
        int[] anArray = Utils.fillArray((int) 10);          

    // find the min and max of the array

        BubbleSort sort = new BubbleSort(anArray);
//        Utils.printArray(anArray);       




import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class Utils {

    private static volatile int max;
    private static volatile int min;
    private static int[][] arrays;

      public Utils(int[][] arrays,int[] array) {
        max = array[0];
        min = array[0];

    // taken from the kings class
    // source:
    // Implementing Fisher�Yates shuffle
    public static void shuffleArray(int[] ar) {
        // If running on Java 6 or older, use `new Random()` on RHS here
        ThreadLocalRandom rnd = ThreadLocalRandom.current();
        for (int i = ar.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            // Simple swap
            int a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;

    public static void printArray(int[] anArray) {
        System.out.print("Array: ");
        for (int i=0; i< anArray.length; i++){
            System.out.print(anArray[i]+" ");

    public static int[] fillArray(int amount) {
        int[] result = new int[amount];
        for (int i=0; i<amount; i++){
            result[i] = i;
        return result;
    public static void findMinMax(int[] array) {
        int i = 0;
        for (; i < (array.length) / 2; i++) {
            int num1 = array[1 * 2];
            int num2 = array[i * 2 + 1];
            if (num1 >= num2) {
                if (num1 > max)
                    max = num1;
                if (num2 < min)
                    min = num2;
            } else {
                if (num2 > max) {
                    max = num2;
                    if (num1 < min)
                        min = num1;
        if (i * 2 < array.length) {
            int num = array[i * 2];
            if (num > max)
                max = num;
            if (num < min)
                min = num;

        System.out.println("min is: " + min);
        System.out.println("max is : " + max);


public static int getMax() {
        return max;

    public static int getMin() {
        return min;
    public static void print(int[] anArray, int i) {

Cannot start spesific WebSphere Application Server

I am receiving an error when starting application server. I am getting this error only specific server, the other starting perfectly fine. We are using WebSphere version. I have shared the log below. I am not familiar with WebSphere system so if you need anything else beside this log, i will try to share it.

enter image description here

Exception Log:

    class load: org.eclipse.osgi.service.debug.DebugTrace from: file:/opt/IBM/WebSphere/AppServer/plugins/org.eclipse.osgi_.jar
class load: org.osgi.framework.InvalidSyntaxException from: file:/opt/IBM/WebSphere/AppServer/plugins/org.eclipse.osgi_.jar
        at java.util.Random.nextLong(
        at org.eclipse.osgi.internal.baseadaptor.AdaptorUtil.canWrite(
        at org.eclipse.core.runtime.adaptor.LocationManager.canWrite(
        at org.eclipse.core.runtime.adaptor.LocationManager.buildLocation(
        at org.eclipse.core.runtime.adaptor.LocationManager.initializeLocations(
        at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.eclipse.core.launcher.Main.invokeFramework(
        at org.eclipse.core.launcher.Main.basicRun(
class load: java/text/MessageFormat
class load: java/text/FieldPosition
class load: java/util/Date

Java Object to String

My DAO gets information from the database using this line of code.

public Object[] getTagData() {
    List TagData = entityManager.createNativeQuery("SELECT, count(st.tags_tagId) as tagCount FROM subject as sub LEFT JOIN subject_tag  st on st.subject_subjectId = sub.subjectId GROUP BY;")

  return TagData.toArray();

It returns


I need to convert this into a String so that I know in what form it will return.