The controller does not receive data from the websocket

I’m writing a chat with websocket. I use sockjs.js and stomp.js. Connection is successful, sabscrub too. But when i try to send a message to the backend (to send all those who join the chat) to the controller nothing happens, although the console says that the data sent:

>>> SEND


Here I establish a connection:

stompClient = Stomp.over(new SockJS("/ContactBook/app/cbxSoc"));

Here i i subscribe:

stompClient.subscribe('/topic/messages', function (message) {

Here I’m sending a message to backend:

stompClient.send("/app-dest-prefix/chat", {}, JSON.stringify({'from':'User', 'text':$scope.chatInput, 'timeCreation':new Date()})

Here my handler message controller:

public class ChatController {

public Message send(Message message){
String time = new SimpleDateFormat("HH:mm").format(new Date());
return message;

Here my websocket configuration:

public class CbxSocketConfig extends 

public void registerStompEndpoints(StompEndpointRegistry ser) {

public void configureMessageBroker(MessageBrokerRegistry config) {
// Prefix for messages FROM client TO server
// Prefix for messages FROM server TO client
config.enableSimpleBroker("/events", "/topic", "/queue");



I do not understand what my mistake is. It seems that the URL is not correct, but judging by the documentation everything is correct …

Use ANTLR4 to get full function content with the spaces for C Language

I am using ANTLR 4 to parse C codes using the grammar provide in the following link

Grammer for C.g4

I want the whole content of functions including all the spaces

Following is the Listener class that I am using to walk through the parse tree

public class CListnerImpl extends CBaseListener{

public void enterFunctionDefinition(FunctionDefinitionContext ctx) {
    System.out.println("Function name: " + ctx.declarator().directDeclarator().directDeclarator().getText());;

But for this code I am getting the function content without any whitespaces like

Function name: sumOfCubes

I want the output like

Function name: sumOfCubes
int d,sum=0;while(n!=0){d=n%10;n/=10;sum+=ddd;}return sum;

It is also ok if I get the code with all the indentations too

N-Queens with first queen placed

I have an assignment in Java- place n queens on n by n board so that none is attacking each other.
The position of the first queen is given. My issue is when I initialize the board (multidimensional array) the rows are skipped and the first queen placed is not being moved.
How do I place the first queen on selected position and backtrack so it will be moved?
It’s a homework so just part of my code:

    boolean nQueens (int board[][], int level, int N) {
    if (level == N) {
        return true;

    for (int j = 0; j < N; j++) {

        if (notSafe(j, level, board, N)) {

        board[j][level] = 1;

        if(nQueens(board, level+1, N)) {
            return true;

        board[j][level] = 0;

    return false;

Jax-WS with NTLM authentification

As I read Jax-ws can authenticate with NTLM, but I have a problem;
First of all I create MyAuthenticator java class as describe in java documentation(see:

when I try to connect with soapUI everything is Ok, see request header:

Request Headers Value
(Request-Line)  POST /Online/OnlineServices.asmx HTTP/1.1
Content-Type    text/xml;charset=UTF-8
SOAPAction  "http://CTL.COM/OnlineServices/AcquireTicket"
Connection  Keep-Alive
User-Agent  Apache-HttpClient/4.1.1 (java 1.5)
Accept-Encoding gzip, deflate
Content-Length  702 

when I try to connect with java, I got 500 Internal server error, see header:

Request Headers Value
(Request-Line)  POST /Online/OnlineServices.asmx HTTP/1.1
SOAPAction  "http://CTL.COM/OnlineServices/AcquireTicket"
Accept  text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type    text/xml;charset="utf-8"
User-Agent  JAX-WS RI 2.1.4-b01-
Connection  keep-alive
Accept-Encoding gzip, deflate
Content-Length  443

this is my code :

        Authenticator.setDefault(new MyAuthenticator(domain + "\kuser","kpass"));
        OnlineServicesSoap onlineServicesSoap = new OnlineServices(url, qName).getOnlineServicesSoap();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Content-Type", Collections.singletonList("text/xml;charset=UTF-8"));
        headers.put("Accept-Encoding", Collections.singletonList("gzip, deflate"));
        ((BindingProvider) onlineServicesSoap).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);
        try {
            AcquireTicketResponse acquireTicketResponse = onlineServicesSoap.acquireTicket(acqTicket);
        } catch (RuntimeException ex) {
            System.out.println(ex.getMessage() + ex.getCause());

I searched a lot and found some posts suggesting to do NTLM authentication but I couldn’t to connect.. I don’t want to use axis implementation

Spring Boot: how to get localized messages from JSR 303 Bean Validation messages?

In my Spring Boot app, I have a regular MessageSource set up and it without any issues it resolves multi-lingual messages based on the HTTP Accept-Language header.

However, it does not work for any messages coming from Bean Validation annotations, those always come in English. It’s as if they never pick up the current Locale.

Here is my global exception handler:

public ResponseEntity<ErrorSummary> handleConstraintViolationException(ConstraintViolationException e) {

    Locale l = LocaleContextHolder.getLocale();

    Set<Error> errors = e.getConstraintViolations().stream()
            .map(v -> new Error(v.getMessage(), String.valueOf(v.getPropertyPath())))

    return new ResponseEntity<>(new ErrorSummary(errors), HttpStatus.BAD_REQUEST);

When I debug I can see my Locale variable is “fr” (French), but all the constraint validation messages are in English.

Android app dependencies ClassNotFoundException

I’m new in Android development. Not very new in ordinary EE Java and Gradle.

So I am trying to build a REST consumer app for Android. I have a (1) .jar file I will need (contains DTOs and api consumers). That (1) .jar has dependencies on other (2) jars from Nexus repo. These (2) do depend on other (3) jars (e.g. apache commons lang3, etc.) from maven repos.

The funny thing is that… The app compiles and install just fine. But on runtime it occasionaly tends to lose some classes from (1) (at least (1) — dunno about (2) and (3) yet).

I know SO does not like pics in questions, but in this case I believe pics = clarity.

See below. Same runtime, same jar. Except one of the classes is not loaded, and another one, sitting right next to it, is available.

Some classes are not seen by the classloader

And some are seen

Why is that so? What did I do wrong?

One more thing… If I attempt to instantiate one of the missing classes (there’s more than one) in main activity (inside onCreate()), sometimes that class appears in the classpath and creates an object just fine. But as ridiculous as it may sound some other class goes missing! It feels like Classloader has limited number of slots for classes it could possibly handle.

Error downloading a File using JSF and OMNIfaces

I have an entity like this

public class myFiles  implements Serializable{

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int idmyFiles;

    private File myFile;

geters and setters...

I have an upload form that seems to work, when I upload a file I can see it in the postgtes table.

IN the form (I am using primefaces) I have this

          <p:fieldset id="myFiles" class="recuadro" legend = "Upload a fileos" >      

                                <p:fileUpload value="#{abmBean.fichero}" mode="simple"  />

                                <p:commandButton   id="btnSubir" ajax="false" process="@all" update="@all"  action="#{abmBean.uploadFile()}" value="Subir" />


This is the method that uploads the file

public void uploadFile()

            File destFile = new File("/tmp/"+fichero.getFileName());
            FileUtils.copyInputStreamToFile(fichero.getInputstream(), destFile);

    /* Then I just create a myFile object F and just F.setFile(destFile) */

It seems to work

To download the file I have this method

public downloadFile(int id)

/* the int id is the id of the myfile object F */

/* I retrieve from the database the F object and then this*/
    File fichero = new File("/tmp/"+F.getFile.getName());

                FileUtils.copyFile(F.getFile, fichero);

                Faces.sendFile(fichero, true);


This works just fine and I have the file back

But the problem is this, I realize that the file I uploaded was also copied to the /tomcat7/bin folder andif I remove the file from there then when I want to dowload it I get a fileNotFoundException.

All I need is to be able to provide the user the file from the database

I am using Tomcat7, Java 1.6 (yes pretty old) Primefaces 6, Postgresql 9.1 and JSF2 on a Debian

Java – && for two dimensional arrays

I’m trying to have an if statement that looks at characters in a 2D array and sees whether three of them are all the same character at the same time (in order to make a game of Tic Tac Toe, and ran into the same error :

bad operand types for binary operator '&&'
                if (TicTac[0][0] && TicTac[0][1] && TicTac[0][2] == 'x') {

Incidentally I was wondering how I can make it work.

Inconsistent byte array read when sent from PC to PC and from PC to Android

I have a Server application on my PC which reads a jpg file and sends it through a socket to the android device. The problem is that when android device receives a byte array, it can’t be converted to bitmap. I created a PC application to receive that same array and the data received is different than on the android even though I am using the same code to receive it.

Hence my assumption is that I somehow need to read it differently on android.

PC Java Server

        ServerSocket serverSocket = new ServerSocket(PORT);
        Socket clientSocket = serverSocket.accept();

        BufferedImage image = File("D:\test1\test.jpg"));
        ByteArrayOutputStream byteArrayoutputStream = new ByteArrayOutputStream();
        ImageIO.write(image,  "jpg", byteArrayoutputStream);
        OutputStream outputStream = clientSocket.getOutputStream();

        byte[] size = ByteBuffer.allocate(4).putInt(byteArrayoutputStream.size()).array();


Android receiver

    DataInputStream inputStream = new 

    byte[] sizeAr = new byte[4];;
    int size = ByteBuffer.wrap(sizeAr).asIntBuffer().get();

    byte[] imageAr = new byte[size];;
    bMap = BitmapFactory.decodeByteArray(imageAr, 0, imageAr.length);//this returns null

Why the number of wifi connections: 0?

I want to show Wifi connection list with android studio. There are 2 connections on wifi settings of my phone but my application doesn’t see them.

Thanks in advance

When I open debug application i see this sentence:
Number Of Wifi connections : 0

So why It can’t see wifi connections?
I tried when wifi is enabled and when it’s disabled.

import java.util.List;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

private StringBuilder sb = new StringBuilder();
private TextView tv;
List<ScanResult> scanList;

protected void onCreate(Bundle savedInstanceState) {
    tv= (TextView)findViewById(;

private void getWifiNetworksList(){
    IntentFilter filter = new IntentFilter();
    final WifiManager wifiManager =
    registerReceiver(new BroadcastReceiver(){

        @SuppressLint("UseValueOf") @Override
        public void onReceive(Context context, Intent intent) {
            sb = new StringBuilder();
            scanList = wifiManager.getScanResults();
            sb.append("n  Number Of Wifi connections :" + " " +scanList.size()+"nn");
            for(int i = 0; i < scanList.size(); i++){
                sb.append(new Integer(i+1).toString() + ". ");




<?xml version="1.0" encoding="utf-8"?>
< xmlns:android=""