JBoss 5.1.2에서 Spring 3.0 구성 요소 스캔 기능을 사용하는 데 어려움을 겪고 있습니다. @Autowired 기능을 사용할 수 없습니다. 아래는 내가 구성한 코드입니다.JBoss 5.1.2에서 스프링 구성 요소 스캔 기능을 사용할 수 없음
내의 Web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-config/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
applicationContext.xml 파일의 아래에 난 콩을 수입 한 라인, 상황에 맞는 XSD로 구성되어 있습니다. applicationContext-hibernate.xml 파일은 Hibernate 구성 세부 사항들을 포함한다.
<ctx:component-scan base-package="com.mycom.cmc" />
<import resource="applicationContext-hibernate.xml" />
다음은 DAO 조작을 위해 사용하는 클래스입니다.
@Repository("batchProcessingTxDAO")
public class BatchProcessingTxDAOImpl extends HibernateRepository implements
BatchProcessingTxDAO {
private static final Logger log = Logger
.getLogger(BatchProcessingTxDAOImpl.class);
@Override
public void saveBatchProcessingTx(BatchProcessingTx batchProcessingTx) {
try {
if (batchProcessingTx != null) {
log.info(String
.format("saving BatchProcessingTx details for batchProcessingTxId :: %s",
batchProcessingTx.getBatchProcessingTxId()));
hibernateTemplate.save(batchProcessingTx);
}
} catch (Exception e) {
log.error(String
.format("Exception occured while saving the BatchProcessingTx caused by :: %s",
e));
}
log.info(String
.format("Sucessfully saved BatchProcessingTx details for batchProcessingTxId ::%s",
batchProcessingTx.getBatchProcessingTxId()));
}
@Override
public BatchProcessingTx getBatchProcessingTxByBatchProcessingTxId(
BigDecimal batchProcessingTxId) {
System.out.println("called Sucessfully 1212121111111111111111111");
BatchProcessingTx batchProcessingTx = null;
/*
if (batchProcessingTxId != null) {
log.info(String.format(
"BatchProcessingTx details for batchProcessingTxId :: %s",
batchProcessingTxId));
batchProcessingTx = hibernateTemplate.get(BatchProcessingTx.class,
batchProcessingTxId);
}
*/
return batchProcessingTx;
}
}
public abstract class HibernateRepository {
private SessionFactory sessionFactory;
protected HibernateTemplate hibernateTemplate;
@Required
@Autowired(required =true)
@Qualifier("sessionFactory")
public void setSessionFactory(final SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
hibernateTemplate = new HibernateTemplate(sessionFactory);
}
protected Session getSession() {
return sessionFactory.getCurrentSession();
}
}
내가 JBoss의 컨테이너에서 응용 프로그램을 배포 할 때 내가 .hbm 파일을 볼 수 있고 JNDI 연결이 제대로 일어나고있다. 하지만 클래스가 JBoss Container 서버 로그에서 스캔되는 것을 볼 수 없습니다.
19:49:54,958 INFO [[/CMC]] Initializing Spring root WebApplicationContext
19:49:55,598 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.BatchProcessingTx -> BATCH_PROCESSING_TX
19:49:55,598 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.BrandMapping -> BRAND_MAPPING
19:49:55,614 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ClientAccessRule -> CLIENT_ACCESS_RULE
19:49:55,614 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ContractInfo -> CONTRACT_INFO
19:49:55,630 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ExceptionInfo -> EXCEPTION_INFO
19:49:55,630 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.PdfDocumentMapping -> PDF_DOCUMENT_MAPPING
19:49:55,645 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ReferenceInfo -> REFERENCE_INFO
19:49:55,645 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.WebServiceTx -> WEB_SERVICE_TX
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ContractInfo.batchProcessingTxes -> BATCH_PROCESSING_TX
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ContractInfo.exceptionInfos -> EXCEPTION_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForFairUsePolicyId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForTermsOfServiceId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForPrivacyPolicyId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForAddedClausesId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractReasonId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractTypeId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractMediaId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractDistributionTypeId -> CONTRACT_INFO
19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.WebServiceTx.contractInfos -> CONTRACT_INFO
19:49:55,661 INFO [ConnectionProviderFactory] Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
19:49:55,661 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
19:49:55,661 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.1.0.4.0
19:49:55,661 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle10gDialect
19:49:55,661 INFO [JdbcSupportLoader] Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
19:49:55,661 INFO [TransactionFactoryFactory] Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
19:49:55,661 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
19:49:55,661 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
19:49:55,661 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
19:49:55,661 INFO [SettingsFactory] JDBC batch size: 15
19:49:55,661 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
19:49:55,661 INFO [SettingsFactory] Scrollable result sets: enabled
19:49:55,661 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
19:49:55,661 INFO [SettingsFactory] Connection release mode: auto
19:49:55,661 INFO [SettingsFactory] Default batch fetch size: 1
19:49:55,661 INFO [SettingsFactory] Generate SQL with comments: disabled
19:49:55,661 INFO [SettingsFactory] Order SQL updates by primary key: disabled
19:49:55,661 INFO [SettingsFactory] Order SQL inserts for batching: disabled
19:49:55,661 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
19:49:55,661 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
19:49:55,661 INFO [SettingsFactory] Query language substitutions: {}
19:49:55,661 INFO [SettingsFactory] JPA-QL strict compliance: disabled
19:49:55,661 INFO [SettingsFactory] Second-level cache: enabled
19:49:55,661 INFO [SettingsFactory] Query cache: disabled
19:49:55,661 INFO [SettingsFactory] Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
19:49:55,661 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
19:49:55,661 INFO [SettingsFactory] Structured second-level cache entries: disabled
19:49:55,661 INFO [SettingsFactory] Statistics: disabled
19:49:55,661 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
19:49:55,661 INFO [SettingsFactory] Default entity-mode: pojo
19:49:55,661 INFO [SettingsFactory] Named query checking : enabled
19:49:55,661 INFO [SessionFactoryImpl] building session factory
19:49:55,723 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
내가 개체를 저장하려고하면 NullPointerException이 발생합니다. 나는 봄 구성 요소 스캔 기능이 작동하지 않는 것 같아요. 이로 인해 나는 hibernateTemplate 인스턴스를 얻을 수 없다. 그리고 JBoss 서버 로그의 로그 파일에있는 클래스에 대한 검사는 보이지 않습니다. 내가 놓친 걸 말해줘. Spring 3.0과 JBoss 5.1.2에서 문제가되는 것입니다.
코드를 게시 할 수있는 위치 및 서비스 사용 방법 ... 테스트 사례에서 작동합니까? 그리고 실제 스택 추적을 게시하십시오. –
응용 프로그램이 서버에 성공적으로 배포 될 때 스택 추적은 실제 스택 추적입니다. 이 코드에는 Junit 테스트 케이스가 없습니다. 나는 Service 레이어 클래스에서 직접 호출하고있다. @Autowired를 사용하면 객체가 null인지 알 수 있습니다. –
게시물에 스택 트레이스가 없으며이 서비스를 어디서 어떻게 호출하는지 코드를 알려 주시기 바랍니다 ... –