Showing posts with label troubleshooting. Show all posts
Showing posts with label troubleshooting. Show all posts

Saturday, 23 April 2016

Debugging module installation on Drupal 7 with NetBeans

After following Configuring NetBeans, a very informative post on Drupal, I could still not debug my module on NetBeans 8.1. My main problem was that the breakpoints set on any of my module's files appeared as broken. In order to fix this, I needed to let NetBeans know which server request calls the module's code.

The Server request


Using Chrome's "Inspect" feature on the /admin/modules page after enabling my module and submitting the form, I found out that the module installation was being initiated by a POST request to "http://.../admin/modules/list/confirm".

I had created an apache virtual site to host it. On NetBeans, I included the whole Drupal 7 web tree as the project source (var/www/drupal7), and modified the project's Run Configuration accordingly (right click on the project's name > Properties):

NetBeans Project Properties - Run Configuration
Project Properties - Run Configuration
On the Advanced... settings window, I added the following Path Mapping:
  • Server Path: http://mylocalserver.local/admin/modules/list/confirm
  • Project Path: click on the ... and browse to the directory where your module is installed: /var/www/drupal7/sites/all/modules/my_module

Project Properties - Run - Advanced Web Configuration
Project Properties - Run Configuration - Advanced...


After this, the break points set on the files under .../my_module appeared and worked just fine.

Thursday, 22 January 2015

SQL Server Express 2014 for local connections

Amazingly, the default configuration for SQLServer Express does not enable local connections. To enable them:
  1. Open the Sql Server Configuration Manager. Available at All Programs > Microsoft SQL Server ... > Configuration Tools
  2. Under SQL Server Network Configuration > Protocols for SQLEXPRESS, enable Named Pipes and TCP/IP as needed.

Oh well.

Saturday, 15 June 2013

Java: chocking on unexpected BOM

I found myself needing to run a java application that reads its configuration from a properties file. This app extracts data from a database. From the configuration file it's supposed to read the url to connect to the database, username and password... amazingly, it would complain with a very cryptic error message:

ERROR: conect Database
java.sql.SQLException: No suitable driver found for
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)


What? no driver for ""... but the url is perfectly fine in the config file:
url=jdbc:oracle:thin://@localhost:1521/xe

After modifying the sources, recompiling the package, and running the new code to get the same error message... with extra debugging data I found out the source of the problem: JAVA!!!

Amazingly, if you edit the properties file in windows with the infamous notepad++, by default, it adds a useless and unnecessary BOM that makes java choke running the application or compiling the sources.

To be fair, adding a BOM to a UTF-8 encoded file is not necessary and not recommended by the standard, but I'd expect java to be more robust...