[EJB 3.0] - Re: Automatic Destroy State in Stateful Session Bean
by grdzeli_kaci
ok, I find another problem :
1.i have interface
| package com.magti.businesslayer.ejb3entity.oracle;
|
| import javax.ejb.Remote;
|
| @Remote
| public interface MyState {
| public void initialize();
| }
|
2. Implementation :
| package com.magti.businesslayer.ejb3entity.oracle;
|
| import javax.ejb.Remote;
| import javax.ejb.Stateless;
|
| @Stateless
| @Remote(MyState.class)
| public class StateBean implements MyState
| {
| String name = null;
|
| public void initialize()
| {
| if (name == null)
| {
| System.out.println("Null");
| name = "Initialize";
| }
| else
| {
| System.out.println("Not Null -> "+name);
| }
| }
| }
|
3. Test Client
package com.magti.businesslayer.ejb3entity.oracle;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class TestMain
{
public static void main(String[] args)
{
try
{
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
jndiProps.setProperty(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interface");
jndiProps.setProperty(Context.PROVIDER_URL,
"jnp://192.168.9.136:1099");
InitialContext ctx = new InitialContext(jndiProps);
MyState state = (MyState) ctx.lookup("StateBean/remote");
state.initialize();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
|
| when i run client fierst time i get this result :
| 21:47:33,652 INFO [STDOUT] Null
|
| second time :
| 21:47:34,652 INFO [STDOUT] Null
|
| third time :
| 21:47:35,652 INFO [STDOUT] Initialize
|
| forth time
| 21:47:36,652 INFO [STDOUT] Initialize
|
| fifth time :
| 21:47:37,652 INFO [STDOUT] Initialize
|
| .....
| .....
|
|
| can anybody explain me why ?
|
| this session bean is stateless.
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976122#3976122
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976122
19 years, 7 months
[JBossWS] - Re: How do I logout on a JSR 181 endpoint?
by sappenin
Ok,
I solved my problem. As it turns out, I had a bug in my code on the Flex side that was adding a WSSE header every time I logged out/logged in (but never removing the headers, and re-using the WebService object used to make calls to the JBossWS). So, while I did have the new credentials to login as, I still had the old credentials in the Webservice object, which were getting passed to JBoss.
So, after correcting for this error on my part, I can now send multiple WS requests as different users without shutting down my browser, exiting the Flash client, or "invalidating" anything on the server side.
Apparently, all JbossWS calls are stateless. (Ahem).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976118#3976118
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976118
19 years, 7 months
[JBossWS] - Re: How do I logout on a JSR 181 endpoint?
by sappenin
Ok, so I recognize that while using BASIC auth, the browser controls the login session, and nothing on the server side can logout a "BASIC" authenticated client.
Just FYI, I'm calling a JBoss webservice from an Adobe FLEX Flash application running in the browser.
So, I turned BASIC auth OFF on my webservices EJB endpoint, and am now using WSSE UsernameToken to authenticate the Flash client to my JSR 181 EJB endpoint.
However, for whatever reason, if I make some WS calls as User A, then make some WS calls as User B (essentially, changing the WSSE username/password tokens), Jboss still thinks I'm user A.
I did some digging on my JBoss server (DEBUG mode), and noticed that the WSSE client calls are happening via Http POST. Since my username is being "remembered" by the JBoss server, there must be some sort of session getting established? (This seems to be functioning a lot like FORM-based authentication). In a typical servlet, I could simply "logout" by invalidating the session. HOW does one do that with an EJB? I don't see anyway to get access to the Session....so I don't know how to invalidate it.
Any ideas?
Thanks!
David
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976111#3976111
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976111
19 years, 7 months