Posts Tagged ‘Maven’
Change settings.xml location
Case
You have to use a custom-set settings.xml file, rather the default one.
By default, settings.xml is assumed to be in one the two following folders:
$M2_HOME/conf/settings.xml
$HOME/.m2/settings.xml
Fix
Use the -s option, for instance:
mvn install -s /path/to/file/otherSettings.xml
Could not initialize class net.sf.cglib.proxy.Enhancer
Error
Compiling with Maven 2, you have:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [businessApplicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
Turning Spring logging level to DEBUG, you find:
DEBUG main org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver - Ignoring handler [org.springframework.scripting.config.LangNamespaceHandler]: problem with class file or dependent class
java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException
Fix
Add dependencies to Groovy, BSH and JRuby in your pom.xml:
[xml]
<dependency>
<groupId>groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b4</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
<version>0.9.8</version>
</dependency>
[/xml]
Try of Explanation
Spring depends on the three jars above. But Maven does not link your project to them.
How to test a single class in Maven?
Use the command:
maven test:single -Dtestcase=com.mypath.(...).MyUnitTest