Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to use spring component-scan feature in JBoss 5.1.2
    primarykey
    data
    text
    <p>I am facing challenge in using Spring 3.0 component-scan feature with JBoss 5.1.2. i am not able to use @Autowired feature. Below are the Code which i configured.</p> <p>My Web.xml</p> <pre><code> &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/spring-config/applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; </code></pre> <p>applicationContext.xml consist of the below line i have imported the beans,context xsd in file. applicationContext-hibernate.xml file contains Hibernate configuration Details.</p> <pre><code> &lt;ctx:component-scan base-package="com.mycom.cmc" /&gt; &lt;import resource="applicationContext-hibernate.xml" /&gt; </code></pre> <p>Below is the class which i using for doing DAO operation.</p> <pre><code>@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; } </code></pre> <p>}</p> <pre><code>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(); } </code></pre> <p>}</p> <p>When i deploy the application on the JBoss Container i can see the .hbm files and JNDI connection is happening properly. but i can not see the class is getting scanned in server log JBoss Container.</p> <pre><code>19:49:54,958 INFO [[/CMC]] Initializing Spring root WebApplicationContext 19:49:55,598 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.BatchProcessingTx -&gt; BATCH_PROCESSING_TX 19:49:55,598 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.BrandMapping -&gt; BRAND_MAPPING 19:49:55,614 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ClientAccessRule -&gt; CLIENT_ACCESS_RULE 19:49:55,614 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ContractInfo -&gt; CONTRACT_INFO 19:49:55,630 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ExceptionInfo -&gt; EXCEPTION_INFO 19:49:55,630 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.PdfDocumentMapping -&gt; PDF_DOCUMENT_MAPPING 19:49:55,645 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.ReferenceInfo -&gt; REFERENCE_INFO 19:49:55,645 INFO [HbmBinder] Mapping class: com.myapp.cmc.domain.model.WebServiceTx -&gt; WEB_SERVICE_TX 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ContractInfo.batchProcessingTxes -&gt; BATCH_PROCESSING_TX 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ContractInfo.exceptionInfos -&gt; EXCEPTION_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForFairUsePolicyId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForTermsOfServiceId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForPrivacyPolicyId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.PdfDocumentMapping.contractInfosForAddedClausesId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractReasonId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractTypeId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractMediaId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.ReferenceInfo.contractInfosForContractDistributionTypeId -&gt; CONTRACT_INFO 19:49:55,645 INFO [HbmBinder] Mapping collection: com.myapp.cmc.domain.model.WebServiceTx.contractInfos -&gt; 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 </code></pre> <p>when i try save the object i am getting NullPointerException. i think the Spring component scan feature is not working. Due to that i am unable to get hibernateTemplate instance. And i don't see any scanning for the class in the Log file of JBoss server log. Please tell me what i missed it. or is it issue with JBoss 5.1.2 with Spring 3.0. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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