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, October 24, 2011
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.
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.
Labels:
graphics,
imagemagick,
linux,
mogrify,
resize
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:
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:
- 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
- Add -Dorg.eclipse.swt.browser.UseWebKitGTK=true to the -vmargs options in eclipse.ini
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
> 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.)
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 (updated after kind comment):
If you don't want to perform this extra step (updated after kind comment):
- Install: yum install gnome-shell-extensions-alternative-status-menu.
- Type Alt-F2 then gnome-tweak-tool
- Go to Shell Extensions --> Alternative Status Menu Extension and switch it to on
- Type Alt-F2 then r and enter (reloads the Gnome shell.)
- You're set! You have gained the Hibernate and Power off options now.
Fedora 15: Add Back Window Buttons
UPDATED on May 9, 2020
Gnome 3 default behavior suppresses all window buttons but the Close. If you want them back:
> gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"
or use: gnome-tweak-tool.
References:
Wednesday, December 22, 2010
Eclipse Error: "Import Cannot Be Resolved"
The imported class is there but Eclipse won't see it.
Try: Project --> Clean
Try: Project --> Clean
Thursday, November 25, 2010
Creating a SVN Repository
Create the repository
> svnadmin create svnrepo
> gedit svnrepo/conf/svnserve.conf
Enable the following lines:
anon-access = none
auth-access = write
password-db = passwd
> gedit svnrepo/conf/passwd
Edit/add user
Create project directory:
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project/trunk
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project/branches
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project/tags
Import the project:
> svn -m "Your comment" import /path-to-source/sample-project file:///path-to-svnrepo/svnrepo/sample-project/trunk
Prepare work location:
> mkdir sampleProject
> cd sampleProject
Local check out trunk of project (without the folder itself):
> svn co file:///data/svnrepo/sample-project/trunk/ .
Remote check out (using SVN + SSH protocols):
> svn co svn+ssh://user@host/path-to-svnrepo/svnrepo/sample-project/trunk/ .
Create user and group svn:
> useradd svn
Add group svn to your groups.
Change ownership of all files in svnrepo/db to svn:
> chown -r svn:svn *
Add write permissions to all files in svnrepo/db.
> svnadmin create svnrepo
> gedit svnrepo/conf/svnserve.conf
Enable the following lines:
anon-access = none
auth-access = write
password-db = passwd
> gedit svnrepo/conf/passwd
Edit/add user
Create project directory:
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project/trunk
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project/branches
> svn -m "Your comment" mkdir file:///data/svnrepo/sample-project/tags
Import the project:
> svn -m "Your comment" import /path-to-source/sample-project file:///path-to-svnrepo/svnrepo/sample-project/trunk
Prepare work location:
> mkdir sampleProject
> cd sampleProject
Local check out trunk of project (without the folder itself):
> svn co file:///data/svnrepo/sample-project/trunk/ .
Remote check out (using SVN + SSH protocols):
> svn co svn+ssh://user@host/path-to-svnrepo/svnrepo/sample-project/trunk/ .
Create user and group svn:
> useradd svn
Add group svn to your groups.
Change ownership of all files in svnrepo/db to svn:
> chown -r svn:svn *
Add write permissions to all files in svnrepo/db.
Monday, November 22, 2010
Microphone Not Working in Fedora 14
If your microphone is not working on your new installation, just try this. It worked for me:
- Go to System --> Preferences --> Sound
- Select the input tab
- Switch from the existing configured microphone (probably microphone 1) to another one (microphone 2)
- Close the application and everything should work ;-)
Friday, November 19, 2010
Spring Property Editor for an Enumeration with Localized Names
Problem statement:
while the setAsText() method does not:
This is because Spring implicitly uses the enumeration name for the value of your tag, not the translated name.
E.g. If you have a select tag, this is what Spring does for you:
It makes sense, of course...
- You use a property editor when you bind a nested Enumeration field of a form backing object.
- You have localized names for the values.
@Override
public String getAsText() {
if(getValue() == null) {
return null;
}
SurveyStatus status = (SurveyStatus)getValue();
return status.getTranslatedName();
}
while the setAsText() method does not:
@Override
public void setAsText(String surveyStatusStr) {
if (logger.isDebugEnabled()) {
logger.debug("Read string [" + surveyStatusStr + "] for the survey status field");
}
SurveyStatus status = null;
if (surveyStatusStr.compareTo(SurveyStatus.ACTIVE.toString()) == 0) {
status = SurveyStatus.ACTIVE;
}
else if (surveyStatusStr.compareTo(SurveyStatus.INACTIVE.toString()) == 0) {
status = SurveyStatus.INACTIVE;
}
setValue(status);
}
This is because Spring implicitly uses the enumeration name for the value of your tag, not the translated name.
E.g. If you have a select tag, this is what Spring does for you:
<option value="ACTIVE" ... >
It makes sense, of course...
Labels:
binding,
property editor,
spring framework
Wednesday, September 15, 2010
Grep Selected Files
You can use find and grep to search for a particular string (string_pattern) in a selection of files:
> find <dir> -name "<file_find_pattern>" -exec grep -H -n '<string_pattern>' {} \;
> find <dir> -name "<file_find_pattern>" -exec grep -H -n '<string_pattern>' {} \;
Thursday, September 09, 2010
Spring Open View In Session Pattern For Portlets
I needed to implement the Open Session In View pattern for a portlet using Spring (3 with annotations) and Hibernate.
This pattern allows lazily loaded objects to have access to the Hibernate Session for the entire processing of the render request despite the original transaction (associated to the portlet request) already being completed.
I.e. If you have One To Many associations, this allows you to load the Many side of the association in the same thread of the request where you loaded the One side.
What I needed to do is:
Add a WebRequestHandlerInterceptorAdapter interceptor wrapping the stantard OpenSessionInViewInterceptor to applicationContext.xml:
then add it to the DefaultAnnotationHandlerMapping in yourPortlet-portlet.xml:
This pattern allows lazily loaded objects to have access to the Hibernate Session for the entire processing of the render request despite the original transaction (associated to the portlet request) already being completed.
I.e. If you have One To Many associations, this allows you to load the Many side of the association in the same thread of the request where you loaded the One side.
What I needed to do is:
Add a WebRequestHandlerInterceptorAdapter interceptor wrapping the stantard OpenSessionInViewInterceptor to applicationContext.xml:
<bean name="openSessionInViewInterceptor"
class="org.springframework.web.portlet.handler.WebRequestHandlerInterceptorAdapter">
<constructor-arg>
<bean class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</constructor-arg>
</bean>
then add it to the DefaultAnnotationHandlerMapping in yourPortlet-portlet.xml:
<bean id="annotationMapper"
class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="10" />
<property name="interceptors">
<list>
<ref bean="openSessionInViewInterceptor"/>
</list>
</property>
</bean>
Labels:
annotations,
hibernate,
open session in view,
spring framework
Wednesday, May 12, 2010
Fedora: Receiving Files Over a Bluetooth Connection
This post refers to receiving files from a phone to a computer over a Bluetooth connection.
Please refer to the official Fedora documentation for installation and initial configuration:
Then you have to enable the bluetooth file sharing service.
If you can't find the link to the application in Applications --> System Tools, then create the link yourself or launch the following command manually:
> gnome-file-share-properties&
Enable Receive Files over Bluetooth.
Go to your phone and send the file to your computer.
Please refer to the official Fedora documentation for installation and initial configuration:
Then you have to enable the bluetooth file sharing service.
If you can't find the link to the application in Applications --> System Tools, then create the link yourself or launch the following command manually:
> gnome-file-share-properties&
Enable Receive Files over Bluetooth.
Go to your phone and send the file to your computer.
Friday, April 16, 2010
Hibernate ManyToOne Association With Annotations
It took me a while to get rid of a:
ERROR org.hibernate.util.JDBCExceptionReporter -
Unknown column 'applicatio0_.domain_domainID' in 'field list'
on a simple many-to-one association.
I had an Application object with a Domain field where many Applications could have the same Domain (standard many-to-one association).
The annotations on the field were:
Class Domain started with:
Hibernate couldn't correctly map the domain ID until I added the JoinColumn annotation:
which in my opinion could be inferred from class Domain:
but it wasn't.
Always use JoinColumn.
ERROR org.hibernate.util.JDBCExceptionReporter -
Unknown column 'applicatio0_.domain_domainID' in 'field list'
on a simple many-to-one association.
I had an Application object with a Domain field where many Applications could have the same Domain (standard many-to-one association).
The annotations on the field were:
@ManyToOne(cascade = CascadeType.ALL)
public Domain getDomain() {
return domain;
}
Class Domain started with:
@Entity
@Table(name="domain")
public class Domain implements Serializable {
// DB name: domainID
private Long id;
private String name;
Hibernate couldn't correctly map the domain ID until I added the JoinColumn annotation:
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="domainID")
public Domain getDomain() {
return domain;
}
which in my opinion could be inferred from class Domain:
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "domainID", unique = true,
updatable = false, nullable = false)
public Long getId() {
return this.id;
}
but it wasn't.
Always use JoinColumn.
Thursday, March 11, 2010
Creating a Movie from Images (Linux)
The short story at this time. These instructions refer to the creation of MPEG4 video from JPGs images on Linux.
You need mencoder, part of the mplayer software.
Type:
> mencoder mf://<PATH>/*.jpg -mf w=320:h=240:fps=12:type=jpg
-ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell
-oac copy -o output.avi
Where you should customize at least:
You need mencoder, part of the mplayer software.
Type:
> mencoder mf:/
-ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell
-oac copy -o output.avi
Where you should customize at least:
- <PATH>/
*.jpg is the path to the directory where your JPGs are. - w=320:h=240 is the image size.
- output.avi is the resulting file name
Monday, March 08, 2010
Eclipse: Copying Preferences To a New Workspace
When I create a new workspace in Eclipse what I want every time is to have all my preferences from the other workspaces, first of all the color preferences. There is no apparent option in Eclipse to do that. File --> Import --> Preferences won't do that. Maybe it's hidden somewhere else.
I found an easy way to do that: simply copy the settings directory to the new workspace.
Preferences are stored in each workspace in:
/.metadata/.plugins/org.eclipse.core.runtime/.settings
Shut down Eclipse.
Copy part or the entire contents of that directory to the corresponding directory of the new workspace (after you've created it, of course).
Restart and you're done!
I found an easy way to do that: simply copy the settings directory to the new workspace.
Preferences are stored in each workspace in:
Shut down Eclipse.
Copy part or the entire contents of that directory to the corresponding directory of the new workspace (after you've created it, of course).
Restart and you're done!
Monday, March 01, 2010
Turning a SVN Project into a SVN/Java Project
This will be needed for a Java project created with the type "from SVN source". It will not have a Java nature by default.
Add a Java nature to the project in .project:
Create the file .classpath with the JDK/JRE libraries (and optionally the default output directory):
This method is alternative to the one detailed here.
Add a Java nature to the project in .project:
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Create the file .classpath with the JDK/JRE libraries (and optionally the default output directory):
Then you might want to add to the classpath the libraries which could not be detected at creation time.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
This method is alternative to the one detailed here.
Eclipse: Hiding Internal JARs
If you need to hide all the internal libraries your project is using, you can do so from the Package Explorer:
- Choose the view menu
- Check Show referenced libraries node
Tuesday, July 28, 2009
Eclipse Losing Reference to JARs
I have this weird problem that every once in a while (especially upon checking in files to SVN/CVS but not limited to that situation) Eclipse will lose reference to class path JARs and start signalling errors everywhere in the code.
What I temporarily did to fix this was to remove a library directory from the [Project] Properties --> Java Build Path --> Source list of a project, save the properties, open them again and add it back in. Problem gone... for a while.
Now I'm trying something I read somewhere: start Eclipse with the -clean command line parameter.
I'll keep you posted...
Feb 2010 Update: with the current version of Eclipse I'm using (Eclipse Java EE IDE for Web Developers, Build id: 20100218-1602) this issue seems to be vanished.
What I temporarily did to fix this was to remove a library directory from the [Project] Properties --> Java Build Path --> Source list of a project, save the properties, open them again and add it back in. Problem gone... for a while.
Now I'm trying something I read somewhere: start Eclipse with the -clean command line parameter.
I'll keep you posted...
Feb 2010 Update: with the current version of Eclipse I'm using (Eclipse Java EE IDE for Web Developers, Build id: 20100218-1602) this issue seems to be vanished.
Subscribe to:
Posts (Atom)