Tuesday, May 17, 2016

Ubuntu on VirtualBox - Mount a vdi drive on startup

Hi, I had Ubuntu 14.04 running on VirtualBox and needed more storage. A solution was an old vdi with enough space available, but... only available after login.

The drive was mounted using:

gvfs-mount -d /dev/sdb3

that's the command line equivalent of clicking on drive icon to mount it, after login.
 I needed the drive already mounted at login time.

Fstab didn't work because virtualbox is loaded after it.

Solution:

1 - Discover the device of your drive (sdb3 in my case):
     sudo fdisk -l

2 - Make a folder to mount your drive:
     mkdir /media/adminuser/mydrive

2 - Edit rc.local
     sudo -H gedit /etc/rc.local

3 - Add a line before exit 0
    mount -t ext4 /dev/sdb3 /media/adminuser/mydrive

4 - Save and reboot.

Good luck!
PS: More info here

Wednesday, February 25, 2015

Enabe JMX on Jetty

Quick and dirty:

$ export JMX_OPTS = -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.port=8090 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
$ java $JMX_OPTS -jar start.jar etc/jetty-jmx.xml etc/jetty.xml


Just for testing, for production system ssl and user authentication must be enabled.

Monday, February 16, 2015

Tomcat doesn't starts on boot (Yosemite) or launchctl operation already in progress

After Yosemite, Tomcat installation refused to start on boot. When trying to start it manually, using:

sudo launchctl load /Library/LaunchDaemons/org.apache.tomcat.plist


failed with message:

launchctl operation already in progress


It took me a while to discover that:

  • launchctl has changed a lot after Yosemite (and you need to read the only available documentation, man launchctl)
  • most commands (like load) are in deprecated mode
  • all tomcat files where with "@" extended attribute (ls -l@ gives a list with extended attributes) meaning that are signed with "com.apple.quarantine" (you need to approve execution explicitly on the first run)
  • the command:

    launchctl print-disabled system


    lists org.apache.tomcat as disabled

Solution:
- Remove the quarantine attribute
xattr -r -d com.apple.quarantine /opt/servers/Tomcat/TomcatHome

- Enable service
sudo launchctl enable org.apache.tomcat

- Add service to the system domain
sudo launchctl bootstrap system /Library/LaunchDaemons/org.apache.tomcat.plist

Monday, February 2, 2015

Enable Java Web Start lauching for JNLP files, also Firefox


In a terminal, type the following command, then press Return:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister "/System/Library/CoreServices/Java Web Start.app"


To enable Firefox to launch JNLP files, open Firefox menu:
Preferences -> Applications ->JNLP Files -> Use other...
Search for /System/Library/CoreServices/Java Web Start

Wednesday, January 14, 2015

Compiling mod_jk on Mac OS X 10.10 (Yosemite)

First, check that you have the most recent version of XCode and the command line tools.
Second, solve the "configure: error: C compiler cannot create executables" problem.
As Adrian Rodriguez says here :
"Some packages like mod_jk use /usr/sbin/apxs -q CC in configure to ask for the C compiler. APXS spits it out, but it has the wrong path so that's why you keep getting errors."

Solution, make a symlink:

cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.10.xctoolchain


After that, download the last version of connectors Source Release tar.gz from here, expand it and go to the native folder.


cd /tmp

wget http://ftp.unicamp.br/pub/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
tar xvf tomcat-connectors-1.2.40-src.tar.gz
cd tomcat-connectors-1.2.40-src/native

./configure --with-apxs=/usr/sbin/apxs
make


The BUILDING.txt file, has details and must be read:

"The resulting module file mod_jk.so of mod_jk will be
located in the directory apache-2.0 (for any version
of Apache 2.x) respectively apache-1.3 (for Apache 1.3).

Simply copy the file to your web server modules or libexec
directory.
"

Result of compiling can be found on native/apache-2.0, to install:


sudo cp apache-2.0/mod_jk.so /usr/libexec/apache2/

# Clean the work area
cd /tmp
rm -r rm -r tomcat-connectors-1.2.40-src
rm tomcat-connectors-1.2.40-src.tar.gz



Saturday, August 2, 2014

Install Libreplan on MySql


Install Libreplan on MySql


This instructions assume that you have already installed MySql, Tomcat is installed at <TOMCAT_HOME> and is the first libreplan installation.
Stop Tomcat:

$ sudo launchctl unload /Library/LaunchDaemons/org.apache.tomcat.plist
Download libreplan mysql version from https://sourceforge.net/projects/libreplan/files/LibrePlan/:

install_mysql_1.4.0.sql
libreplan_mysql_1.4.0.war

Download MySql JDBC driver from here - MySQL JDBC Driver Download Here.
Move the mysql-connector-java-5.1.31-bin.jar (or newer version) to <TOMCAT_HOME>/lib folder.

Open a terminal on the folder where you downloaded the install_mysql_1.4.0.sql and libreplan_mysql_1.4.0.war files.

Log on MySql and create a user and a database for libreplan. Then switch to the new database and run the install_mysql_1.4.0 script:

$ mysql mysql -u root
mysql>
mysql> CREATE USER 'libreplan'@'localhost' IDENTIFIED BY 'libreplan';
Query OK, 0 rows affected (0.23 sec)

mysql> CREATE DATABASE libreplan;
Query OK, 1 row affected (0.09 sec)

mysql> GRANT ALL ON libreplan.* TO 'libreplan'@'localhost';
Query OK, 0 rows affected (0.23 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.23 sec)

mysql> connect libreplan;
Connection id:    91
Current database: libreplan

mysql> \. install_mysql_1.4.0.sql
Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.12 sec)

...(a lot of this until the end of the script)...

Query OK, 0 rows affected (0.19 sec)
Records: 0  Duplicates: 0  Warnings: 0

Query OK, 1 row affected (0.01 sec)

mysql> exit

Edit the context xml file: <TOMCAT_HOME>/conf/context.xml and add the following content after <Context> tag:

<Resource name="jdbc/libreplan-ds" auth="Container"
         type="javax.sql.DataSource"
         driverClassName="com.mysql.jdbc.Driver"
         url="jdbc:mysql://localhost:3306/libreplan"
         username="libreplan"
         password="libreplan"
         maxActive="100"
         maxIdle="30"
         maxWait="10000"
         validationQuery="Select 1" />


Copy the libreplan war file renaming it to libreplan.war. This is important or your url will be: http://localhost:8080/libreplan_mysql_1.4.0/
$ cp libreplan_mysql_1.4.0.war <TOMCAT_HOME>/webapps/libreplan.war

Start Tomcat:

$ sudo launchctl load /Library/LaunchDaemons/org.apache.tomcat.plist

You will find LibrePlan at:

http://localhost:8080/libreplan

Friday, December 6, 2013

Compiling mod_jk on Mavericks -



Compiling mod_jk on Mavericks




After the upgrade to Mavericks and solving SVN problems, the Apache Server refused to start with a message:
"Job appears to have crashed: Abort trap: 6"

Looking at the log, I discovered that the Apache Tomcat Connector "mod_jk" aborts with a log message: detected source and destination buffer overlap.

This is a bug on the Apache Connector as stated here and not solved until the current version (tomcat-connectors-1.2.37).

The most simple solution is to modify the tomcat-connectors-1.2.37-src/native/common/jk_map.c file, changing the following lines, at the jk_map_get_int(..) method at line 184.

The original code:

int jk_map_get_int(jk_map_t *m, const char *name, int def)
{
    char buf[100];
    const char *rc;
    size_t len;
    int int_res;
    int multit = 1;

    sprintf(buf, "%d", def);
    rc = jk_map_get_string(m, name, buf);


After edition (changes in bold):

int jk_map_get_int(jk_map_t *m, const char *name, int def)
{
    char buf[100];
    char buf2[100];
    const char *rc;
    size_t len;
    int int_res;
    int multit = 1;

    sprintf(buf2, "%d", def);
    rc = jk_map_get_string(m, name, buf2);

Just recompile/install as indicated in my blog about Tomcat/Pentaho installation.