Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

spring 2 & struts 2 doubt

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
please help me in solving this problem.m trying to implement declarative transaction management in my struts 2 application,using spring 2
while debugging exception is thrown at this line of my source code
ApplicationContext ctx = new ClassPathXmlApplicationContext("springContext.xml",BscAction.class);


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Unable to instantiate Action, mfar.action.coa.BscAction, defined for 'balanceSheetCategoryAction_ra' in namespace '/controlled-view/coa'IOException parsing XML document from class path resource [springContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [springContext.xml] cannot be opened because it does not exist
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)


root cause

Unable to instantiate Action, mfar.action.coa.BscAction, defined for 'balanceSheetCategoryAction_ra' in namespace '/controlled-view/coa'IOException parsing XML document from class path resource [springContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [springContext.xml] cannot be opened because it does not exist - action - file:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/MFAR/WEB-INF/classes/struts.xml:161:59
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:289)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:360)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:78)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:70)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:66)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post some code where you are getting this exception ...
 
sharan vasandani
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
concentrate on bolded part

sprintContext.xml file


<?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:aop="http://www.springframework.org/schema/aop"
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.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">



<bean id="mfarDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean"
lazy-init="true">
<property name="jndiName" value="java:comp/env/jdbc/MFAR" />
</bean>



<bean id="myDataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
lazy-init="true">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.81.7.156:3306/mfar" />
<property name="username" value="root" />
<property name="password" value="password1" />
</bean>

<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate" lazy-init="true">
<property name="dataSource">
<ref local="mfarDataSource" />
</property>
</bean>

<bean id="dbAccessManager" class="mfar.dao.DBAccessManager"
lazy-init="true">
<constructor-arg index="0">
<ref local="mfarDataSource" />
</constructor-arg>
<constructor-arg index="1">
<ref local="jdbcTemplate" />
</constructor-arg>
</bean>

<bean id="fundManager" class="mfar.manager.FundManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="applicationParameterManager"
class="mfar.manager.ApplicationParameterManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="referenceFactory" class="mfar.ref.ReferenceFactory"
lazy-init="true">
<constructor-arg index="0">
<ref local="dbAccessManager" />
</constructor-arg>
</bean>

<bean id="securityManager" class="mfar.manager.SecurityManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="floatingRatesManager"
class="mfar.manager.FloatingRatesManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="shareClassManager" class="mfar.manager.ShareClassManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="accountHeadManager"
class="mfar.manager.coa.AccountHeadManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="coaManager" class="mfar.manager.coa.CoaManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>


<bean id="bscManager" class="mfar.manager.coa.BscManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>


<tx:annotation-driven transaction-manager="txManager"/>


<tx:advice id="txAdvice" transaction-manager="txManager">

<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>

<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="myDataSource" />
</bean>


<bean id="accountRelationManager"
class="mfar.manager.coa.AccountRelationManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

</beans>


BscManager.java

package mfar.manager.coa;

import java.lang.reflect.Method;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.transaction.annotation.Transactional;


import mfar.bean.coa.AccountHead;
import mfar.bean.coa.BalanceSheetCategory;
import mfar.bean.coa.ChartOfAccount;
import mfar.dao.DBAccessManager;
import mfar.exception.MFARException;
import mfar.manager.IBeanManager;

/**
* This class communicates with the DBAccessManager for all actions relating to
* Balance Sheet Category.
*
* @author sharanv
*
*/

@Transactional

public class BscManager implements IBeanManager
{
continued...



BscAction.java

class BscAction extends ActionSupport
{
public BscAction()throws MFARException
{

ApplicationContext ctx = new ClassPathXmlApplicationContext("springContext.xml");------Blowing here
bscManager = (BscManager) ctx.getBean("bscManager");

retreiveAll();

}

continued....

tomcat giving error



javax.servlet.ServletException: Unable to instantiate Action, mfar.action.coa.BscAction, defined for 'balanceSheetCategoryAction_ra' in namespace '/controlled-view/coa'$Proxy15
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
 
sharan vasandani
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
concentrate on bolded part

sprintContext.xml file


<?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:aop="http://www.springframework.org/schema/aop"
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.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">



<bean id="mfarDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean"
lazy-init="true">
<property name="jndiName" value="java:comp/env/jdbc/MFAR" />
</bean>



<bean id="myDataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
lazy-init="true">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.81.7.156:3306/mfar" />
<property name="username" value="root" />
<property name="password" value="password1" />
</bean>

<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate" lazy-init="true">
<property name="dataSource">
<ref local="mfarDataSource" />
</property>
</bean>

<bean id="dbAccessManager" class="mfar.dao.DBAccessManager"
lazy-init="true">
<constructor-arg index="0">
<ref local="mfarDataSource" />
</constructor-arg>
<constructor-arg index="1">
<ref local="jdbcTemplate" />
</constructor-arg>
</bean>

<bean id="fundManager" class="mfar.manager.FundManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="applicationParameterManager"
class="mfar.manager.ApplicationParameterManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="referenceFactory" class="mfar.ref.ReferenceFactory"
lazy-init="true">
<constructor-arg index="0">
<ref local="dbAccessManager" />
</constructor-arg>
</bean>

<bean id="securityManager" class="mfar.manager.SecurityManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="floatingRatesManager"
class="mfar.manager.FloatingRatesManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="shareClassManager" class="mfar.manager.ShareClassManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="accountHeadManager"
class="mfar.manager.coa.AccountHeadManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

<bean id="coaManager" class="mfar.manager.coa.CoaManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>


<bean id="bscManager" class="mfar.manager.coa.BscManager"
lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>


<tx:annotation-driven transaction-manager="txManager"/>


<tx:advice id="txAdvice" transaction-manager="txManager">

<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>

<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="myDataSource" />
</bean>


<bean id="accountRelationManager"
class="mfar.manager.coa.AccountRelationManager" lazy-init="true">
<property name="dbAccessManager">
<ref local="dbAccessManager" />
</property>
</bean>

</beans>


BscManager.java

package mfar.manager.coa;

import java.lang.reflect.Method;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.transaction.annotation.Transactional;


import mfar.bean.coa.AccountHead;
import mfar.bean.coa.BalanceSheetCategory;
import mfar.bean.coa.ChartOfAccount;
import mfar.dao.DBAccessManager;
import mfar.exception.MFARException;
import mfar.manager.IBeanManager;

/**
* This class communicates with the DBAccessManager for all actions relating to
* Balance Sheet Category.
*
* @author sharanv
*
*/

@Transactional

public class BscManager implements IBeanManager
{
continued...



BscAction.java

class BscAction extends ActionSupport
{
public BscAction()throws MFARException
{

ApplicationContext ctx = new ClassPathXmlApplicationContext("springContext.xml");------Blowing here
bscManager = (BscManager) ctx.getBean("bscManager");

retreiveAll();

}

continued....

tomcat giving error



javax.servlet.ServletException: Unable to instantiate Action, mfar.action.coa.BscAction, defined for 'balanceSheetCategoryAction_ra' in namespace '/controlled-view/coa'$Proxy15
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

look at the error:


where do you have the springContext.xml file?
(hope you did not make any typing errors...)

Herman
[ June 01, 2007: Message edited by: Herman Scheltinga ]
 
permaculture is giving a gift to your future self. After reading this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!