Note that there are some explanatory texts on larger screens.

plurals
  1. POAutowiring of fields failed exception
    primarykey
    data
    text
    <p>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.</p> <p>Error log is here;</p> <pre><code>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 ... </code></pre> <p>My application-context.xml ;</p> <pre><code>&lt;context:annotation-config/&gt; &lt;context:component-scan base-package="sample.code.listing" /&gt; &lt;context:component-scan base-package="com.project.controller" /&gt; &lt;context:component-scan base-package="com.project.domain" /&gt; &lt;context:component-scan base-package="com.project.service" /&gt; &lt;bean class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt; &lt;property name="webBindingInitializer"&gt; &lt;bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"&gt; &lt;property name="propertyEditorRegistrars"&gt; &lt;list&gt; &lt;ref bean="myPropertyEditorRegistrar" /&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="myPropertyEditorRegistrar" class="sample.code.listing.utils.MyPropertyEditorRegistrar"/&gt; &lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt; &lt;property name="basenames"&gt; &lt;list&gt; &lt;value&gt;content.Language-ext&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt; &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; </code></pre> <p></p> <p>My AddSinifController is here :</p> <pre><code>@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&lt;Sinif&gt; 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"); } } } </code></pre> <p>Regards</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload