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

Ads









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
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
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
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> <
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
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
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
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page
code for phone application
code for phone application  I wish to write a small android (or java) application that allows user to enter any number and when user clicks on dial... to view call log history from your application. It should also allow user to type
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new
Applet run with appletviewer but not in browser, any code problem.
Applet run with appletviewer but not in browser, any code problem.  Hi,My problem is when I am running my applet in appletviewer index.html, Its work... can be problem in code also. please check my code. 1) Card.java package
Problem with Java Source Code - Java Beginners
Problem with Java Source Code  Dear Sir I have Following Source Code ,But There is Problem with classes, plz Help Me. package mes.gui; import javax.swing.JOptionPane.*; import java.sql.*; import javax.swing.*; import
Java Compilation error. Hibernate code problem. Struts first example - Hibernate
Java Compilation error. Hibernate code problem. Struts first example  Java Compilation error. Hibernate code problem. Struts first example
Problem while using tomcat 6.0 in eclipse with struts application
Problem while using tomcat 6.0 in eclipse with struts application  Hi please provide solution for the following problem org.apache.jasper.JasperException: java.lang.ClassCastException
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting...,since i try to configure this out for 1 week,i dont find any solution for my problem. T_T I have develop my java web application in window Environment and now i
Problem in setting IP address for a JFrame Class Desktop Application
Problem in setting IP address for a JFrame Class Desktop Application  I have designed a browser for our final year project, it is working well. But when we put it in a system which has a proxy setting for internet connection
context
context  what is context in general in java ?   An association between a name and an object is called a binding, and a set of such bindings is called a context
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration... RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException... in database as text and set the mobile field or telephone field as string in your code
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration... RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException... in database as text and set the mobile field or telephone field as string in your code
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
Problem
(); stdIn.close(); echoSocket.close(); } } this is my code, compiled
Problem
(); echoSocket.close(); } } this is my code, compiled with no errors, but when running giving
problem
;Hi, What do you want to do with this code. Please clarify
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier...; Hi friend, For solving the problem visit to : http://www.roseindia.net

Ads