Saturday, August 28, 2010

Spring IDE "Build is incomplete" and

I use sts 2.3.2 and always got "Build path is incomplete" issues. And I found this was caused by this exception:

at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(
at java.lang.reflect.Constructor.newInstance(Construc
at java.lang.Class.newInstance0(
at java.lang.Class.newInstance(
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AspectDefinitionMatcher.initAspectJE xpressionPointcut( )
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AspectDefinitionMatcher.createAspect JPointcutExpression( 86)
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AspectDefinitionMatcher.internalMatc hes(
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AspectDefinitionMatcher.matches(Aspe
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob$1.doWith ActiveProjectClassLoader(AopReferenceModelBuilderJ
at $DefaultProjectClassLoaderSupport.executeCallback(
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob.buildAop ReferencesForBean( :209)
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob.buildAop ReferencesForBeans(AopReferenceModelBuilderJob.jav a:281)
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob.buildAop ReferencesForBeansConfig(AopReferenceModelBuilderJ
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob.buildAop ReferencesFromBeansConfigSets(AopReferenceModelBui
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob.buildAop ReferencesForFile( :353)
at org.springframework.ide.eclipse.aop.core.internal. model.builder.AopReferenceModelBuilderJob.buildAop Model(
at org.springframework.ide.eclipse.aop.core.internal.
at ava:55)
Caused by: org.apache.commons.logging.LogConfigurationExcepti on: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.
at org.apache.commons.logging.impl.LogFactoryImpl.dis coverLogImplementation(
at Instance(
at org.apache.commons.logging.impl.LogFactoryImpl.get Instance(
at org.apache.commons.logging.impl.LogFactoryImpl.get Instance(
at org.apache.commons.logging.LogFactory.getLog(LogFa
at p.aspectj.AspectJExpressionPointcut.(Aspec
... 20 more

Even upgrading to 2.3.3.M3 didn't help.

And I found org.apache.commons.logging.impl.Log4JLogger was not in
.metadata/.plugins/org.springframework.ide.eclipse.osgi.targetdefinition/ That explains why the exception happens.

My project uses to config log4j with this line,


I tried to remove the dependency of common-logging, and from my maven project, and cleaned all maven projects to remove from target/classes and target/test-classes.

Then everything become ok. No "Build path is incomplete" any more.

Unfortunately, I couldn't reproduce it when I put back to the project, and built the maven project.

I guess somehow was picked by SPRING IDE.

Friday, August 27, 2010

My Cygwin/Xwin settings

This is my ~/.Xdefaults file:

Xft.dpi: 96.0
Xft.hinting: 1
Xft.rgba : rgb
Xft.antialias: 1
Xft.hintstyle: hintfull

XTerm*faceName: Bitstream Vera Sans Mono
XTerm*faceSize: 10
XTerm*scrollBar: True
XTerm*rightScrollBar: True
XTerm*renderFont: True

URxvt*background: #EFFFEF
URxvt*foreground: #000000
URxvt.font: xft:Bitstream Vera Sans Mono:size=10:light:roman:antialias=true,xft:NSimSun:size=16:medium:antialias=true
URxvt*boldFont: xft:Bitstream Vera Sans Mono:size=10:bold:roman:antialias=true,xft:SimHei:size=16:medium:antialias=true
URxvt*italicFont: xft:Bitstream Vera Sans Mono:size=10:medium:italic:autohint=true:antialias=true
URxvt*boldItalicFont: xft:Bitstream Vera Sans Mono:size=10:bold:italic:autohint=true:antialias=true
URxvt.scrollBar: True
URxvt.scrollBar_right: True
URxvt.Shading: 50
URxvt.fading: 50

Friday, August 6, 2010

Without cropping in Cygwin Xwin during switch monitors

I have a laptop with a LCD 1400x900 and a monitor with 1280x1024 connecting to the dock. When I dock and undock the laptop, my Cygwin Xwin always has something cropped. XWin doesn't change the resolution automatically, and I cannot use xrandr to change it too. For example, after starting xwin using LCD, and docking the laptop, xrandr still returns:

bash-3.2$ xrandr -q
Screen 0: minimum 1440 x 900, current 1440 x 900, maximum 1440 x 900
default connected 1440x900+0+0 0mm x 0mm
1440x900 0.0*

and the following command will fail because the size can only be 1440x900.

bash-3.2$ xrandr -fb 1280x1024

This is annoying because I have to restart xwin after switching the monitor. Finally I found this thread solved my problem.

add the following options into /usr/bin/startx

serverargs="-screen 0 1440x1024x32 -multiwindow -clipboard"

Basically it creates a screen large enough to cover any monitor.

Thursday, August 5, 2010

Use mock_model outside of Rails

I want to use RSpec's mock_model outside of Rails, but only found this mail thread.

Actually it is not hard to use mock_model without rails. You need to install rspec-rails, and active_record gem first. Here is an example,

require 'active_support/core_ext/hash'
require 'spec/rails/mocks'
include Spec::Rails::Mocks

class TestTable

class View
def initialize(table)
@table = table

def print_keys
"name is #{} #{@table.class.primary_keys.join(",")}"

def print_name
"name is #{}"

describe "TestTable" do
before do
table = mock_model(TestTable, :name=>"table_abc")
@view =

it "should fail the expectation check" do
TestTable.should_receive(:primary_keys).and_return(["pk1", "pk2"])
@view.print_keys.should == "name is table_abc"

it "should complain that no primary_keys is called" do
TestTable.should_receive(:primary_keys).and_return(["pk1", "pk2"])
@view.print_name.should == "name is table_abc"

it "should print the table name" do
@view.print_name.should == "name is table_abc"

it "should print the table name and keys" do
TestTable.should_receive(:primary_keys).and_return(["pk1", "pk2"])
@view.print_keys.should == "name is table_abc pk1,pk2"