DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Frameworks
  4. Spring 3 and Apache Commons JCS Exception

Spring 3 and Apache Commons JCS Exception

Roger Hughes user avatar by
Roger Hughes
·
Jan. 27, 12 · Interview
Like (0)
Save
Tweet
Share
10.02K Views

Join the DZone community and get the full member experience.

Join For Free

I’ve seen a couple of projects in the last few months that have needed to cache data between requests. The developers, not wanting to write their own caching module, decided that Apache Commons JCS fitted the bill and added it to their Maven POM using the latest version:

<dependency>
    <groupId>jcs</groupId>
    <artifactId>jcs</artifactId>
    <version>1.3</version>
</dependency>  

Unfortunately, when the build ran, exceptions with the following key root causes:

Caused by: javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: 
Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@8034b6] does not support XML Schema. 
Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.

Caused by: java.lang.IllegalArgumentException: No attributes are implemented

...began to appear similar to those shown in the example below:

Tests run: 5, Failures: 0, Errors: 4, Skipped: 1, Time elapsed: 0.303 sec <<< FAILURE!
testSendFileStringOutputStream(com.configureconnect.cplayer.ImageGeneratorServiceTest)  Time elapsed: 0.105 sec  <<< ERROR!
org.unitils.core.UnitilsException: Unable to create application context for locations [test-beans.xml]
 at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:121)
 at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:36)
 at org.unitils.core.util.AnnotatedInstanceManager.getInstanceImpl(AnnotatedInstanceManager.java:234)
 at org.unitils.core.util.AnnotatedInstanceManager.getInstance(AnnotatedInstanceManager.java:121)
 at org.unitils.spring.util.ApplicationContextManager.getApplicationContext(ApplicationContextManager.java:65)
 at org.unitils.spring.SpringModule.getApplicationContext(SpringModule.java:222)
 at org.unitils.spring.SpringModule$1.isApplicableFor(SpringModule.java:104)
 at 

---- Lots of lines removed for readability....

 at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:592)
 at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
 at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from class path resource [test-beans.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@8034b6] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
 at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
 at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
 at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
 at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
 at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:117)
 ... 32 more
Caused by: javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@8034b6] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
 at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:102)
 at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
 ... 44 more
Caused by: java.lang.IllegalArgumentException: No attributes are implemented
 at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:98)
 at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:99)
 ... 46 more

From the stack trace, I believe that it was JCS’s dependency on xerces and other XML APIs that have caused the problem.


The classes from these libraries have been added to the Java SE SDK and improved upon, whilst xerces has also continued to grow, change and diverge. Hence, when compiling with Java 5 and greater, the xerces classes conflict with Java SE SDK creating the exception demonstrated above.

Possible Solutions

  • Don’t use JCS: this works!
  • Try excluding xerces using Maven. I haven’t tried this yet...
  • Upgrade to Spring 3.1

The version of Spring used was 3.0.5, but the Guys at Spring have been busy and recently released Spring 3.1, which comes with its own cache. I haven’t looked at this yet, but it’s worth investigating...

 

From http://www.captaindebug.com/2012/01/spring-3-and-apache-commons-jcs.html

Spring Framework

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Comparing Map.of() and New HashMap() in Java
  • Solving the Kubernetes Security Puzzle
  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud
  • Top 10 Best Practices for Web Application Testing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: