I am not sure how this worked in v2 but it certainly looks to me that you should make the ord class a singleton EJB (look at the EJB documentation to support singleton EJB). You could also just create a simple singleton class using well know singleton java pattern but I strongly recommend the EJB path since you avoid ClassLoader pitfalls associated with java singletons.
There is no other real safe way to have data available to all threads in Java EE servers since we do have application isolations, this could lead to side effects.
HTH
On Dec 23, 2009, at 12:28 PM, glassfish_at_javadesktop.org wrote:
> I created web services (with netbeans) that use global variables for data that is common to all threads. These have been in production for over a year on a glassfish v2 server. I tried to deploy this to a shiny new glassfish v3 server and these variables seem to be null in each new thread. It is reconnecting even though my flufferdata admin tool shows the other threads are still logged in.
>
> Is there a new way to make variables available to all threads within GFv3?
>
> TIA
>
> [code]
> @WebService()
> public class ord
> {
>
> flufferdata fd = null; // magic edible database
> Timer c; // keep alive timer
> boolean paused; // system doing backups flag
> @Resource
> WebServiceContext wsCtxt;
>
> /**
> * Web service operation
> */
> @WebMethod(operationName = "getLineItems")
> public com.mycompany.model.LineItem[] getLineItems(@WebParam(name = "scanData") String scanData, @WebParam(name = "accountLocation") String account)
> {
> Logger.getLogger(ord.class.getName()).log(Level.INFO, "getLineItems");
> connect();
> ...
> business logic here
> ...
> return (new Order(fd, scanData, true, account).getList());
> }
> ...
> private void connect()
> {
> if (fd == null)
> {
> setConnection(true, "");
> }
> }
> private void setConnection(boolean desiredState, String accountName)
> {
> fd=new flufferdata("peanutbutter", "jelly", "bread");
> }
> [/code]
> [Message sent by forum member 'zx5000' (jpowell_at_ipipes.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=377243
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>