Announcement Announcement Module
Collapse
No announcement yet.
NoSuchBeanDefinitionException. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoSuchBeanDefinitionException.

    Hi all!
    I post from Japan, and please excuse my poor English.
    Well, I created an application for the mail service with spring, but I can't get bean at:

    Code:
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    MailService mailService = (MailService) context.getBean("mailService");
    so, please could you help me?
    I write more information below.

    applicationContext.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jee="http://www.springframework.org/schema/jee"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
      http://www.springframework.org/schema/jee
      http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
    
      <context:annotation-config />
    
      <!-- dozer component regist -->
      <bean id="net.sf.dozer.util.mapping.MapperIF"
        class="net.sf.dozer.util.mapping.DozerBeanMapper" scope="singleton">
        <property name="mappingFiles">
          <list>
            <value>dozer-global-configuration.xml</value>
          </list>
        </property>
      </bean>
    
      <!-- component scan -->
      <context:component-scan base-package="jp.mycompany.mail.service.impl">
      </context:component-scan>
    
      <!-- import service -->
      <import resource="classpath:/applicationContext-core-service.xml" />
    
      <!-- import dao -->
      <import resource="classpath:/applicationContext-core-dao.xml" />
    
    </beans>
    jp.mycompany.mail.service.impl.MailServiceImpl

    Code:
    package jp.mycompany.mail.service.impl;
    
    import java.io.UnsupportedEncodingException;
    import java.sql.Timestamp;
    import java.util.Date;
    import java.util.LinkedHashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.regex.Pattern;
    
    import javax.mail.BodyPart;
    import javax.mail.MessagingException;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeUtility;
    
    import jp.mycompany.core.bean.CvnetMail;
    import jp.mycompany.mail.service.MailService;
    import net.sf.dozer.util.mapping.MapperIF;
    
    import org.apache.commons.lang.StringUtils;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.provtech.jin.mail.Mail;
    import org.provtech.jin.mail.MailHeader;
    import org.provtech.jin.mail.alternative.AlternativeFactory;
    import org.provtech.jin.mail.attachment.Inline;
    import org.provtech.jin.mail.internet.ContentType;
    import org.provtech.jin.mail.internet.MailAddress;
    import org.provtech.jin.mail.util.MailUtil;
    import org.provtech.jin.mobile.carrier.Carrier;
    import org.provtech.jin.mobile.carrier.utils.MobileAnalysisUtils;
    import org.provtech.jin.util.StringUtil;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.dao.EmptyResultDataAccessException;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
    
    import au.id.jericho.lib.html.Source;
    
    @Service(value = "mailService")
    public class MailServiceImpl implements MailService {
    
        @Autowired
        private MapperIF mapper;
    
    	private static final Pattern CARRIER_MAIL_IPHONE = Pattern
    	.compile("^[^@]+@i\\.softbank\\.jp$");
    	
    
         ・・・
    error log

    Code:
    2013-05-16 15:13:46,879 INFO - [main] MailBatch(54) # MailBatch START  
    2013-05-16 15:13:51,070 ERROR- [main] MailBatch(107) # java.lang.ExceptionInInitializerError
    	at jp.mycompany.mail.lad.MailBatch.execute(MailBatch.java:93)
    	at jp.mycompany.mail.lad.MailBatch.main(MailBatch.java:57)
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mailService' is defined
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:971)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
    	at jp.mycompany.mail.util.ContextUtils.<clinit>(ContextUtils.java:55)
    	at jp.mycompany.mail.lad.MailBatch.execute(MailBatch.java:93)
    	at jp.mycompany.mail.lad.MailBatch.main(MailBatch.java:57)
     
    2013-05-16 15:13:51,072 INFO - [main] MailBatch(59) # MailBatch END
    Last edited by tetsu; May 16th, 2013, 03:52 AM.

  • #2
    Hi!

    In general it's a question for Spring Core (http://forum.springsource.org/forumd...p?26-Container), not Spring Integration (http://www.springsource.org/spring-integration)

    However I suggest you to check which version of Spring you are using and remove versions from xsd urls in application context xml.

    HTH,
    Artem

    Comment


    • #3
      Thank you very much, Cleric.

      I will post at Spring Core.
      I used spring2.5.6. Maybe it is a problem.

      Regards,
      tetsu

      Comment

      Working...
      X