Application context problem code

Application context problem code

now i am posting my code here .
i got error of sessionfactory.
so tell me where i declare sessionfactory method.

package net.action;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.orm.hibernate3.SessionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.web.context.WebApplicationContext;

import com.opensymphony.xwork2.Action;

public class TestNew extends TestBase {

protected FileSystemXmlApplicationContext context = null;
protected SessionFactory sessionFactory=null ;
protected ApplicationContext applicationContext;
private AccountAction currentAction;

public String getContextLocations() {
return "/applicationContext.xml";
}

protected void init() {
servletContext.setAttribute(
WebApplicationContext.ROOT WEB APPLICATION CONTEXT ATTRIBUTE,
applicationContext);
}

/**
* setup method is called before test
*/
protected void setUp() throws Exception {
super.setUp();

//String[] contextLocations = new String[1];
//contextLocations[0] = "test/applicationContext.xml";
//contextLocations[1] = "src/test/applicationContext.xml";
context = new FileSystemXmlApplicationContext("test/applicationContext.xml");
System.out.println("see ");

sessionFactory = (SessionFactory) context.getBean("sessionFactory");
System.out.println("pl check it");
Session session = SessionFactoryUtils.getSession(sessionFactory,false);
TransactionSynchronizationManager.bindResource(sessionFactory,
new SessionHolder(session));
}

@Test
public void tests() throws Exception {

request.setAttribute("account.username", "hello");
request.setAttribute("account.password", "test");

// code to set test action environment
createAction("/create", "Test", "list");

// code to execute test action
String result = proxy.execute();

// code to test action result
assertEquals("valid Page...", Action.SUCCESS, result);

System.out.println("List successfully dispalyed ....");

}

/**
* @param currentAction
* the currentAction to set
*/
public void setCurrentAction(AccountAction currentAction) {
this.currentAction = currentAction;
}

**
* @return the currentAction
*/
public AccountAction getCurrentAction() {
return currentAction;
}

public SessionFactory getSessionFactory(){

return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory){
this.sessionFactory=sessionFactory;

}

}
View Answers









Related Tutorials/Questions & Answers:
Application context problem code
Application context problem code   now i am posting my code here . i...( WebApplicationContext.ROOT WEB APPLICATION CONTEXT ATTRIBUTE, applicationContext... FileSystemXmlApplicationContext context = null; protected SessionFactory sessionFactory=null
application context file problem
application context file problem  how to configure junit application context file with struts........? it is not finding sessionfactory method
Advertisements
What is Application Context?
What is Application Context?  Hello, What is Application Context? Thanks
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... application it is showing javax.servlet.ServletException: Parse Error in JSP page
Hibernate code problem - Hibernate
problem please send me code. Visit for more information. http...Hibernate code problem  Hi This is Raju.I tried the first example........How can i solve this problem. Am i need to Kept any other jars in path. 
code problem:ajax - Ajax
code problem:ajax  Hi,I am using ajax to populate a select box.for this I am writing out.write("ONE"); like that.it runs fine in firefox.bt not in IE.Can anyone help me out this... thanks
Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want... in the DAO.Can it be possibe. Please send some sample code.. thanks & Regards Birendra  Hi friend, For solving the problem visit
code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz
code problem - Java Beginners
code problem  Dear sir, I'm havin a problem that suppose i've got... java script j2ee j2me sql plz help me to sort out this problem. thnx   Hi Friend, Please try the following sample code to solve your problem
problem with code - Ajax
problem with code  hi friends i am sending a code in that when we... to use ajax i wrote the code of jsp and the remaning code by using ajax is not wrritened by observing these below code please try the remainning ajax code its
Problem with code - Java Beginners
Problem with code  Hi Deepak. Im a newbie here at your forum. I have got a simple code of mine which is having a little problem. When I compile it, i get an...,identifier expected'...error. Could you help me out? Thank you
hibernate code problem - Hibernate
/selectclause.shtml If you have any problem this send me detail and source code...hibernate code problem  suppose i want to fetch a row from the table through a value which i got from the jsp page. how can i do it and iterate
code problem - Java Beginners
code problem  Dear sir, My problem is that i have some string value and in some case i want to remove all the value of this string, i tried this code- Response.str.clear(); but it shows some error called "response package
code problem - Java Beginners
code problem  Dear sir, my problem is given below: suppose a file Carries the following lines- Name: john age: 45 Address: goa phone...; Hi friend, Code to help in solving the problem : import java.io.
code problem - Java Beginners
code problem  Dear sir, my question was actually how to find a particual line's contain, example if a file contains- hy, how r u? regrd, john... your problem in details. Which keyword search the line. Thanks
code problem - Java Beginners
of program. thnx  Hi friend, Code to help in solving the problem...code problem  Dear sir, I've some integer value in ArrayList like- 10 40 30 i want to add them and print should be like- "total value
problem:struts code - Struts
problem:struts code  Hi, Am using struts1.2.I wrote a form(dynavalidator form)with validation after completing the form if we press submit its call the action class,in action class i gave forward to same form,the problem is if i
code problem - Java Beginners
code problem  Dear sir, I have an excel file in D: drive called today.xls, i want to open it thru java program, what code would be compatible plz help me  Hi friend, Code to help in solving the problem : import
code problem - Java Beginners
code problem  Dear sir, my problem is that, i have two Combobox one.... plz tell how to code this program.   Hi Friend, You can use the following code: ComboBox var arr = new Array(); arr[0] = new
code problem - Java Beginners
code problem  Dear sir, I've some string called "JohnSon" that has to be crypted first and then decrypted, how to crypt and decrypt data plz tell me.  Hi friend, Code to help in solving the problem : public
code problem - Java Beginners
; Hi friend, Code to help in solving the problem : import java.io....code problem  Dear Sir, I've to make a program where there are 10 lines of a particular file i've to display every Line's contains, example- Line1
code problem - Struts
code problem  hi friends i have 1 doubt regarding how to write the code of opensheet in action class i have done it as the action class code...(); System.out.println(conn); //Code to generate new sheet i.e login time IS NULL
code problem - Java Beginners
code problem  My code is below: import java.io.*; class FileRead...()); } } } Dear sir, my problem is that suppose i enter line number: 3 if line... your code and then again try it : import java.io.*; class FileRead
combo box code problem
combo box code problem  in this my problem related to : when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
spring context dependency maven code
Context in my maven project. So, i am searching searching for the code that I can add into my pom.xml file. What is spring context dependency maven code? Thanks... is the dependency code for spring-context version 5.1.5: <dependency> <
Hibernate code problem - Hibernate
Hibernate code problem  Hai, iam working on simple login application using hibernate in spring. I've used Spring dependency injection too.I.... Please find my src code here... ----------------controller Layer
code problem - Java Beginners
code problem  i've to send a login packet( username & password..., what code should be compatible, as i heared with UDP programing there is no Guarantee of packet's delevery so send me code made of TCP, plz help me
Hibernate code problem - Hibernate
Hibernate code problem  how to write hibernate Left outer join program
Code problem - Java Beginners
Code problem  Hi. I want to create a drop down button,where the value will be hard coded and on selecting an option another drop down button... and these values will come from the database. Can anyone help me with the code
code for this problem - JSP-Servlet
code for this problem   i have buttom submit .It is working with single click.Suppose if i am At the same time clicking(parallel) twise second request will be stoped until process the proces first requst and terminate
Hibernate code problem - Hibernate
Hibernate code problem   Hi This is Raju I tried the first example of hibernate course material.This is to insert a record into CONTACT table.Is Hibernate code automatically creates the CONTACT table and then insert
hibernate code problem - Hibernate
hibernate code problem  String SQL_QUERY =" from Insurance...: " + insurance. getInsuranceName()); } in the above code,the hibernate... thanks shakti  Hi friend, Your code is : String SQL_QUERY =" from
code problem - Java Beginners
code problem  I want to write a program that read a string and prints... of space charaters Here is the code which I suppose is almost correct.However...; int p,i; boolean q,r,t; int count=0,count2=0,count1=0
code problem - Java Beginners
code problem  1)what is accurate use of access specifiers (plz give me all uses in options)..? 2)In folllowing options which can be used by the inner class....? a)private instance variables b)public instance variables c
Code Problem - Struts
Code Problem  i want to insert multiple row values (from html table which is in jsp) into oracle database using struts.for example oracle table contains 3 fields as sub1,sub2,sub3.html table contains 10 rows of sub1,sub2,sub3
code problem - Java Beginners
code problem  Dear sir, I want to print some line with (") this sign,like: output should come ("hello world") instead of (hello world) thnx  hi friend, If you want to print "hello world",you have to use
Code Problem - Struts
Code Problem  Sir, am using struts for my application.i want to uses session variable value in action class to send that values as parameter to function.ex.when i login into page,i will welcome with corresponding user homepage
code problem - Java Beginners
code problem  Dear sir, i'm making a program where characters of a string are being displayed having its length thru a loop, like- s a t i s h i want to store them as sequence in a StringBuffer like "satish" how
code related problem
code related problem  this code is compiling but not running please help import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Mybutton11 extends JFrame { JTextField text1 = new JTextField(20
Java code problem
Java code problem  Please check the errors,if any,in this code...i am a java beginner import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map
code problem - Java Beginners
code problem  1)what is accurate use of access specifiers (plz give me all uses in options)..? 2)In folllowing options which can be used by the inner class....? a)private instance variables b)public instance variables c
Code Problem - Applet
Code Problem  How to set a background color for frame and panel ...? What is the difference btw these two(in setting background color)..?  Hi Friend, If you simply want to set background color for panel, try
Problem in EJB application creation - EJB
Problem in EJB application creation  Hi, I am new to EJB 3.0... application. 1. I would like to know how to associate an Entity bean class... getting the following error message when running an enterprise application
jsp code problem - JSP-Servlet
jsp code problem  Hi, I have employee details form in jsp. After... have a problem with open the next form. plz, help me. thanks,  Hi friend, Please give me detail and send me error code page. Please
jsp code problem - Java Beginners
jsp code problem  Hi, I have a problem with else part. It did not show the message box when the result set is null. plz, help me. thank u in advance
What are difference between Bean Factory and Application Context ?
What are difference between Bean Factory and Application Context ?  Hi, What are difference between Bean Factory and Application Context
Problem in my code - Development process
Problem in my code  Plz go thru this code. I want to check login and pwd with database. Backend MsAccess , Table name : Reg , Dsn Name: JJ While executing code am getting 404 error User Name Password
problem in java code - Java Beginners
problem in java code  In displaying an matrix in normal java code we use two for loops...When i attended an interview.....the hr asked me to display the matrix by only using one loop....there should be any condition or other
Spring Context - Writing Application Context
Spring Context - Writing Application Context  ... by defining the Application context definition file (applicationContext... application context. About Application ApplicationContext An ApplicationContext
Give me the source code for this problem
Give me the source code for this problem  Ram likes skiing a lot. That's not very surprising, since skiing is really great. The problem with skiing is one have to slide downwards to gain speed. Also when reached the bottom most

Ads