Spring 3 ASM – Spring asm Dependency

Posted: March 16, 2012 in Java Posts
Tags:

ASM Vénissieux

In earlier version of Spring (Spring version 2.5) the asm library was included. But the current version of Spring 3 does not contains the asm library. So, you have to download and add the asm library to your project.

In this section you will find the instruction to download and add the asm library into your project.

What is ASM?

The ASM is very small framework that is used to analyze and manipulate Java byte codes. It is used in Spring 3 framework to dynamically modify the Java bytecode and generate the new bye code in runtime. The ASM framework is easy to use and fast. Its performance is good. You can read more about the asm framework at http://asm.ow2.org/. The latest version of asm library can be downloaded from http://asm.ow2.org/download/index.html. If you getting any error in your Spring framework then you can get the latest version of asm library from the asm official website.

If you don’t include the asm dependency in your Spring 3 project you might get the following error:

Jan 2, 2010 2:49:26 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh

INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1a05308:
startup date [Sat Jan 02 14:49:26 IST 2010]; root of context hierarchy

Exception in thread “main” java.lang.IllegalStateException: Cannot load configuration class: net.roseindia.Spring3HelloWorldConfig

at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfiguration
Classes(
ConfigurationClassPostProcessor.java:274)

at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBean
Factory(
ConfigurationClassPostProcessor.java:147)

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPost
Processors(
AbstractApplicationContext.java:624)

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactory
PostProcessors(
AbstractApplicationContext.java:614)

at org.springframework.context.support.AbstractApplication
Context.refresh(
AbstractApplicationContext.java:398)

at org.springframework.context.annotation.Annotation
ConfigApplicationContext.<init>(
AnnotationConfigApplicationContext.java:65)

at net.roseindia.Spring3HelloWorldConfigTest.main(Spring3HelloWorldConfigTest.java:9)

Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type

at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)

at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)

at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)

at org.springframework.context.annotation.ConfigurationClass
Enhancer.newEnhancer(
ConfigurationClassEnhancer.java:101)

at org.springframework.context.annotation.Configuration
ClassEnhancer.enhance(
ConfigurationClassEnhancer.java:89)

at org.springframework.context.annotation.Configuration
ClassPostProcessor.enhanceConfigurationClasses(
ConfigurationClassPostProcessor.java:266)

… 6 more

Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

… 12 more

If you are using the maven to for development of your project then following entry can be added to pom.xml
<dependency>
<groupId>asm</groupId>
<artifactId>asm-commons</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>2.2.3</version>
</dependency>

The above dependency entry will add include asm library into your project.

Advertisements
Comments
  1. […] Spring 3 ASM – Spring asm Dependency (shanisk.wordpress.com) […]

    Like

  2. Calling Constructor in Spring « Zeeshan Akhter says:

    […] Spring 3 ASM – Spring asm Dependency (shanisk.wordpress.com) […]

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s