3

I have a strange error which I searched about alot on the internet. I could not figure it why I am getting this error. I found some explanations about that error on spring jira. I have context:component-scan in applicationContext.xml and I defines 5 packages in com.sow.webservices package. However when I add the controller package including controller classes, I throws

Error occured processing XML '[Ljava.lang.String; cannot be cast to java.lang.String'. See Error Log for more details

This is component-scan:

<context:component-scan base-package="com.sow.webservices.aop, 
                                          com.sow.webservices.exceptions,
                                          com.sow.webservices.models, 
                                          com.sow.webservices.services,
                                          com.sow.webservices.controller">

I would like to show you whole exception trace. Appreciate for your help.

!ENTRY org.springframework.ide.eclipse.beans.core 1 0 2014-04-11 18:07:39.996
!MESSAGE Error occured processing '/SOW_WS/src/main/webapp/WEB-INF/applicationContext.xml'
!STACK 0
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String
    at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:92)
    at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:70)
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:247)
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
    at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1400)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1330)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:494)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:402)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:388)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:445)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Even if xml throws this exception I can run my application, but when I remove com.sow.webservices.controller it stops showing there is mistake sign but it gives 404 error. Since I am in trouble with component-scan, LocaleChangeInterceptor is not working and I can not internationalize my application

3
  • Just a thought, if these are the 5 packages you have and no filters, why don't you keep base package as "com.sow.webservices" instead of mentioning it all? Commented Apr 11, 2014 at 15:28
  • What version of Spring are you using? You mentioned Spring JIRA and, yes, there is, indeed, an issue reported and fixed (jira.spring.io/browse/SPR-11221). Have you tried with the Spring versions that fixed that JIRA issue? Commented Apr 11, 2014 at 15:30
  • @Prasad, it is still in development, I may have anohter package containing sometrhing under 'com.sow' instead of 'com.sow.webservices'. AndreiStefan , yes before I was using 4.0.2, But after reading that issue I moved on 4.0.3 Commented Apr 11, 2014 at 15:42

1 Answer 1

5

check your controllers, if one of them uses the annotation @ControllerAdvice try commenting it out and the weird thing is the error goes away. FREAKY!!!!

Sign up to request clarification or add additional context in comments.

3 Comments

wouw. you are right. it worked. However this time my app exception can not be catched by a controller which use @ ControllerAdvice and its methods use the @ ExceptionHandler annotation.
nice. this fixed my error which was just slightly different: java.lang.String; incompatible with java.lang.String
Ok but we need @ControllerAdvice, do you know how to replace it with an equivalent Spring XML configuration ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.