• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Error in spring context.xml

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Every One,

I have class A with constructor argument as (URI uri, Image image), where URI is java.net.URI and Image is java.awt.Image. I am trying to configure it via spring as:



But error is thrown as : Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'a' defined in class path resource [/context.spring.xml]: Unsatisfied dependency expressed through constructor argument with index 1 of type [java.awt.Image]: Could not convert constructor argument value of type [java.lang.String] to required type [java.awt.Image]: Failed to convert value of type 'java.lang.String' to required type 'java.awt.Image'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.awt.Image]: no matching editors or conversion strategy found.

Please do provide your valuable suggestions.

Regards,
Looka
 
looka dicosta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any One ..Please Reply. Thanks in Advance
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moced form Swing / AWT / SWT.

looka dicosta wrote:Any One ..Please Reply. Thanks in Advance


Please EaseUp <- link
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
value="" in your constructor-arg.

value = means you want ot pass in that value, that exact String value

value="something" means the string "something" will be passed in.

If you want to reference another bean you use ref="" instead of value=""

value is value, ref is ref.

Mark
 
looka dicosta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks Mark. But for image if I create another bean like .

and change the above as : .

Then also I am getting errors.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, first you put

abstract="true"

This means that it is abstract and Spring will not create an object for you. Which means there is nothing to ref/inject in your other bean, hence an error.

You need would need to create a real Image instance if your constructor takes a class of that type. You can't pass a String for an Image, that is wrong types.

Mark

 
reply
    Bookmark Topic Watch Topic
  • New Topic