Accessing static object across portlets

hi
in portal server 7.1, i had a static object that is used by all the portlets by usebean tag in jsp. it works fine
for all the tabs that i created. But when i tried to access the page in new browser, the same static object exists.
how, the object exists for the new session also. the bean code i called from jsp is...
public class ObjectDispatcher {
/** Creates a new instance of ObjectDispatcher */
private static SessionDispatcher dispatcher;
public ObjectDispatcher() {  }
public SessionDispatcher getDispatcher() {
if (dispatcher == null) {
dispatcher = new SessionDispatcher();
return dispatcher;
the jsp portlet code to call the bean is :
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8" import="com.test.SessionDispatcher"%>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<portlet:defineObjects />
<%PortletPreferences prefs = renderRequest.getPreferences();%>
<jsp:useBean id="objdispatcher" class="com.test.ObjectDispatcher" scope="session"/>
<%
SessionDispatcher bosession = objdispatcher.getDispatcher();
out.println(" got dispatcher "+bosession);
String sessid = bosession.getSessionID();
%>
the bosession object is printed for all the portlets across the tab give the same portlet object that is fine.
but for new browser also, the same object is printing.
i want to create new object when new explorer opens.
please help to resolve this issue

hi
in portal server 7.1, i had a static object that is used by all the portlets by usebean tag in jsp. it works fine
for all the tabs that i created. But when i tried to access the page in new browser, the same static object exists.
how, the object exists for the new session also. the bean code i called from jsp is...
public class ObjectDispatcher {
/** Creates a new instance of ObjectDispatcher */
private static SessionDispatcher dispatcher;
public ObjectDispatcher() {  }
public SessionDispatcher getDispatcher() {
if (dispatcher == null) {
dispatcher = new SessionDispatcher();
return dispatcher;
the jsp portlet code to call the bean is :
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8" import="com.test.SessionDispatcher"%>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<portlet:defineObjects />
<%PortletPreferences prefs = renderRequest.getPreferences();%>
<jsp:useBean id="objdispatcher" class="com.test.ObjectDispatcher" scope="session"/>
<%
SessionDispatcher bosession = objdispatcher.getDispatcher();
out.println(" got dispatcher "+bosession);
String sessid = bosession.getSessionID();
%>
the bosession object is printed for all the portlets across the tab give the same portlet object that is fine.
but for new browser also, the same object is printing.
i want to create new object when new explorer opens.
please help to resolve this issue

Similar Messages

  • Thread safety bug in XPS Serializer or FixedDocument sequence? "calling thread cannot access this object..."

    Every once in a while (500 iterations or more) I'm getting an exception in the static method below stating "calling thread cannot access this object because a different thread owns it".  Thing is, this method references no external objects
    and performs no special threading operations.  All of the WPF objects are created and consumed in this method.  The only aspect that is multi-threaded is that this method can get called concurrently on different threads in the same app domain (the
    project is a Windows service). That said the fileToDecollate parameter will be unique every time, so there is no "collision" as far as that goes.
    Any ideas?   This is maddening and in theory it should not be possible to blow this error.
    Exception Information------------------------------------------
    System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
       at System.Windows.Threading.Dispatcher.VerifyAccess()
       at System.Windows.DependencyObject.GetLocalValueEnumerator()
       at System.Windows.Xps.Serialization.SerializersCacheManager.GetTypeDependencyPropertiesCacheItem(Object serializableObject)
       at System.Windows.Xps.Serialization.SerializersCacheManager.GetSerializableDependencyProperties(Object serializableObject)
       at System.Windows.Xps.Serialization.SerializablePropertyCollection.InitializeSerializableDependencyProperties()
       at System.Windows.Xps.Serialization.SerializablePropertyCollection.Initialize(PackageSerializationManager serializationManager, Object targetObject)
       at System.Windows.Xps.Serialization.SerializableObjectContext.CreateContext(PackageSerializationManager serializationManager, Object serializableObject, SerializableObjectContext serializableObjectParentContext, SerializablePropertyContext serializablePropertyContext)
       at System.Windows.Xps.Serialization.ReachSerializer.DiscoverObjectData(Object serializedObject, SerializablePropertyContext serializedProperty)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.FixedDocumentSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.SerializeDocumentReference(Object documentReference)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.SerializeDocumentReferences(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(SerializablePropertyContext serializedProperty)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeProperty(SerializablePropertyContext serializablePropertyContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeProperties(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObjectCore(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.DocumentSequenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
       at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
       at System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(Object serializedObject)
       at System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(Object serializedObject, Boolean isSync)
       at System.Windows.Xps.XpsDocumentWriter.Write(FixedDocumentSequence fixedDocumentSequence)
       at MyCompany.Utilities.Document.XPSDocument.Decollate(String fileToDecollate, String outputPath) in E:\Projects\MyCompany\Utilities\MyCompany.Utilities.Document\XPSDocument.cs:line 358
       at MyCompany.Services.ERM.XPSCapture.Decollate(String fileToDecollate, String outputPath) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\XPSCapture.cs:line 210
       at MyCompany.Services.ERM.ERMFileProcessor.decollateERMFile(String tempERMFile, IFileCapture fileCapture) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\ERMFileProcessor.cs:line 1257
       at MyCompany.Services.ERM.ERMFileProcessor.process() in E:\Projects\doc-link\MyCompany\Services\Altec.Services.ERM\ERMFileProcessor.cs:line 354
       at MyCompany.Services.ERM.ERMFileProcessor.Process(ProcessingCompleteCallback callback) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\ERMFileProcessor.cs:line 90
    Additonal Info------------------------------------------
    ExceptionManager.MachineName: BTP-30-DEV
    ExceptionManager.WindowsIdentity: XXXXX-WA\Bradley
    ExceptionManager.FullName: WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    ExceptionManager.AppDomainName: MyCompany.XXXXXXServiceHost.exe
    ExceptionManager.ProcessInfo: PID=7392, ThreadID=7816, Managed ThreadID=36, Name=MyCompany.XXXXXXServiceHost, Uptime=00:02:12.2548416
    ExceptionManager.ProcessResourceUsage: Working Set=265188 KB, Peak Working Set=525940 KB, Virtual Memory Size=530264 KB, Peak VM Size=809832 KB, Handles=631
    ExceptionManager.SystemMemory: Load=81%, Total Physical=3168748 KB, Free Physical=586736 KB, Total PageFile=5213700
    publicstaticList<string>
    Decollate(stringfileToDecollate,
    stringoutputPath)
      // iterate fixed documents and fixed pages, create new XPS files
    List<string>
    xpsDecFiles = newList<string>();
      using(XpsDocumentxpsSourceDocument
    = newXpsDocument(fileToDecollate,
    FileAccess.Read))
        FixedDocumentSequencefixedDocSeq
    = xpsSourceDocument.GetFixedDocumentSequence();
        intpageNumber = 0;
        foreach(DocumentReferencedocReference
    infixedDocSeq.References)
          FixedDocumentsourceFixedDoc
    = docReference.GetDocument(false);
          foreach(PageContentpage
    insourceFixedDoc.Pages)
            pageNumber++;
            // prepare new fixed doc sequence
    FixedDocumentSequencenewFixedDocSeq
    = new
    FixedDocumentSequence();
    DocumentReferencenewDocReference
    = new
    DocumentReference();
    FixedDocumentnewFdoc
    = new
    FixedDocument();
    newDocReference.SetDocument(newFdoc);
    // copy the page
    PageContentnewPage =
    new
    PageContent();
    newPage.Source = page.Source;
    (newPage asIUriContext).BaseUri
    = ((IUriContext)page).BaseUri;
    // tickle this method... presumably just to load the FixedPage data.
    FixedPagenewFixedPage
    = newPage.GetPageRoot(false);
    // Add page to fixed doc sequence.
    newFdoc.Pages.Add(newPage);
    // Always do this last: add document reference to fixed doc sequence. 
    newFixedDocSeq.References.Add(newDocReference);
    // create and save new XPS doc                   
    stringdecFileName =
    Path.Combine(outputPath,
    Path.GetFileNameWithoutExtension(fileToDecollate)
    + "~"+ (pageNumber).ToString()
    + FileExtensions.XPS);
    if(File.Exists(decFileName))
    File.Delete(decFileName);
    XpsDocumentnewXPSDoc
    = new
    XpsDocument(decFileName,
    FileAccess.ReadWrite);
    // testing.  thread IDs should be the same.
    //Debug.Assert(System.Windows.Threading.Dispatcher.CurrentDispatcher.Thread.ManagedThreadId == newFixedDocSeq.Dispatcher.Thread.ManagedThreadId);
    XpsDocument.CreateXpsDocumentWriter(newXPSDoc).Write(newFixedDocSeq);
    newXPSDoc.Close();
    // add file to list
    xpsDecFiles.Add(decFileName);
      returnxpsDecFiles;

    I have opened a support case with Microsoft through my employer.  I'm convinced there is some .NET framework code that is not thread safe.  I did put together a test harness app that demonstrates the problem (within 30 seconds or so after
    you start it) and I sent that to MS support.  They're looking into it. Anyone else who is curious can download the sample project here:
    https://skydrive.live.com/redir?resid=5CBB4B55BCCB2D67!443&authkey=!AGEnR3CKrXUU6E0
    Bradley
    Bradley P.

  • Getting ClassCastException while accessing ServletRequest object.

    Hi,
    I am using weblogic 8.1 sp4 and I am trying to deploy a JSF portal application. When I try to access ServletRequest object, it throws a ClassCastException.
    code snippet -
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    ServletRequest servletRequest = (ServletRequest)externalContext.getRequest(); // Throws error at this point.
    It works fine if I use PortletRequest instead of ServletRequest. But I am trying to make it independent of portal API. Is there any way by which I can access servletRequest object?
    If I run this application outside portal environment(i.e. only on JSF fraemwork), it works fine.
    Here is the error i get in my browser -
    javax.portlet.PortletException: Error Invoking Method '#{ValidateServlet.Validate}' : java.lang.ClassCastException at com.sun.faces.portlet.FacesPortlet.processAction(FacesPortlet.java:236) at com.bea.portlet.container.PortletStub.processAction(PortletStub.java:277) at com.bea.portlet.container.AppContainer.invokeProcessAction(AppContainer.java:428) at com.bea.netuix.servlets.controls.content.JavaPortletContent.fireProcessAction(JavaPortletContent.java:202) at com.bea.netuix.servlets.controls.portlet.JavaPortlet.fireProcessAction(JavaPortlet.java:1091) at com.bea.netuix.servlets.controls.portlet.JavaPortlet.raiseChangeEvents(JavaPortlet.java:566) at com.bea.netuix.nf.ControlLifecycle$4.postVisitRoot(ControlLifecycle.java:298) at com.bea.netuix.nf.ControlTreeWalker.walkRecursive(ControlTreeWalker.java:315) at com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:127) at com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:106) at com.bea.netuix.nf.Lifecycle.runInbound(Lifecycle.java:173) at com.bea.netuix.nf.Lifecycle.run(Lifecycle.java:137) at com.bea.netuix.servlets.manager.UIServlet.runLifecycle(UIServlet.java:321) at com.bea.netuix.servlets.manager.UIServlet.doPost(UIServlet.java:184) at com.bea.netuix.servlets.manager.PortalServlet.doPost(PortalServlet.java:767) at com.bea.netuix.servlets.manager.UIServlet.service(UIServlet.java:138) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilter.java:293) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6724) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178) Caused by: javax.faces.el.EvaluationException: Error Invoking Method '#{ValidateServletJ.Validate}' : java.lang.ClassCastException at com.sun.faces.el.MethodBindingImpl.rethrow(MethodBindingImpl.java:109) at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:101) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72) at javax.faces.component.UICommand.broadcast(UICommand.java:312) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381) at com.sun.faces.portlet.LifecycleImpl$InvokeApplicationPhase.execute(LifecycleImpl.java:524) at com.sun.faces.portlet.LifecycleImpl.phase(LifecycleImpl.java:246) at com.sun.faces.portlet.LifecycleImpl.execute(LifecycleImpl.java:156) at com.sun.faces.portlet.FacesPortlet.processAction(FacesPortlet.java:222) ... 29 more Caused by: java.lang.ClassCastException at work.ValidateServletJ.Validate(ValidateServletJ.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sun.faces.el.impl.MethodInvokeVisitor.handleMethod(MethodInvokeVisitor.java:44) at com.sun.faces.el.impl.MethodAbstractVisitor.visit(MethodAbstractVisitor.java:354) at com.sun.faces.el.impl.AstValue.jjtAccept(AstValue.java:16) at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:93) ... 37 more Nested Exception is javax.faces.el.EvaluationException: Error Invoking Method '#{ValidateServletJ.Validate}' : java.lang.ClassCastException at com.sun.faces.el.MethodBindingImpl.rethrow(MethodBindingImpl.java:109) at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:101) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72) at javax.faces.component.UICommand.broadcast(UICommand.java:312) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381) at com.sun.faces.portlet.LifecycleImpl$InvokeApplicationPhase.execute(LifecycleImpl.java:524) at com.sun.faces.portlet.LifecycleImpl.phase(LifecycleImpl.java:246) at com.sun.faces.portlet.LifecycleImpl.execute(LifecycleImpl.java:156) at com.sun.faces.portlet.FacesPortlet.processAction(FacesPortlet.java:222) at com.bea.portlet.container.PortletStub.processAction(PortletStub.java:277) at com.bea.portlet.container.AppContainer.invokeProcessAction(AppContainer.java:428) at com.bea.netuix.servlets.controls.content.JavaPortletContent.fireProcessAction(JavaPortletContent.java:202) at com.bea.netuix.servlets.controls.portlet.JavaPortlet.fireProcessAction(JavaPortlet.java:1091) at com.bea.netuix.servlets.controls.portlet.JavaPortlet.raiseChangeEvents(JavaPortlet.java:566) at com.bea.netuix.nf.ControlLifecycle$4.postVisitRoot(ControlLifecycle.java:298) at com.bea.netuix.nf.ControlTreeWalker.walkRecursive(ControlTreeWalker.java:315) at com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:127) at com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:106) at com.bea.netuix.nf.Lifecycle.runInbound(Lifecycle.java:173) at com.bea.netuix.nf.Lifecycle.run(Lifecycle.java:137) at com.bea.netuix.servlets.manager.UIServlet.runLifecycle(UIServlet.java:321) at com.bea.netuix.servlets.manager.UIServlet.doPost(UIServlet.java:184) at com.bea.netuix.servlets.manager.PortalServlet.doPost(PortalServlet.java:767) at com.bea.netuix.servlets.manager.UIServlet.service(UIServlet.java:138) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilter.java:293) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6724) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178) Caused by: java.lang.ClassCastException at work.ValidateServletJ.Validate(ValidateServletJ.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sun.faces.el.impl.MethodInvokeVisitor.handleMethod(MethodInvokeVisitor.java:44) at com.sun.faces.el.impl.MethodAbstractVisitor.visit(MethodAbstractVisitor.java:354) at com.sun.faces.el.impl.AstValue.jjtAccept(AstValue.java:16) at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:93) ... 37 more
    Any pointers will be greatly appreciated.
    Thanks
    Kunal

    Kunal,
    A PortletRequest/RenderRequest is not a ServletRequest - the two are not the same and don't share a common superclass or interface other than java.lang.Object. So simple casting like you're doing won't work.
    Are you trying to call a method that is only found on ServletRequest and not on PortletRequest/RenderRequest. If so, you're out of luck. You don't have a ServletRequest object inside the portal, so you can't call methods that aren't on the RenderResponse object.
    If the method(s) you're calling are common to both classes then you can use reflection to access the desired methods and avoid a CCE. A good pattern for this type of situation is "Duck Typing" - a description of Duck Typing in Java can be found here:
    http://www.coconut-palm-software.com/the_visual_editor/?p=25
    Hope that's helpful.
    Regards,
    Peter

  • Synchronization on a static object

    If I have a code like:
    synchronized(_otherParsers)
    _otherParsers = new Vector();
    } knowing the _otherParsers is a static object in the class, the synchronization will block all access to the object or it will block the access to the sync. block?
    OBS: So when one thread enters the synchronized block, accesses to that object by other threads are blocked until the original thread exits the synchronized block. [PENDING: verify previous statement, and figure out if synch'ed blocks block out all method calls on the object or just synch'ed ones] (quote from Java Tutorial, http://java.sun.com/docs/books/tutorial/together/bingo/synchronized.html)

    IIRC, when using synchronize(someObject) then
    someObject is locked, meaning that the original object
    isn't locked. So other methods will execute correctly.let's say the following:import java.util.Vector;
    public class A {
      public static Vector v = null;
      public A() {
        v = new Vector();
      public static void main(String[] args)
         B b = new B();
         new Thread(b).start();
         new A();
    class B implements Runnable {
      public void run() {
        synchronized(A.v) {
            A.v = new Vector();
            A.v.add("test");
    }As you can clearly see, the static vector, member of A class is initialized twice (once by the new A() in the main method of A class and once by A.v = new Vector() in the run() method of B class). Assuming the thread enters the synchronized block before the call to new A() in the main method, when that call ocures, is the A.v object locked? or not?

  • Static Object Vs. Lots of referece passing...

    I am implementing a discrete event simulator for which there is only ever one "executor" object and one "output manager" object used to advance time and deal with output to files. However many objects in the simulator need access to these objects and there "security" is not an issue. I was wondering if anyone knows if it is gives better performance to make these classes with static methods or whether I should pass a reference to them to nearly every other object. Also do you know why whatever one is beter?
    Cheers,
    Mark

    For this project performance really is the issue
    though. My concern is that if I pass a reference of
    an object to lots of other objects (in the order of
    100,000) that is simply a waste of time and memory
    So let's get this straight. You can have 100,000 Objects, but you can't add one reference varialble to each.
    if making the objects access methods static may
    remove this I will happily accept this over
    management and testability issues. What do you think making the method static will save you, exactly?
    What I really want to know is for example...
    is the above less effective than...No, generally , static methods are less effective than instance methods.
    if StaticObjectType in the later example is the same
    as the OtherObjectType in the first example., but
    with a static method, given that only one instance of
    OtherObjectType will ever exist. This makes no sense. There is no such thing as a 'static' Object. Static only applies to references and methods and nested classes.
    My worry is that passing this object address around
    and storing it as a field will be far less effective
    than having just a static method, although I am not
    sure this is true.There is a slight performance hit when calling an instance method over a static method. Declaring a method final may remove this. When I say slight, I mean really slight. Both methods are called in the basically the same manner.
    As this is happening thousands of times a second in
    this program and storage and speed are key really
    just need to choose the most efficient
    implementation.Again I don't understand how you can afford o have thousands of Objects but can't afford an extra reference on them.

  • Please tell me the way to access the object...........?

    when we are decleared a class variable,there should be an object in the memory.this object is the object of the java.obj.Class class.............
    my query is ..
    how to acess that object ?
    e.g.
    public class Basic
    public class Acsess{
    Basic b;//now please tell how access the object of class Basic.Class?......
    thanks and regurds

    I believe that the following example will help. You should also read this tutorial page:
    [Understanding Instance and Class Members|http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html]
    class A
        static String fie = "this is fie";
        String foo = "this is foo";
    public class B
        public static void main(String[] args)
            System.out.println(A.fie);
            A instance = new A();
            System.out.println(instance.fie); // Not recommended; does not
                                              // make it clear that fie is
                                              // a class (static) variable
            System.out.println(instance.foo);
    }

  • Sharing of Objects across applications

    Hi,
    Is it possible to reference an object initialized by another application?
    For example, I have a Logger object that I instantiated from App1. Then I decided to come up with App2. I want to use in App2, the same logger innstance I am using in App1. Of course, assuming that App1 is running. If not, App2 shall create the Logger object and when App1 is run, App1 now shall reference the Logger object App2 created.
    I guess what I am pointing out here is how sharing of objects across application can happen in Java.

    There is no direct support for this in JVM - you cannot reference object created by JVM#1 from JVM#2 playing fair game =)
    If you need 100% pure JAVA solution the only way to do it is to use
    networking, either RMI (as it was already suggested) or coding your own TCP protocol. Main drawback - it'll be slow.
    For faster access you'll need to use JNI and some sort of interprocess communication method - shared memory/messages/etc. This might be faster (there will be no TCP/IP marshaling) but it'll be more combersome to support it for different OS.

  • Access to object in xmlns

    Hi,
    I've come across such a silly probem shown in example below:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:views="*" creationComplete="initApp()">
        <mx:Script>
            <![CDATA[
         import mx.controls.Text;
         public function initApp()
          label1.text = "View1 changed";
         ]]>
        </mx:Script>
        <views:view1 label="view1" width="100%" />
    </mx:Application>
    view1.xml file contains:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%">
    <mx:Label id="label1" x="10" y="50" text="View1"/>
    </mx:Canvas>
    It renders error:
    1120: Access of undefined property label1.
    How can I access label1 object from main file?

    Next I wanted to call function declared in main app:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:views="*">
        <mx:Script>
            <![CDATA[
            import mx.controls.Button;
         public function test():void
         ]]>
        </mx:Script>
        <views:view1 id="myComp" />
    </mx:Application>
    view1.mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%">
    <mx:Button id="button1" label="Button1" click="test()"/>
    </mx:Canvas>
    1180: Call to a possibly undefined method test.    ViewStackTest/src    view1.mxml    line 3    1251498782218    1661
    How can reference to test()?

  • Using public static object for locking thread shared resources

    Lets Consider the example,
    I have two classes
    1.  Main_Reader -- Read from file
    public  class Main_Reader
         public static object tloc=new object();
           public void Readfile(object mydocpath1)
               lock (tloc)
                   string mydocpath = (string)mydocpath1;
                   StringBuilder sb = new StringBuilder();
                   using (StreamReader sr = new StreamReader(mydocpath))
                       String line;
                       // Read and display lines from the file until the end of 
                       // the file is reached.
                       while ((line = sr.ReadLine()) != null)
                           sb.AppendLine(line);
                   string allines = sb.ToString();
    2. MainWriter -- Write the file
    public  class MainWriter
          public void Writefile(object mydocpath1)
              lock (Main_Reader.tloc)
                  string mydocpath = (string)mydocpath1;
                  // Compose a string that consists of three lines.
                  string lines = "First line.\r\nSecond line.\r\nThird line.";
                  // Write the string to a file.
                  System.IO.StreamWriter file = new System.IO.StreamWriter(mydocpath);
                  file.WriteLine(lines);
                  file.Close();
                  Thread.Sleep(10000);
    In main have instatiated two function with two threads.
     public string mydocpath = "E:\\testlist.txt";  //Here mydocpath is shared resorces
             MainWriter mwr=new MainWriter();
             Writefile wrt=new Writefile();
               private void button1_Click(object sender, EventArgs e)
                Thread t2 = new Thread(new ParameterizedThreadStart(wrt.Writefile));
                t2.Start(mydocpath);
                Thread t1 = new Thread(new ParameterizedThreadStart(mrw.Readfile));
                t1.Start(mydocpath);
                MessageBox.Show("Read kick off----------");
    For making this shared resource thread safe, i am using  a public static field,
      public static object tloc=new object();   in class Main_Reader
    My Question is ,is it a good approach.
    Because i read in one of msdn forums, "avoid locking on a public type"
    Is any other approach for making this thread safe.

    Hi ,
    Since they are easily accessed by all threads, thus you need to apply any kind of synchronization (via locks, signals, mutex, etc).
    Mutex:https://msdn.microsoft.com/en-us/library/system.threading.mutex(v=vs.110).aspx
    Thread signaling basics:http://stackoverflow.com/questions/2696052/thread-signaling-basics
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Accessing static context from instances...

    Hello,
    I'm confused with something. Accessing static elemnts or static methods from an instance is allowed. I think it shouldn't be allowed. Because static context is class-wide so objects shouldn't be able to access them.
    Am I wrong..?

    I find it confusing.. If something is class-wide then
    it should only be accessed by the class, not the
    instance of the class...That depends on the nature or purpose of the information. Static information or methods are a useful way of sharing information between instances of the same class, while still having that information protected from other classes. Other examples are constants which are used within each instance. Why should each instance have a separate copy of exactly the same constant?
    You could even argue that any method which does not need any instance information should be declared static, but it is not always necessary to make that distinction.
    Eclipse (mine at least :) ) gives a warning when you access a static
    method/variable 'through' an instance, telling you that you should access >the method/variable in a static way.This warning usually occurs if you call a static method in a non static way. For example, if you declare a class called MyClass with a static method myMethod() and you have an instance assigned to variable anInstance, you should call the method using MyClass.myMethod() instead of anInstance.myMethod().
    Graeme

  • How to access an object in a bean

    I am looking for a way to access an object in a bean and make available to the page.
    for example if i have a Bean called User and it contains an attribute Called Company as an attribute in User. Now I have User.getCompany(). and I can do this
    <%User user = request.getUser();
    Company company = user.getCompany();
    request.setAttribute("comp", company); %>
    how do I do this with useBean ?

    I am looking for a way to access an object in a bean
    and make available to the page.
    for example if i have a Bean called User and it
    contains an attribute Called Company as an attribute
    in User. Now I have User.getCompany(). and I can do
    this
    <%User user = request.getUser();
    Company company = user.getCompany();
    request.setAttribute("comp", company); %>
    how do I do this with useBean ?You can access a JavaBean Object property of another JavaBean inside the JSP with the use of EL (Expression Language)
    So if you are using JSP 2.0 or higher try this:
    <jsp:useBean id="user" class="your.package.User" scope="request"/>
    ${user.company.id}I tested the above and it works.
    Note that you need to set the Company object in the User object before trying to access it inside the JSP.
    You can also set it in the JSP if you want, (before trying to access it), but its cleaner to do it in a Servlet.
    Both User and Company must follow JavaBeans notation.
    So in the above case the User object is something like this:
    package your.package;
    public class User{
       private Customer customer;
       public User(){}
       public Customer getCustomer(){
          return customer;
       public void setCustomer(Customer customer){
         this.customer = customer;
    }And your Customer JavaBean is something like this:
    package your.package;
    public class Customer{
       private int id;
       public Customer(){}
       public int getId(){
         return this.id;
       public void setId(int id){
         this.id = id;
    }

  • Hyper-V encountered an error trying to access an object on computer ...

    I'd like to share an issue which occurred during one of my recent configurations as well as the associated solution which worked for me.
    While configuring Hyper-V Manager on a non-domain joined Windows 8.1 Enterprise client, to communicate with a non-domain joined Microsoft Hyper-V Server 2012R2, I received the following enjoyable message:
    Hyper-V encountered an error trying to access an object on computer '.....' because the object was not found. The object might have been deleted. or you might not have permission to perform the task. Verify that the Virtual Machine Management service
    on the computer is running. If the service is running, try to perform the task again by using Run as Administrator.
    As it turns out I forgot to change the machine name on the Hyper-V server. It's worth noting that it's also necessary to add an entry in the client machine's HOSTS file which matches the computer name of the Hyper-V server.

    Hi ITMAGE,
    Thanks for your sharing and support for this forum .
    It should be helpful to other people who are facing this issue .
    Best Regards,
    Elton JI
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Add ABAP program: validating package - error accessing shared objects-area

    When adding a new program or browsing the packages in eclipse i get an "error accessing shared objects-area".
    I can edit, save and run existing ABAP reports, however.
    There was a similar problem here, regarding database procedure proxies but the solution doesn't apply to my problem, i guess. The solution was about creating the shared memory area CL_RIS_SHM_AREA. I can't access the memory area and start the constructor, as it doesn't show up on the monitor.
    ADT 2.28
    Eclipse 4.3
    Netweaver 7.31 SP4 -> is this really compatible with ADT 2.28?
    Thanks in advance for helpful hints,
    Julian

    HI Julian,
    if the area doesn't show up in the monitor, please try to start the constructor in transaction SHMM on your own by selecting the icon 'Start Constructor' as shown in the screenshot.
    Choose CL_RIS_SHM_AREA as area, select 'Default Instance' and 'Dialog' as execution mode. Then press 'Create'. Either this works or the system will tell you the issue with the instance creation (e.g. insufficient shared objects memory - see the other solution description).
    Best regards, Sebastian

  • DBMS_SQL.PARSE to access remote objects

    I am using following code in a procedure ...
    DBMS_SQL.PARSE (cur, vSQL, DBMS_SQL.NATIVE);
    where variable vSQL can contain a remote object.
    A DB link (with Fixed User option) exists to access that database.
    The DB link is working. The remote object is accessible outside this procedure.
    When this command is executed, I get ...
    ORA-24374: define not done before fetch or execute and fetch
    ... error.
    Can DBMS_SQL handle remote objects?
    Oracle version is 9.2.0.5.0
    Any help would be greatly appreciated.

    Here is the code I am running ...
    CREATE OR REPLACE PROCEDURE p_sql_valid_or_not_cnt
    (vSQL IN VARCHAR2, vValid OUT NUMBER, vMessage OUT VARCHAR2, vCount OUT NUMBER) IS
    -- Purpose: Returns 0 in vvalid if SQL is valid, else returns -1. Returns row count when SQL is valid.
    -- Parameters:
    -- IN : vSQL
    -- OUT : vValid
    -- OUT : vMessage
    -- OUT : vCount
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    BEGIN
    DBMS_SQL.PARSE (cur, vSQL, DBMS_SQL.NATIVE);
    fdbk := DBMS_SQL.EXECUTE (cur);
    vCount := 0;
    LOOP /* Fetch next row. Exit when done. */
    EXIT WHEN DBMS_SQL.FETCH_ROWS (cur) = 0;
    vCount := vCount + 1;
    END LOOP;
    vValid := 0;
    vMessage := 'No errors';
    DBMS_SQL.CLOSE_CURSOR (cur);
    END p_sql_valid_or_not_cnt;
    To run ...
    set serveroutput on
    declare
    i number;
    m varchar2(500);
    c number;
    begin
    p_sql_valid_or_not_cnt('SELECT * FROM TAB where 1 <> 1',i,m,c);
    DBMS_OUTPUT.PUT_LINE(i);
    DBMS_OUTPUT.PUT_LINE(m);
    DBMS_OUTPUT.PUT_LINE(c);
    end;
    This runs fine.
    But when I try to access an object from a remote server using DB link. I get the error ...
    set serveroutput on
    declare
    i number;
    m varchar2(500);
    c number;
    begin
    p_sql_valid_or_not_cnt('SELECT * FROM REMOTE_SCHEMA.T_REMOTE@REMOTE_SERVER where 1 <> 1',i,m,c);
    DBMS_OUTPUT.PUT_LINE(i);
    DBMS_OUTPUT.PUT_LINE(m);
    DBMS_OUTPUT.PUT_LINE(c);
    end;
    declare
    ERROR at line 1:
    ORA-24374: define not done before fetch or execute and fetch
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 1125
    ORA-06512: at "SYS.DBMS_SQL", line 328
    ORA-06512: at "IMEPAS.P_SQL_VALID_OR_NOT_CNT", line 16
    ORA-06512: at line 6
    I can run the SQL that I am passing as vSQL directly in SQLPLUS ...
    This code in itself works.
    SELECT * FROM
    REMOTE_SCHEMA.T_REMOTE@REMOTE_SERVER
    where 1 <> 1;
    The user I am using to logon to my server is also there on REMOTE_SERVER.
    The DB LINK is created by CONNECTED USER option. The user on REMOTE_SERVER has explict select access on the table (not via role) I am accessing.
    Any help would be much appreciated.

  • Unable to access the objects with out schema as prefix.. can any body help

    Hi,
    i am using 10g.I have one problem like i unable to get the table access with out mention prefix for that table.
    but i created public synonym and gave all grants to all users also. but still i need to mention schema name as prefix otherwise it give the error..
    can any body tell me reason and give me solution.
    ex: owner:eiis table:eiis_wipstock
    connect to: egps schema
    in this position if i try with eiis.wipstock it gives error but if i mention like eiis.wiis_wipstock then its working fine.

    Pl do not spam the forums with duplicate posts - Unable to access the objects with out schema as prefix.. can any body help

Maybe you are looking for

  • Error Message during posting return delivery against materil document

    Dear experts I have created a purchase order with batch specific unit of measure KAI. I created the inbound  delivery document (say for eg: 30,000 KG) I have taken GRN for the above IBD through MIGO transaction with 101 movement for all 30,000 KG. La

  • Cannot save file as a png?

    Hi I'm working with a file that was originally provided as a jpg.  Opened it in Photoshop and saved it as a psd file.  Made modifications and now when I try to save that file, there is no option to save it as a png.  I've seen this before but no idea

  • New aluminum keyboard - Remap volume & player keys to F13 - F19?

    (I couldn't see a 'Keyboards' or 'Other Hardware' section of the forum so thought I'd post here). I've just bought the new aluminium keyboard. I'm loving it apart from the placement of the volume keys, iTunes/QuickTime control keys etc. I want to rem

  • Sales order number should be sent as a SMS to customer automaticaly

    Hi,      i want whenever i raise the SO that respective SO number should gone to the customer as SMS automatically. Please suggest how i can do this?

  • Authorizations problem

    Hi Experts, Iam getting error while accessing to FSDB its working fine for the users who have assigned superadmin role but iam getting the below error for the new user who have only cutom role to access FSDB. Access Denied The item you are attempting