Screenshot from 2017-11-09 13-08-37

To enable symbolic links in Payara you just have to go to the admin console (http://localhost:4848 or inside netbeans open it in the Services window | Servers | Payara right click it and select ‘open admin console’) and click Configuration | server-config | Virtual Servers | server, then under Additional Properties, click Add Property and enter allowLinking as name and true as value as shown in the image above.

Symbolic links do not work with war deployments, they only work with exploded wars (if you add a symbolic link inside a war, the files from the target dir will be copied inside the war -compressed file-)
The good news is that Netbeans runs your app as an exploded war (folder). The folder path is usually {project}/build/web, to find out the folder which it uses for your app just open the Payara admin console and go to the Applications section and click your app, then look for the attribute ‘Location’
Go to that location and create whatever symbolic link your app needs, for example

cd {project}/build/web
ln -s /usr/share/docs docs

then you can access all the resources inside that folder like so

http://localhost:8080/project/docs

In production, you’ll have to deploy your app as an exploded war and have the same symbolic link created in the server

sources:
http://www.stpe.se/2008/07/enable-symbolic-links-in-glassfish/

Anuncios

Screenshot from 2017-11-08 14-43-11

I’ve started a project with jhipster@4.10.2 and ran the usual yarn install and afterwards mvn, it executed fine and I could see the result on http://localhost:8080.
Then, I opened the project on [IntelliJ] and followed the steps on the guide to configure the IDE to exclude directories, enable spring support, enable javascript code support and -the most important feature to me- application hot restart. The last step in the guide is to enable the maven IDE profile, but it caused the following error

Error:(19, 8) java: cannot access javax.servlet.Filter
class file for javax.servlet.Filter not found

when I tried to run the app (right click your app class file src/main/java/{package}/{appname}.java and choose ‘Run’), well actually at compile time.

I just had to disable the IDE maven profile to get it working again.

jhipster_logo

En un proyecto generado con jhipster@4.5.6 me estaba marcando el error ‘The engine “node” is incompatible with this module’ al ejecutar el comando yarn install

El problema es que en esta versión el archivo packages.json tenía una línea que decía

“engines”: {
“node”: “^4.3”
}

mi versión de node es

node -v
v7.1.0

y de acuerdo a semver la especificación “node”: “^4.3” me permitiría solamente utilizar node 4.x
Puedes forzar la ejecución de yarn install de la siguiente manera

yarn install –ignore-engines

Esto fue corregido en versiones posteriores de jhipster, por ejemplo en la versión 4.10.2 el archivo packages.json especifica

“engines”: {
“node”: “>=6.9.0”
}

lo que permite utilizar versiones más recientes de node, v7.1.0 por ejemplo.

para actualizar tu proyecto de jhipster (primero actualiza jhipster con yarn global upgrade generator-jhipster) intenté utilizar el comando jhipster upgrade pero no pudo actualizar debido a que marcaba el mismo error. Para actualizar lo que hice fue simplemente volver a ejecutar el comando jhipster (equivalente a jhipster app)

fuentes:
https://github.com/gilbarbara/react-joyride/issues/131
https://docs.npmjs.com/misc/semver
https://yarnpkg.com/
https://nodejs.org/

git – resolver conflictos

noviembre 8, 2017

uQVJZ
Cuando trabajas en un proyecto compartido, con control de versiones en git, es muy frecuente que te encuentres con conflictos al hacer un merge de los cambios de los demás.
Para resolver estos conflictos la mayoría de IDE’s (intellij, netbeans, etc.) tienen una opción ‘resolver conflictos’ que muestra un editor de 3 partes con las diferencias.
Existen varias herramientas en linux para comparar archivos -incluso carpetas- entre las que destaca meld. Puedes abrir esta herramienta desde la línea de comandos -para no tener que abrir el proyecto en el IDE- cuando aparezcan estos conflictos. Primero tienes que instalar meld y luego hay que establecerla como la herramienta por default para resolver conflictos en git con git config --global merge.tool meld y cuando haya conflictos tras hacer un merge la podemos abrir mediante git mergetool.

fuentes:
https://stackoverflow.com/questions/12956509/how-to-set-meld-as-git-mergetool

I’ve just upgraded to netbeans 8.2. I imported my previous settings from 8.1 when it asked me to do so. When I opened a previous project it throw me an error at compilation time complaining that I have missing the package javax.validation, at first I thought I had to reconfigure the jdk default home for netbeans (file [netbeans_dir]/etc/netbeans.conf) since it was choosing my os default open-jdk. But it had nothing to do with this.

You need to install the EJB and EAR plugin for it to work properly.

If you happened to have the plugin installed and still got the error above, it could be the application server you are using. In my case i configured the project to run on payara 173 which renamed the file bean-validator.jar to validation-api.jar to follow conventions, but netbeans 8.2 didn’t update the library path. A quick solution is to copy the file validation-api.jar in {payara-home}/glassfish/modules and name it bean-validator.jar.

sources:
https://groups.google.com/forum/#!topic/payara-forum/GVzQk2twHGM

I’ve had a lot of troubles to display a datetimepicker inside a bootstrap modal window. I’ve tried several ways to display the datetimepicker but none of them worked (delegate, z-index, etc.)

The problem I think, is we tried to initialize the datetimepicker before it gets added to the DOM, because of the animation on the modal window.
I tried also to initialize the datetimepicker on the ‘opened’ event of the modal window like so

<div class="row">
            <div class="'col-sm-3'">
                <div class="form-group">
                    <div class="'input-group" id="'datetimepicker'">

                        <span class="input-group-addon">
                            <span class="glyphicon glyphicon-time"></span>
                        </span>
                    </div>
                </div>
            </div>
        </div>
var modal = $modal.open({
      templateUrl: ...,
      controller: ...
});
modal.result.then(function (result) {
     $state.go('avisos', null, {reload: true});
}, function () {
    $state.go('^');
 });

modal.opened.then(function(){
     console.log('modal opened');
     $('#datetimepicker').datetimepicker({ format: 'DD/MM/YYYY'});
});

the event gets fired before the datetimepicker is in place and therefore not initialized correctly. So, the solution for me was to initialize the datetimepicker in a timeout function inside my angular controller

setTimeout(function () {
     $('#datetimepicker').datetimepicker({
         format: 'DD/MM/YYYY'
     });
}, 1000);

Screenshot from 2017-10-04 14-18-42

we needed to filter the events on a fullcalendar. The fullcalendar retrieves the events from the server through a REST service like so

<div id="calendar"></div>
$scope.calendar.fullCalendar({
                header: ...,
                defaultView: 'agendaWeek',
                events: function (start, end, timezone, callback) {
                    Audiencia.findByDates({inicio: start.format('YYYY-MM-DD'), fin: end.format('YYYY-MM-DD')}, function (data) {
                        var events = data.map(function (audiencia) {
                            return {
                                start: moment(audiencia.inicio).tz('America/Mexico_City'),
                                end: moment(audiencia.fin).tz('America/Mexico_City'),
                                title: audiencia.nuc || (audiencia.sala ? audiencia.sala.nombre : 'Audiencia'),
                                audiencia: audiencia,
                                backgroundColor: audiencia.tipoAudiencia.color
                            };
                        });
                        callback(events);
                    });
                },

here we used a $resource called Audiencia which retrieves the events from the server. we have to map the properties in the Audiencia objects to the Event object expected by the fullcalendar, nothing special.
Then, when a select option is changed we need to filter the events accordingly, so we need to add the select control and bind the event.

<div class="row">
        <div class="col-sm-6">
            <div class="form-inline">
                <div class="form-group">
                    Juez 

                        TODOS

                </div>
            </div>
        </div>
    </div>
    <div id="calendar"></div>
$scope.filtro = {
                juez: null
            };

$scope.jueces = Juez.query();

$scope.refrescarAudiencias = function (juez) {
                $scope.calendar.fullCalendar('rerenderEvents');
            };

$scope.calendar.fullCalendar({
                header: ...,
                defaultView: ...,
                events: ...,
                eventRender: function (event, element) {
                    var audiencia = event.audiencia;
                    if ($scope.filtro.juez && !audiencia.jueces.reduce(
                            function (prev, current) {
                                return $scope.filtro.juez.id === prev.id || $scope.filtro.juez.id === current.id;
                            })) {
                        return false;
                    }
                },...

here the important part is the eventRender function that is called for each event and when it returns false, the event is not displayed, thus filtered.
In the example the object Audiencia contains an array of Juez and if the selected Juez matches any of the Juez in the audiencia it is shown, otherwise it is not. We used the reduce function which takes an array and produce a single value, boolean in this case. Notice that we added an extra option ‘TODOS’ to display all events, if it gets selected $scope.filtro.juez is null and thus is not filtered.

We could also have used the filter function like this

eventRender: function (event, element) {
                    var audiencia = event.audiencia;
                    var display = true;
                    if($scope.filtro.juez){
                        display = audiencia.jueces.filter(function(juez){
                            return $scope.filtro.juez.id === juez.id;
                        }).length > 0;
                    }
                    if(!display){
                        return false;
                    }
}...

it depends on your preference and the readability of the code.

sources:
https://stackoverflow.com/questions/6641355/jquery-fullcalendar-event-filtering
https://fullcalendar.io/docs/