Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:46:34+00:00 2026-06-15T20:46:34+00:00

I am using Spring MVC Portlet and I have a problem. My app is

  • 0

I am using Spring MVC Portlet and I have a problem. My app is working properly while it have one bean. If I want to add another bean below error is occurring.

Error log is here;

ERROR [org.springframework.web.portlet.DispatcherPortlet] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addSinifController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.project.service.SinifService com.project.controller.AddSinifController.sinifService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySinifService' defined in file [/tmp/1-sample_BookCatalog/WEB-INF/classes/com/project/service/SinifService.class]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:280)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1011)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:543)
    at 
...

My application-context.xml ;

<context:annotation-config/>

<context:component-scan base-package="sample.code.listing" />
<context:component-scan base-package="com.project.controller" />
<context:component-scan base-package="com.project.domain" />
<context:component-scan base-package="com.project.service" />

<bean
    class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="webBindingInitializer">
        <bean
            class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
            <property name="propertyEditorRegistrars">
                <list>
                    <ref bean="myPropertyEditorRegistrar" />
                </list>
            </property>
        </bean>
    </property>
</bean>

<bean id="myPropertyEditorRegistrar" class="sample.code.listing.utils.MyPropertyEditorRegistrar"/>

<bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>content.Language-ext</value>
        </list>
    </property>
</bean>

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

My AddSinifController is here :

@Controller(value="addSinifController")
@RequestMapping(value="VIEW")
@SessionAttributes(types=Sinif.class)
public class AddSinifController {

    @Autowired
    @Qualifier("mySinifService")
    private SinifService sinifService;

    public SinifService getSinifService() {
        return sinifService;
    }

    public void setSinifService(SinifService sinifService) {
        this.sinifService = sinifService;
    }

    private Logger logger = Logger.getLogger(AddSinifController.class);

    @RenderMapping(params = "myaction=addsinif")
    public String showAddSinifForm(RenderResponse response,ModelMap model){
        return "addSinifForm";
    }

    @RenderMapping(params = "myaction=home")
    public String showhome(RenderResponse response,ModelMap model) {    
        return "home";      
    }

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(Long.class, new LongNumberEditor());

    }
    @ModelAttribute("sinif")
    public Sinif getCommandObject(){
        return new Sinif("sinif");
    }
    @ModelAttribute(value = "myaction=siniflar")
    public List<Sinif> getCommandObject2(){
        return sinifService.getSiniflar();
    }
    @ActionMapping(params="myaction=addSinif")
    public void addSinif(@ModelAttribute Sinif sinif,
            BindingResult bindingResult, ActionResponse response,
            SessionStatus sessionStatus){
            Kademe kademe = new Kademe("kademe");
            kademe.setId((long) 6);
            sinif.setKademe(kademe);
 }          
            sinifService.addSinif(sinif);
            response.setRenderParameter("myaction", "addsinif");
            sessionStatus.setComplete();

        if(!bindingResult.hasErrors()){
            System.out.println("hata yok");
            sinifService.addSinif(sinif);
            response.setRenderParameter("myaction", "addsinif");
            sessionStatus.setComplete();
        }else{
            response.setRenderParameter("myaction", "home");
        }
    }


}

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:46:36+00:00Added an answer on June 15, 2026 at 8:46 pm

    Give the same annotation

    @Qualifier("mySinifService")
    

    to the class implementing your SinifService interface, which you want to instantiate. Basically, the problem here is that when you ask Spring to autowire SinifService interface in the AddSinifController class, Spring doesnt know which implementation of the interface to be instantiated, when you have more than one class implementing your interface. By giving the @Qualifier annotation, you are referring to that particular bean which you want to be instantiated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

has any one using Spring MVC with Jquery! i have got a strange problem
I am using spring mvc portlet for one of my applications. I have a
I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
I want to make spring MVC 3.0.3 portlet using DispatcherPortlet class With JSON support.
I am using Spring MVC 3.1 to develop a Java web app. I have
I am using Spring MVC 3.0 I have a guestbook.jsp page where I want
I'm using Spring MVC 3.0 and Tomcat. I have a bean that has a
I'm using Spring MVC for a web app. I want to use OpenID for
Setup: I am using Spring-MVC in one of my project. I have to access
I am using spring mvc and spring security. In my security-app-context.xml I have: <authentication-manager>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.