This discussion is archived
0 Replies Latest reply: May 11, 2012 3:10 AM by 936697 RSS

org.springframework.beans.factory.BeanCreationException

936697 Newbie
Currently Being Moderated
In the perisistence.xml we are configured the subscription jndi, calling using this applicationContext.xml.
But our problem is that subscription jndi should be configured in jboss locally.
Where we have to configured that jndi in local server. I have given the applicationContext and persistence.xml file blow:
Also we have subscription-ds file in deploy folder of my JBoss5.1.2.


When ever we are going to run the testcases it throwing following Exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: subscription not bound
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
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.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at com.hungama.subscription.test.LogUtilTest.<init>(LogUtilTest.java:20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:209)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:258)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:255)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.naming.NameNotFoundException: subscription not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
at sun.reflect.GeneratedMethodAccessor266.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:750)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:200)
at org.springframework.jndi.Jndi


Following is my persistence.xml file which i kept in META-INF/persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
     <persistence-unit name="subscriptionUnitName" transaction-type="JTA">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:/subscriptionDS</jta-data-source>
          <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
               <!-- <property name="hibernate.hbm2ddl.auto" value="update"/> -->
               <property name="hibernate.show_sql" value="false"/>
               <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
               <property name="jboss.entity.manager.jndi.name" value="java:/subscription"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/subscriptionFactory"/>
          </properties>
     </persistence-unit>
</persistence>


My applicationContext.sml file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<util:properties id="chrgingProperties" location="classpath:charging-jndi.properties"/>

<util:properties id="msgingProperties" location="classpath:messaging-jndi.properties"/>

<bean id="jndiPropeties" class="com.myCompany.subscription.services.config.model.JNDIProperties">
          <property name="msgingProperties" ref="msgingProperties"></property>
          <property name="chrgingProperties" ref="chrgingProperties"></property>
</bean>

          <jee:jndi-lookup id="entityManagerFactory" jndi-name="java:/subscription"></jee:jndi-lookup>
          
          <jee:jndi-lookup id="dataSource" jndi-name="java:/subscriptionDS"></jee:jndi-lookup>
          
          
          <bean id="trasactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
               
               <property name="transactionManagerName" value="java:/TransactionManager"/>
     <property name="userTransactionName" value="UserTransaction"/>          
          </bean>
          
          
          <aop:config>
          <aop:pointcut id="productServiceMethods" expression="execution(* com.myCompany.subscription.services.impl.*.*(..))"/>
          <aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods"/>
          </aop:config>
          
          <tx:advice id="txAdvice" transaction-manager="trasactionManager">
               <tx:attributes>
               <tx:method name="getError*" propagation="REQUIRES_NEW" read-only="true"/>
               <tx:method name="save*" propagation="REQUIRED" rollback-for="com.myCompany.subscription.exception.SubscriptionServiceException"/>
               <tx:method name="chargeAmount*" propagation="REQUIRED"/>
               <tx:method name="insert*" propagation="REQUIRED"/>
               <tx:method name="update*" propagation="REQUIRED"/>
               <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
               <tx:method name="*" propagation="SUPPORTS" read-only="true"/>
          </tx:attributes>
          </tx:advice>
          
          
          <!-- Services Started -->
          <bean id="generalDao" class="com.myCompany.subscription.services.dao.GeneralDao">
               <property name="entityManagerFactory" ref="entityManagerFactory"></property>
          </bean>
          
          <bean id="logUtil" class="com.myCompany.subscription.services.util.LogUtil" init-method="initialize">
               <property name="generalDao" ref="generalDao"/>
          </bean>
          
          <bean id="chargingMsgingClient" class="com.myCompany.subscription.services.client.SubscriptionJMSClient">
               <property name="logUtil" ref="logUtil"></property>
               <property name="properties" ref="chrgingProperties"></property>
               <property name="connectionFactoryName" value="ConnectionFactory"></property>
               <property name="topicName" value="topic/myCompanyChargingTopic"></property>
          </bean>
          
          <bean id="messagingJMSClient" class="com.myCompany.subscription.services.client.MessagingJMSClient">
               <property name="logUtil" ref="logUtil"></property>
               <property name="properties" ref="msgingProperties"></property>
               <property name="connectionFactoryName" value="ConnectionFactory"></property>
               <property name="topicName" value="topic/TempTopic"></property>
               
          </bean>
          
          <bean id="subscriptionParams" class="com.myCompany.subscription.services.config.model.SubscriptionServiceParams">
          </bean>
          
          <bean id="subscriptionConfigService" class="com.myCompany.subscription.services.config.SubscriptionConfigService" init-method="initialize" >
               <property name="generalDao" ref="generalDao"></property>
               
               <property name="paramType" value="MESG_GW"></property>
               <property name="paramGroup" value="MESG_GW"></property>
               <property name="msgUserName" value="MSG_USERNAME"></property>
               <property name="msgUserPassword" value="MSG_PASSWORD"></property>
               <property name="msgSourceMsisdn" value="MSG_SOURCE_MSISDN"></property>
               <property name="messagingUrl" value="MESSAGING_URL"></property>
               <property name="subscriptionParams" ref="subscriptionParams"></property>
               <property name="msgAgencyId" value="MSG_AGENCYID"></property>
          </bean>
          
          <bean id="subServiceManager" class="com.myCompany.subscription.services.impl.SubscriptionServiceManager">
               <property name="generalDao" ref="generalDao"/>
               <property name="logUtil" ref="logUtil"></property>
               <property name="ratingEngineService" ref="ratingEngineService"/>
               <property name="callbackServiceManager" ref="callbackServiceManager"/>
               <property name="subMsgingClient" ref="subMsgingClient"/>
               <property name="chargingMsgingClient" ref="chargingMsgingClient"></property>
          </bean>
          
          <bean id="ratingEngineService" class="com.myCompany.rating.services.impl.RatingEngineService">
               <property name="generalDao" ref="generalDao"/>
          </bean>
          
          <bean id="callbackServiceManager" class="com.myCompany.subscallback.services.impl.SubsCallbackServiceManager">
               <property name="generalDao" ref="generalDao"/>
          </bean>
          
          <bean id="subscriptionService" class="com.myCompany.subscription.services.impl.SubscriptionService">
               <property name="generalDao" ref="generalDao"/>
               <property name="logUtil" ref="logUtil"></property>
               <property name="subscriptionParamName" value="SUBSCRIPTION"></property>
               <property name="subscriptionParamType" value="SUBSCRIPTION"></property>
               <property name="subscriptionParamGroup" value="PLAN_MASTER_TYPE"></property>
          </bean>
          
          <bean id="subMsgingClient" class="com.myCompany.subscription.services.client.SubscriptionMessageClient">
               <property name="logUtil" ref="logUtil"></property>
          </bean>
          
     
          
          <bean id="msgGwClient" class="com.myCompany.subscription.services.client.MessageGatewayClient">
               <property name="subscriptionParams" ref="subscriptionParams"></property>
               <property name="logUtil" ref="logUtil"></property>
          </bean>
          

                    
          <bean id="schedulerService" class="com.myCompany.subscription.services.impl.SubscriptionSchedulerService">
               <property name="generalDao" ref="generalDao"/>
               <property name="msgClient" ref="subMsgingClient"></property>
               <property name="logUtil" ref="logUtil"></property>
               <property name="msgGwClient" ref="msgGwClient"></property>
               <property name="subscriptionParams" ref="subscriptionParams"></property>
               <property name="messagingJMSClient" ref="messagingJMSClient"></property>
               <property name="subServiceManager" ref="subServiceManager"></property>
          </bean>
          
          <bean id="schedulerLock" class="com.myCompany.subscription.services.model.SchedulerLock">
          </bean>
          
          
</beans>

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points