No Active Application Context
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
No Active Application Context  XML
Forum Index -> JBoss Seam Integration
Author Message
osian

Joined: 11/11/2008 00:00:00
Messages: 17
Offline


Hi,

I have, on screen, a simple progress bar being updated while some stuff happens in a thread in the background.
Once this thread is completed, I want to refresh the hibernate object that I have, but I keep on getting the exception:

Exception in thread "Thread-12" java.lang.IllegalStateException: No active application context
at org.jboss.seam.security.EntityPermissionChecker.instance(EntityPermissionChecker.java:55)
at org.jboss.seam.security.HibernateSecurityInterceptor.onLoad(HibernateSecurityInterceptor.java:36)
at org.hibernate.event.def.DefaultPreLoadEventListener.onPreLoad(DefaultPreLoadEventListener.java:41)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:148)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at com.nexustelecom.mediation.errorcorrection.wizard.FileSearch.areRecordsLoadedFor(FileSearch.java:635)
at com.nexustelecom.mediation.errorcorrection.wizard.FileSearch.ensureButtonStatuses(FileSearch.java:295)
at com.nexustelecom.mediation.errorcorrection.wizard.FileSearch.executeServerCommandComplete(FileSearch.java:407)
at com.nexustelecom.mediation.admind.shared.ExecuteCommandOnServerThread.run(ExecuteCommandOnServerThread.java:61)
at java.lang.Thread.run(Thread.java:619) 


Does anyone have any thoughts around this? Do I need to try and get the action that is being executed into conversation scope or something??

Thanks in advance,
Osian
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


Seam goes through the various contexts to find the seam component requested (in this case it looks like seam security). If you are bypassing the seam interceptors for some reason, this could be causing you problems (usually the ajax--like progress bar--will bypass the Seam interceptors). You could work around this by looking up the Seam Security features that you want in the view and place them in your backing bean (assign the security roles, id's etc that you are looking for in an @Init method perhaps when the interceptors are not being bypassed).
osian

Joined: 11/11/2008 00:00:00
Messages: 17
Offline


Hi Judy,

Thanks for your reply.

It would be easier for me to post some code to show you what I am attempting to do, but there is a lot of it, so let me try and explain:

1. A user clicks on a button, which causes a thread to be fired off and the progress bar to start.
2. The progress bar is updated through the thread while the thread is performing its processing
3. When the thread is complete, a call is made back to the calling component, which in this case is a seam component in conversation scope.
4. During this call to say that the thread is complete, I attempt to either refresh a hibernate object, or perform a search through hibernate to be able to update the screen with new information

Below are some snippets of code of the thread and the seam component:

Seam Component:
Code:
@Name("errorFileSearch")
 @Scope(ScopeType.CONVERSATION)
 public class FileSearch extends NexusEntityQuery<ErrorFile> implements ListDataValueChanged<String>, ExecuteServerCommandListener {
 
 	...
 	@Override
 	@Conversational
 	@Begin(join = true, flushMode=FlushModeType.MANUAL)
 	public void executeServerCommandComplete() {
 		getActionButtonManager().setAllButtonsTo(false);
 		ensureButtonStatuses();
 		getProgramManager().unlockAllOtherTabs();
 		if (isReprocessMode()) {
 			performSearch(0, false);
 		}
 		else if (isCorrectionWizardMultiMode() || isCorrectionWizardSingleMode()) {
 			for (ErrorFile file : getSelectedRecords()) {
 				//This is where the error is thrown
 				getSession().refresh(file);
 			}
 		}
 		//sets the progress bar to 100%
 		getActionButtonManager().getProgressBar().stopProgressBar();
 	}
 	... 
 }


Thread:
Code:
public class ExecuteCommandOnServerThread extends Thread implements Serializable {
 
 	private static final long serialVersionUID = 1L;
 
 	private ExecuteServerCommandListener executeServerCommandListener;
 	private Vector<ServerCommand> serverCommands = new Vector<ServerCommand>();
 	
 	/**
 	 * @param executeServerCommandListener
 	 * @param serverCommands
 	 */
 	public ExecuteCommandOnServerThread(ExecuteServerCommandListener executeServerCommandListener, Vector<? extends ServerCommand> serverCommands) {
 		this.executeServerCommandListener = executeServerCommandListener;
 		this.serverCommands.addAll(serverCommands);
 	}
 	
 	/**
 	 * @param serverCommand
 	 */
 	/**
 	 * @param executeServerCommandListener
 	 * @param serverCommand
 	 */
 	public ExecuteCommandOnServerThread(ExecuteServerCommandListener executeServerCommandListener, ServerCommand serverCommand) {
 		this.executeServerCommandListener = executeServerCommandListener;
 		serverCommands.add(serverCommand);
 	}
 
 	/* (non-Javadoc)
 	 * @see java.lang.Thread#run()
 	 */
 	@Override
 	public void run() {
 		long start = System.currentTimeMillis();
 		for (ServerCommand command : serverCommands) {
         	try {
 	            executeServerCommandListener.handleResponse(command, command.execute());
             } catch (IOException e) {
 	            e.printStackTrace();
             }
         }
 		long end = System.currentTimeMillis();
 		if ((end - start) < 1500) {
 	        try {
 		        Thread.sleep(2000);
 	        } catch (InterruptedException e) {}
 		}
 		//call the seam component to notify that all processing is complete
 		executeServerCommandListener.executeServerCommandComplete();
 	}
 }


Any ideas?
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


OK...so looking (briefly) at your snippets, the thread (which has no seam contexts) is attempting to do something that requires seam contexts --your xhtml page requires some type of seam security setting probably. Does this sound correct? You might want to remove (temporarily) any security settings you have on your xhtml page to see if this actually is the case.
You could also check the example for progress monitor in seam-comp-showcase to see how the thread is used in a static inner class with reference back to the seam component. There are further examples of thread managemet with progress monitor with ICEpack (if you have any type of support contract at all, you have access tot his).

osian

Joined: 11/11/2008 00:00:00
Messages: 17
Offline


Hi Judy,

Thanks again for getting back to me so quickly.

I don't have any security in use in my application at the moment, so I don't believe that this should be causing any issues.

Wrt the example, my class is performing exactly the same actions, the only difference is that I attempt to do something with the hibernate objects, and this is where the problem arises. Strangely enough, it doesn't happen all of the time, but obviously I don't want it to happen at all :-)

Do the examples in icepack do something similar to what I am trying to acheive? (I don't have a support contract currently, so I don't have access to it).

I have a feeling that it is to do with the rendering phase, Seam probably requires more phases to take place for what I want to acheive, but I don't know how to initiate those from the code.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


Take a look at your pages.xml and see if you have any restrictions setup on that page (for example if you are forcing the user to be logged in?--that would require seam security). Also please take a look at the thread examples in seam-comp-showcase for progress monitor. You can see the "named" seam component maintains control (rather than passing it off to the inner class which has not access to the seam contexts.
 
Forum Index -> JBoss Seam Integration
Go to:   
Powered by JForum 2.1.7ice © JForum Team