*
The moose likes Spring and the fly likes Error in spring context.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Error in spring context.xml" Watch "Error in spring context.xml" New topic
Author

Error in spring context.xml

looka dicosta
Greenhorn

Joined: Nov 22, 2012
Posts: 21
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

Joined: Nov 22, 2012
Posts: 21
Any One ..Please Reply. Thanks in Advance
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Moced form Swing / AWT / SWT.

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

Please EaseUp <- link


luck, db
There are no new questions, but there may be new answers.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
looka dicosta
Greenhorn

Joined: Nov 22, 2012
Posts: 21


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
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in spring context.xml
 
Similar Threads
hibernate 4 and spring 3.1.2 issue with LocalSessionFactoryBuilder
Problem in I18N in Spring
Spring WEB MVC 3.0 using org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport
Datasource url database name not known until after a Batch step
Declaring variable in Spring batch update SQL query