Announcement Announcement Module
Collapse
No announcement yet.
NPE (launcher) on CommandLineJobRunner Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Thanks LucasWard. Here is the configuration for the data sources:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans 
    	xmlns="http://www.springframework.org/schema/beans" 
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:tx="http://www.springframework.org/schema/tx" 
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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">
    		
    	
    	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    		<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
    		<property name="url" value="REDACTED" />
    		<property name="username" value="REDACTED" />
    		<property name="password" value="REDACTED" />
    	</bean>
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="mappingLocations" value="classpath*:/*.hbm.xml" />
    		<property name="hibernateProperties">
    			<value>
    				<![CDATA[
    					hibernate.show_sql=true
    					hibernate.format_sql=true
    			]]>
    			</value>
    		</property>
    	</bean>
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" lazy-init="true">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    	
    </beans>
    The URI, user and password have been redacted, but I know they work. Thanks again.

    - Saish

    Comment


    • #17
      Nevermind, I saw it on page one. It's creating the bean fine, but I don't see any log statements where it's trying to autowire.

      Comment


      • #18
        Do I need to configure auto-wiring to be enabled somewhere? I did not see that in any of the samples and cannot remember doing it with our standard Spring implementation.

        - Saish

        Comment


        • #19
          I do see the following ClassNotFound a few lines before the error. Not sure if that would affect anything, but the bean is, I think, being returned as a singleton, so I thought I would point it out:

          DEBUG ClassUtils - Class [edu.emory.mathcs.backport.java.util.concurrent.Sem aphore] or one of its dependencies is not present: java.lang.ClassNotFoundException: edu.emory.mathcs.backport.java.util.concurrent.Sem aphore

          Comment


          • #20
            I have no idea why it's doing this, but I found the following in the log:

            Code:
            DEBUG DefaultListableBeanFactory - Creating instance of bean 'jobLauncher' with merged definition [Root bean: class [org.springframework.batch.core.launch.support.SimpleJobLauncher]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=false; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [simple-job-launcher-context.xml]]
            DEBUG DefaultListableBeanFactory - Eagerly caching bean 'jobLauncher' to allow for resolving potential circular references
            Most of that doesn't matter, but the important part is that autowireCandidate=false. Can you explicitely set that to true in the bean? Just add 'autowire-candidate=true' do your bean definition for the launcher.

            Comment


            • #21
              Yahtzee! That did it. Thanks so much. I now get a table not found error, which is what I expected in the very beginning before I hit the NPE (as I had not created the tables yet).

              - Saish

              Comment


              • #22
                Just a guess, but maybe updating to the latest Spring 2.5.4 (or 2.0.8) would help (without editing the bean)?

                Comment


                • #23
                  Thanks Robert. I upgraded to 2.5.4 and removed the autowire attribute from the bean. Everything worked fine. Much obliged.

                  - Saish

                  Comment

                  Working...
                  X