Monday, January 30, 2012

hbm2ddl SchemaExport: You have an error in your SQL syntax near type=InnoDB

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB'

I used to create my MySQL DBs with ant and everything was working. Now, moving to maven and hbm2ddl I get this error.
After some searching it comes out that it's a problem of incompatibility between the MySQL Java connector (5.1) and the MySQL version (5.5) where type InnoDB was dropped and replaced with engine.

On Fedora, the easy solution is to downgrade MySQL to version 5.1 (download the RPMs from MySQL web site)

More details here.

Wednesday, November 09, 2011

Maven + Subversion Enabled Eclipse Java Project

What I want for my Eclipse projects is to be Java projects, allow content revisions with Subversion and be managed by Maven.

This is what I need to do.

Eclipse version: Eclipse Indigo
Subversion plugin: Subversive
Maven plugin: m2eclipse
Java: JDK 1.6

Support for Subversion and Maven is now integrated into Eclipse.
  1. Choose Help --> Install new software --> Work with: Indigo - http://download.eclipse.org/releases/indigo
  2. Expand collaboration and check the m2eclipse and Subversive packages.
  3. Configure the Maven repository here: Window --> Preferences --> Maven --> Installations.
Now you need the Maven SCM handler for Subversive.
  1. The easy way is to create a fake new project from File --> new project --> New Project wizard
  2. Select the project type: Maven --> Checkout Maven Projects from SCM
  3. In the target location dialog box select the m2e marketplace in the right bottom corner.
  4. When you are presented with the list of connectors, the m2e-subversive is the the last one.
  5. Once Eclipse has restarted, you can choose again to create a project through Maven --> Checkout Maven Projects from SCM and this time you will be able to specify a SCM URL (svn) and fill in the URL.
Now you have a project checked out from a Subversion repository which uses a Maven repository to manage its library dependencies.

References
  1. The place where I found the final answers is Ralph's Java blog.

Monday, October 24, 2011

Liferay: Error Registering Portlets

I got a problem when trying to undeploy a portlet on Liferay the standard way: removing the unzipped WAR in Tomcat's webapps/ dir and the cached information.

08:48:56,725 ERROR [HotDeployUtil:112] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for MyPortlet

It seemd like the portlet was somehow still in the page for Liferay and the message saying the portlet needed to be removed from the page did not show any buttons to do that. After a while I didn't have the message anymore but only an error page.

Some googling brought me on a page in the Liferay forum where they suggested to remove the portlet-api-2.0.jar from the lib/ directory of the WAR and redeploy it:

> zip -d MyPortlet.war /WEB-INF/lib/portlet-api-2.0.jar

It actually worked. Don't ask me why.

Monday, August 08, 2011

Batch Resize on Linux

Install imagemagick.
Now you can use mogrify.
Example: to resize to half the original size all the JPGs in a directory (keeping the aspect ratio of course):

> mogrify -resize 50% *.jpg

More here.

Eclipse Startup - Crash on Fedora 15

For some obscure reason, the Fedora 15-packaged Eclipse doesn't include JSP syntax highlighting and I could find no easy way to add it (conflicting dependencies prevent that). So I resorted to the original TAR-GZ distribution. The problem there is with the OpenJDK. My Eclipse simply crashes on startup.
What you need to do is tell Eclipse to use Sun's JDK.
Open the eclipse.ini and add the path to the Java executable:

-vm
/opt/java/jdk1.6.0/bin/java

right before the -vmargs option.
More here.

[UPDATE] - Oh, the reason for the crash is not openJDK. It's a bug in Fedora. To circumvent it do the following:
  1. In Gnome3 the webkit library name changed to libwebkitgtk so you need to create one missing symbolic link: ln -s /usr/lib/libwebkitgtk-1.0.so.0 /usr/lib/libwebkit-1.0.so.2
  2. Add -Dorg.eclipse.swt.browser.UseWebKitGTK=true to the -vmargs options in eclipse.ini
More here.

Friday, July 01, 2011

Extracting Audio from Video or Stream

From AVI or other video formats:
> ffmpeg -i file_name.avi -ab 128 -ar 44100 file_name.mp3

From an online stream:
> ffmpeg -i URL_address -ab 128 -ar 44100 file_name.mp3

> man ffmpeg

Wednesday, June 15, 2011

Fedora 15: Old and New Alt-Tab Behavior

As of Fedora 14 (Gnome 2.32) the behavior of Alt-Tab was to cycle through all the windows of all the open applications in a virtual workspace.
Gnome 3 shipping with Fedora 15 behaves differently and probably more efficiently (time will tell.)

Alt-Tab now cycles through all open applications in all virtual workspaces. All the windows of an application are shown when that application is the selected one. You can move the mouse over one window and select it but you can't just use the keyboard to do that.

If you want to cycle through all the windows of the active (selected) application you need to use Alt-~ (or the button above Tab.)

Fedora 15: Add Back Shutdown Option

Gnome 3 by default won't show the shutdown button. To see it click on your name on the top bar and press Alt. The Suspend option will turn into Power off.
If you don't want to perform this extra step:
  1. Install: yum install gnome-shell-extensions-alternative-status-menu.
  2. Type Alt-F2 then r and enter (reloads the Gnome shell.)
  3. You're set! You have gained the Hibernate and Power off options now.
Credits.

Fedora 15: Add Back Window Buttons

UPDATED
Gnome 3'default behavior suppresses all window buttons but the Close. If you want them back:
  1. Install gconf-editor: yum install gconf-editor
  2. Run it and go to desktop --> gnome --> shell --> windows
  3. Set the value to "menu:minimize:maximize:close"
  4. Type ALT-F2 then r and enter (reloads the Gnome shell) or you will see the modifications once you log out and then back in.
  5. You're done!
Credits.

Wednesday, December 22, 2010

Eclipse Error: "Import Cannot Be Resolved"

The imported class is there but Eclipse won't see it.
Try: Project --> Clean