The imported class is there but Eclipse won't see it.
Try: Project --> Clean
Wednesday, December 22, 2010
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
Subscribe to:
Posts (Atom)