Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException

leave a comment »

ERROT:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException

STORY:
I was setting up a Spring powered web application for testing.
I edited the configurations files (*.xml) to add in some new configuration for testing / POC.
The following error is shown when I deployed the WAR file in tomcat
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 40 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'bean'. One of '{"http://www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":meta, "http://www.springframework.org/schema/beans":constructor-arg, "http://www.springframework.org/schema/beans":property, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.

SOLUTION:
As highlighted above, there is error in the mentioned XML file.
After I opened the XML file, I found that is some missed-closed bean definition ABOVE the mentioned line (Line 40 in XML).
The error bean definition as below:

<bean id="accountManager" class="alfred.sandbox.AccountManager">

Added in a BLACK SLASH “/” to close the bean definition properly will solve the error:

<bean id="accountManager" class="alfred.sandbox.AccountManager"/>

Written by Alfred

September 15, 2011 at 17:40

java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect

leave a comment »

ERROR:
Hits the error java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect when I try to start a webapp in tomcat.

STORY:
I was trying to add AOP to an existing web application. The AOP configuration I added is:

<aop:aspectj-autoproxy />

SOLUTION:
Add the AspectJ library to the classpath. The required AspectJ library are:
1. aspectjrt
2. aspectjweaver

My webapps is using Maven, so I added the dependencies to pom.xml as below:

<!-- AspectJ -->
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.6.11</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.6.11</version>
</dependency>

Written by Alfred

September 14, 2011 at 10:41

Linux | Find string in files

leave a comment »

Problem
I am trying to search for a string from the XML files (yup, more than an XML file)

Solution
I use grep with option “-an” which will print out the file name and line number of the found string.
The command below will search for text “my text” from all XML files in my current working directory.

grep -an "my text" *.xml

15 Practical GREP, resource

Written by Alfred

August 17, 2011 at 14:58

Posted in linux

Tagged with , , ,