Java Threads vs. Native Global Variables

A brief description of the problem:
I am trying to integrate a multi-threaded Java app with legacy Fortran code. The Fortran code in question makes extensive use of global variables in the form of Fortran's Common Block data structure.
If multiple threads were allowed access to a native routine, they would over write each others data which is stored in global variables.
If only one thread at a time can have access to the native routine for the duration of the native routine, the whole advantage of using threads is completely nullified.
These native routines cannot be rewritten (3rd party code) and must be used.
One solution I envisioned was to load a new copy of the native shared object code for each Java object that used the native code. However, it seems System.loadLibrary() can only be used in a static context.
Is there any known solution to this problem?

Here is an elaboration on the earlier suggestions. It's a high overhead solution, because you have to start a bunch of JVMs.
1. You have a java control program, which will start up a pool of "services", make requests to them, and gather the results.
2. Each service is a small java program with a native method:
o java communications front-end.
o native method declaration.
o native - in your case fortran - method implementation.
3. Each service is started using "exec". That puts it in a separate process.
4, Since each service is a java program, you can use java to do communications between the control program and the service.
o You could use RMI.
o You could - perhaps - use java Process communications, i.e., have the services write to stdout, and have the control program capture the output.
o You could use socket communications.

Similar Messages

  • Jdev+ADF Mobile : Error java.lang.NullPointerException,need global variable

    hi, i am using jdeveloper version 11.1.1.1.0.
    i try to get value of field "id" from a table "customer" from input value from "username" and "password" form in welcome / login page.
    the value of field "id" that logged on will be used for further operation like determine relationship with other table for showing data.
    to accomplish that, i create a new java class "bean.java"
    the content is simple, just a few variable like : eeid,eeuser,eepass, and more else.
    each variable have accessors.
    after create "bean.java", i register that class to faces-config.xml in managed beans tab. i give it description like below :
    - name : beanku
    - class : mvc.bean
    - scope : session
    to login, i check the login button with code like this :
    public String cmdSigninee_action() throws ClassNotFoundException, SQLException {      
    String tuser = (String) inputUseree.getValue(); --> value of username
    String tpass = (String) inputPassee.getValue(); --? value of password
    bean ong = (bean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("beanku"); --> it's ok here
    ong.setSeeid("testing"); --> here is the error
    i got an error message like shown below :
    Target URL -- http://127.0.0.1:7101/madf-mvc-context-root/faces/welcome.jsp
    Dec 4, 2009 11:39:26 PM oracle.jbo.uicli.mom.CpxUtils$Visitor logMainApplicationCpx
    INFO: file:/C:/Documents and Settings/Ong/Application Data/JDeveloper/system11.1.1.1.33.54.07/o.j2ee/drs/madf/madf-mvc-webapp/WEB-INF/classes/mvc/DataBindings.cpx
    Dec 4, 2009 11:39:27 PM oracle.adfinternal.controller.faces.lifecycle.JSFLifecycleImpl setLifecycleContextBuilder
    INFO: ADFc: Initializing ADF Page Lifecycle for the JSF environment, LifecycleContextBuilder is 'oracle.adfinternal.controller.application.model.JSFDataBindingLifecycleContextBuilder'.
    Dec 4, 2009 11:40:21 PM com.sun.faces.application.ActionListenerImpl processAction
    SEVERE: java.lang.NullPointerException
    javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.lang.NullPointerException
         at mvc.backing.Welcome.cmdSigninee_action(Welcome.java:380)
         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:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         ... 38 more
    Dec 4, 2009 11:40:21 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
    WARNING: #{backing_welcome.cmdSigninee_action}: java.lang.NullPointerException
    javax.faces.FacesException: #{backing_welcome.cmdSigninee_action}: java.lang.NullPointerException
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         ... 37 more
    Caused by: java.lang.NullPointerException
         at mvc.backing.Welcome.cmdSigninee_action(Welcome.java:380)
         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:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         ... 38 more
    Dec 4, 2009 11:40:21 PM com.sun.faces.lifecycle.Phase doPhase
    SEVERE: JSF1054: (Phase ID: INVOKE_APPLICATION 5, View ID: /welcome.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@8aa35b]
    <Dec 4, 2009 11:40:21 PM ICT> <Error> <HTTP> <BEA-101017> <[ServletContext@14855001[app:madf module:madf-mvc-context-root path:/madf-mvc-context-root spec-version:2.5], request: weblogic.servlet.internal.ServletRequestImpl@5a2f7[
    POST /madf-mvc-context-root/faces/welcome.jsp?_adf.ctrl-state=4p5g40az1_4 HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
    Referer: http://127.0.0.1:7101/madf-mvc-context-root/faces/welcome.jsp;jsessionid=vs4JLZ7ppccm9mdq4z1RJn31c1Qj9ZpLmdHhT2BGTThzP7JnZfmJ!1909271282?_adf.ctrl-state=4p5g40az1_4
    Accept-Language: en-us
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
    Content-Length: 346
    Connection: Keep-Alive
    Cache-Control: no-cache
    Cookie: JSESSIONID=vs4JLZ7ppccm9mdq4z1RJn31c1Qj9ZpLmdHhT2BGTThzP7JnZfmJ!1909271282
    ]] Root cause of ServletException.
    javax.faces.FacesException: #{backing_welcome.cmdSigninee_action}: java.lang.NullPointerException
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
         Truncated. see log file for complete stacktrace
    javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         Truncated. see log file for complete stacktrace
    java.lang.NullPointerException
         at mvc.backing.Welcome.cmdSigninee_action(Welcome.java:380)
         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:597)
         Truncated. see log file for complete stacktrace
    >
    anyone can help me with those errors? i just need global variable, so i can use it for check relationship with other table.
    or if anyone of you can give me another way to get the value of field "id" from a table?
    thank you so much before! and i am sorry if my english is bad.

    If you select the JSP page in the graphical stuts-config.xml overview in JDeveloper, you should see the properties of the JSP page in the property inspector. One of those properties defines the Java class that handles the action/forwarding/etc.
    Then you should create a new Java-class that extends the original action handling class. Change the property in the graphical stuts-config.xml overview in JDeveloper to this new class.
    Then add an event attribute to the submitbutton element in the form of your JSP page, e.g. seeDetails.
    In your newly created class you can then create a new method: onSeeDetails. This method should be invoked when the submit button is pressed and the form is submitted.
    In the ADF ToyStore demo there are some examples of Java classes that extend the standard action handler. There in the ViewController project.
    ROnald

  • Java Thread allow lock on variable?

    I have a situation where i have more then 20 threads each has some variable call it- int [ ] variable.
    Now each thread wants to see this variable of all other thread and any thread is allowed to add value of int array of any other thread.
    Now suppose a reference to int array or all threads is availabe to all other threads, is there a way to put a lock on it?
    So say Thread 1 is changing int array of Thread 2. Can thread 1 put a lock on thread 2's int array so while it is changing the value of that int array no one else can do anything to it?
    At the same time if some other thread is accessing the int array of thread 2, thread1 is put on hold until it gets it's turn to put lock on it?
    Thx!!!

    Now suppose a reference to int array or all threads
    is availabe to all other threads, is there a way to
    put a lock on it? Look at the "synchronized" keyword.
    So say Thread 1 is changing int array of Thread 2.Typically variables aren't associated with threads but rather with other objects.
    You can have thread local variables, but the point of that is to preclude this kind of thing.
    Read this:
    http://java.sun.com/docs/books/tutorial/essential/concurrency/

  • GlobalContainer x Global Variable Java Section

    Guys,
    My requirement: I have a variable that'll be read from message header with DynamicConfiguration and will be used in several UDFs in a message mapping.
    Are there any problems in using either GlobalContainer object or Global Variable in Message Mapping Java Section for storing/recovering this variable?
    And in the case I use Java Sections, suppose I have the following:
    Global Variables
    String param = null;
    Initialization Section
    param = "value";
    Then, what do I need to use in Clean-up Section? Should I give it a null value or an empty string value? I mean, I can't understand the necessity of this section, since garbage collector would handle that variable (and supposing it will be valid only during this message mapping thread).
    Any thoughts?
    Thanks in advance,
    Henrique.

    Hey William,
    thank you for your input.
    Yeah, I thought that too, that clean-up section would be useful when I needed to use .close() methods on the open objects.
    And since java sections are newer, I think they are the prefered way too.
    Regards,
    Henrique.

  • Problems in syncronyzing two threads into Test Stand using a Global Variable (TestStand 4.1.1)

    I have one thread that is doing TCPIP Aquisition into a Global variable defined in Teststand. And I have another thread that it supose to read it. All are in the same sequence and execution. The problem is that the aquisition thread got a lot of bytes, while the processing thread is reading always only a few. Do you know what the problem could be?
    I will attach also some pictures just to be maybe more clear...
    Attachments:
    Implementation_pictures.zip ‏368 KB

    I wasn't looking at your Sequence, I was looking at Receive_HDL_Block.JPG. What is that VI doing (the one with number 3 on the icon and Size_in_bytes as an input) ?
    Where in teststand are you doing any checking?
    I don't really understand your sequence.
    You have a sequence (running in a new thread) (why), following by another called Receiver Handler (also running in a new thread) then two more sequences which seem to do some with transmitting something (also running as new threads). You are only waiting on one of these threads (the Receiver Handler). There does seem to be any loops in TestStand, you dont seem to be bothered about the other threads that you have running. What happens when this test sequence finally does stop, what is stopping the Threads that you have running.
    Your pictures dont really seem to fit in with your Test Sequence, such as where does Test_005.vi fit into everything
    The whole thing is a bit of a nightmare.
    Maybe your best bet would be to scrap the lot and start again. Only this time have a better understanding of what you what to achieve, what would be best to put into Teststand and what to put into labview. Whether you really need all those new threads running.
    Sorry to be so blunt.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Global Variable in JAVA

    Hi I am new to Java but have been programming in other languages for sometime.
    What I want to achieve is to have some global variables that I can use in other classes. This was particularly difficult because I want to use these global variable in Switch/Case statements. I thought this was solved by creating the following class
    public final class IntObj {
    public static final int ftsefut_contract_id = 2;
    so in another class i would use IntObj.ftsefut_contract_id in the switch/case and it worked. However, i now am begining to think this is not working. Usng NetBeans, if I change the value of ftsefut_contract_id from 2 to 3 and "clean and rebuild", I am still seeing the value of ftsefut_contract_id to be 2 and not the new value (ie 3) that I have inputed. Can someone please explain is there a better method of having global variables and if not how do I get NetBean or the project to flush itself and reload the new values each time I rebuild.
    Thanks

    That behaviour is explicitly permitted by the Java specifications.
    Use an enum.

  • How to go to java section global variable declaration

    Hi all
    i am following this scenario
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID0446700150DB10376299506581707969End?blog=/pub/wlg/11287
    in this scenario 3rd screen shot is about global variable declaration:
    In order to build the content of the attachment (for this particular requirement) we use a global variable declared and initialized in the global sections :
    can any body tell me how to go to this java section screen , as i am unable to find this java screen....
    Thanks
    sandeep

    even i cant see this edit java section
    i am working on PI 7.1. has this feature been removed in pi 7.1
    this is replaced in PI7.1 ... check this blog on how to use the "global" variable in PI7.1:
    /people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable
    Regards,
    Abhishek.

  • Newbie thread about global variables and result set

    Hello everyone this is my first post, im from colombia and now im learning about this world !! the WCC !!
    Now im doing a practice but im so noob that i cant get it so far... i wrote some of the oracle documentation.. and it was so usefull for starting.. but now im trying to do custom components builded in java + resources + services + template etcc .. all good stuff :D.
    i want to retrieve a result set coming from a custom service ... and then i want to store this result set in some kind of global variable !! why ? because i want to use this data from the result set again and again without making more call to the service !!
    ive tried to copy this resultset but i think it cant be done because i use a popUp window to display the rows from the RS.. and when i close the window .. it dies!!
    i want to use this RS for 3 custom metadata field.. but i have no idea how to do this....
    this is a part of my custom resource
    <$if fieldName like "xElaborador"$>
    <$executeService("SERVICE_ALLUSERS")$>
    <$trace(" ### executing service ###","#log")$>
    <!--i tried to copy the rs here but this is wrong i guess -->
    <$nuevoRS="usuarios_LDAP"$>
    <$endif$>
    <!-- usuarios_LDAP is the RS parameter coming from the java calss -->
    <$if rsExists("usuarios_LDAP")$>
    <$if rsFirst("usuarios_LDAP")$>
    <$loop usuarios_LDAP$>
    <$trace(" ### inside RS ###","#log")$>
    <$include each_user_LDAP$>
    <$endloop$>
    <$else$>
    <$include therearenotusers$>
    <$endif$>
    <$endif$>
    <!-- THIS CODE IS USELSS BASICALLY-->
    <$if fieldName like "xRevisor"$>
    <$if rsExists("nuevoRS")$>
    <$if rsFirst("nuevoRS")$>
    <$loop nuevoRS$>
    <$trace(" ### inside rs for revisor ###","#log")$>
    <$include each_user_LDAP$>
    <$endloop$>
    <$else$>
    <$include therearenotusers$>
    <$endif$>
    <$endif$>
    <$endif$>
    pls tell me if im too lost im all ears to learn the good practices for this tool.

    Hi ,
    One of the good resource on this topic is :
    http://jonathanhult.com/blog/2012/11/resultset-versus-dataresultset/
    Thanks,
    Srinath

  • How do you override global variable values when calling oraxsl or xsl.exe?

    I am a newbie to oracle xslt.
    I have down loaded the latest version of xdk (10.1.0.2...). (Jan 2, 2009).
    In the past I haveI used micorsoft's "msxsl.exe" to perform my transformations.
    I am looking for a more up-to-date transformation tool.
    I found Oracle's version, and thought I would try it out.
    I have run the "bin/xsl.exe -hh" command.
    I read its help data. It states that variables are
    passed by coding a pramater "-V <var> <value>".
    I have also examined the oraxls.bat file.
    I found the documentation on "oracle.xml.parser.v2.oraxsl" class.
    It states that parameters are passed after the "-p" switch.
    It says the value of the -p parameter is "a list of paramemters".
    I don't find this sufficient information to be useful.
    I can spend days guessing, and I might get lucky.
    I thought it my be better to ask for help.
    I need to pass in (override) values for 3 global variables.
    I saw the method
    "setParam(namespace, variable, value)",
    near the documentation for the "oraxsl" class.
    How do you format the options string to communicate more than one param statement?
    (in either xsl.exe and/or oraxsl class).
    Suppose I have an xslt stylesheet as follows:
    ==================================================
    <?xml version="1.0" ?>
    <xsl:stylesheet version="1.1" xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
    <xsl:param name='a' select='"default_a"' />
    <xsl:param name='b' select='"default_b"' />
    <xsl:param name='c' select="'default_c"' />
    <xsl:template match='/'>
    this is value for a: <xsl:value-of select='$a' />
    this is value for b: <xsl:value-of select='$b' />
    this is value for c: <xsl:value-of select=$c' />
    <xsl:apply-templates />
    </xsl:template>
    </xsl:stylesheet>
    ========================================================
    Now as part of the calling of the XSL processor I want to change the value of these
    three global parameters.
    I want:
    a="current_a",
    b="current_b",
    and c="current_c"
    How do I express this using xsl.exe and its paramter string (-V ????).
    and/or how do I express it to the oraxsl class ( -p (xsl, a,"current_a"), (....) )???
    The syntax for specifying this information is not very clear in either situation.
    Of course I am making the "assumption" that by "param" they are
    refering to "global parameters" (as in my stylesheet), rather than some other global parameters of XLST.
    As an aside inquiry:
    I had hopped that the Oracle's xsl Verion 2 routine could handle xslt 2.0 commands
    such as "xsl:for-each-group", since it handled multiple xsl:outputs.
    From reading some of the documentation it seems it only handles xslt 1.0 syntax/commands.
    Is this true? (or is the documentation not up-to-date?).
    Any help on passing param values to xsl.exe and/or "oraxsl" class is appreciated.
    Thanks.

    Here is the line from one of my testing .bat files that passed in one parameter. I can't recall if I've passed in two, but this will give you a starting point for passing in multiple
    java -cp %CPath% oracle.xml.parser.v2.oraxsl -p show_image='yes' %ValXML% %ValXSLT% As for XSLT 2.0 support, it appears it does per {thread:id=503445}

  • Global variable in servlet & DBPooling questions

    Hello guys,
    I used to develop PHP/ASP, and am new to servlet. I have been searching around for a solution ...
    With Php, we can get the reference of a global variable in any classes->functions...
    How do I do this with servlet ?
    And second..I have developed the DB class as below... I set the datasource to be static, so it initializes only once. Is it a good idea? How would you like to improve this class? any comments?
    package shop.database;
    import javax.sql.DataSource;
    import java.sql.*;
    import org.apache.commons.dbcp.BasicDataSource;
    import org.apache.log4j.Logger;
    import shop.admin.exception.GeneralException;
    public class DdManager {
         static protected Logger logger = Logger.getLogger(DdManager.class);
         private String userName = "root";
    private String password = "";
    private String hostName = "jdbc:mysql://localhost:3306/shop";
    private String database="shop";
         static private DataSource ds;     // set this to be static so all threads share the same job in JVM
         private Statement stmt;
         private Connection conn;
         private ResultSet rs;
         private CallableStatement cs;
    public DdManager() {}
    * setup the data source and return it
         public static DataSource getDataSource(
              String sDrvName,
              String sUserName,
              String sPwd,
              String connectURI) {
              BasicDataSource ds = new BasicDataSource();
              ds.setDriverClassName( sDrvName );
              ds.setUsername( sUserName );
              ds.setPassword( sPwd );
              ds.setUrl( connectURI );
              ds.setMaxActive( 15 );
              ds.setMaxIdle( 10 );
              ds.setMaxWait( 10000 ); // 10 seconds
              return ds;
         * static init of the class
         * this class is will be called only once to initialize the DataSource
         static {
              try {
                   Class.forName( "com.mysql.jdbc.Driver" );
                   ds = getDataSource(     "com.mysql.jdbc.Driver",
                                            "root",
                                            "jdbc:mysql://localhost:3306/shop" );
                   if (ds == null) {
                        String msg = "Connection Pool error";
                        logger.error(msg);
                        throw new GeneralException(msg);
                   logger.info("DataSource has been initialized");
              } catch(Exception exception) {
                   logger.error(exception.toString());
                   try {
                        throw new GeneralException(exception.toString());
                   } catch (GeneralException e) {
                        logger.error(e.toString());
         * get the connection from the pool (DataSource)
    public void openConnection() throws GeneralException {
    try {
         BasicDataSource bds = (BasicDataSource) ds;
         logger.info("NumActive: " + bds.getNumActive() + ", " + "NumIdle: " + bds.getNumIdle());
    conn = ds.getConnection();
    logger.info("Connection of " + database + " has been established");
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * close the connection will actually return the connection to the pool (Must)
    public void closeConnection() throws GeneralException {
         initResource();
    try {
         if (conn != null){
                   conn.close();
                   logger.info("Connection of " + database + " has been closed");
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * prepare the calling stmt
    public void prepareProcedure(String callStatement) throws GeneralException {
         initResource();
    try {
         cs = conn.prepareCall(callStatement);
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * set the pass-in parameter for "String"
    public void setParameter(int position, String parameter) throws GeneralException {
    try {
         cs.setString(position, parameter);
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * set the pass-in parameter for "Integer"
    public void setParameter(int position, int parameter) throws GeneralException {
    try {
         cs.setInt(position, parameter);
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * execute the procedure and return the resultset
    public ResultSet execProcedure() throws GeneralException {
    try {
         rs = cs.executeQuery();
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    return rs;
    * close the statment and resultset
         private void initResource() throws GeneralException {
         try {
              if(rs != null) {
                   rs.close();
              if(stmt!= null) {
                   stmt.close();
              logger.info("Statement & Resultset have been free");
         } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    Thanks mates!
    myy

    Thanks Saish,
    Your response is really appreciated. Sorry about that
    as i didnt know there is 'code' formatting button,
    and I will look into the Singleton pattern.
    As I'm still in the learning stage. Therefore, i
    still have a lot of thing do not understand.
    ... use it in a method signature ...What is "a method signature" ?
    A method signature is basically the method's parameters, return value, name and any access or other modifiers. The following is a method signature:
    static final public void main(final String[] args)Between the braces of the method body is the implementation (or as I already alluded to, the method body).
    Consider using an already-developed connection poolimplementation, such as Jakarta Commons DBCP ...
    I'm trying to implement the Jakarta DBCP. Did I go
    into the wrong way?
    Sorry, did not read the imports. Yes, you are. However, I am confused about what you are trying to implement. You have a static method getDataSource(). You also have a static variable 'ds'. Use one or the other. I would be that there are seemingly random errors cropping up based on whether you remember to call getDataSource() or not.
    You do not, generally, want the data source to be static. Multiple threads might use the class. And if there is only a static data source, you will either need to synchronize the methods that use the data source (resulting in a scaling bottleneck) or not synchronize them (which will totally destroy any concept of a logical unit of work or database transaction).
    .. A static datasource, as in your class, can onlysafely be used by one thread at a time, potentially
    introducing scaling bottlenecks (or race conditions)
    in your system ...
    So, you mean there is no need for the DataSource to
    be static ?
    No, in fact, IMO, it should not be. That is why you are pooling. Use instances. The pool will manage the connections and their availabilty for you.
    Why are you throwing GeneralException everywhere?Here's a question: can someone using your class (a
    caller) realistically be expected to handle a
    database exception?
    When there is a database error, I just want to stop
    the process and redirect the user to an error page. I
    will look into the unchecked exceptions. Thanks.
    Unchecked exceptions do not need to be declared in a method signature or caught within the method body. Checked exceptions do. As such, an added benefit is that unchecked exceptions de-clutter your code.
    In your initResources() method, what happens if theclose() on ResultSet throws an exception
    Oh, yes. I'm so stupid.
    Now I only have ...
         private static DataSource ds;     // set this to
    be static so all threads share the same obj in JVM
         private Connection conn;
         private CallableStatement cs;
    private void initResource() throws GeneralException
    n {
         try {
              if(cs != null) {
                   cs.close();
    logger.info("CallableStatement has been
    as been free");
         } catch(Exception exception) {
         logger.error(exception.toString());
    throw new
    throw new GeneralException(exception.toString());
    You still have issues.
    public void initResources() {
       if (rs != null) {
         try { rs.close(); } catch (SQLException ignore) { ignore.printStackTrace(); }
       if (stmt != null) {
         try { stmt.close(); } catch (SQLException ignore) { ignore.printStackTrace(); }
    }Normally, this type of method would not be called initResources() but rather closeResources() or freeResources(). It would be called from within the 'finally' block of another method using the CallableStatement or ResultSet.
    This is really is problem, would you mind to tell me
    how to handle this(close the connection) if the
    close() on either CallableStatement or Resultset
    throws an exception ?
    See above. Simply log the exception (there is usually nothing meaningful you can do if a close() fails, and it is up to you as a developer if this is an error or just a warning). Another option is to 'chain' exceptions. In your own exception, add a method 'addException(Throwable)'. This would add another exception to a List of exceptions. When you print the stack trace, iterate through the chained exceptions to print them all out. One place where I find this useful is rollback() code. If the original SQL statement fails AND the rollback fails, I definitely want to see that rollback() exception as well in my logs.
    The DB thing makes me headache. What I actually
    wanted is a solution for:
    Let say I have a class "HelloAction.class" contains
    the code:
    public ActionForward XXX() {
         DbManager DB = new DBManager();
         ... do some DB thing here...
         SecondClass SC = new SecondClass();
         SC.doSomeOtherDbThing();
         ... do something else...
         ThirdClass TC = new ThirdClass();
         SC.doMoreOtherDbThing();
    }There are some functions in SecondClass.class and
    ThirdClass.class that will need database connection.
    I consider 'global variable' is because I want these
    two classes are able to use the same
    connection(DbManager) from the function -
    ActionForward XXX().
    What is the best way to implement the above situation
    (sharing the same connection in different classes &
    sub-classes?
    I also just realize that the problem of multi-threads
    with these two class variables..
         private Connection conn;
         private CallableStatement cs;Really headache. I really appreciate any comments.
    Thanks.
    - myyPass the Connection or DataSource to each method or constructor. Call commit() or rollback() from the method that created the transaction.
    - Saish

  • Storing global variable

    Hey there
    I'm trying to figure out how/if you can store a global variable, for access in all classes of the program. In this case I am developing an app which connects to a database. At the moment each class makes a seperate connection to the database for it's purposes, but I would rather make one connection at the beginning, and then each class shares this connection. I realise I can do this by having each class constructor accept a connection, and then just threading the connection to all of them. However, is there a way I can just store that connection somewhere in memory, and access it from all classes. I remember being able to do this in C# so hopefully Java has something similar.
    Thanks
    Nathan

    I don't know how this got into the JDBC forum, but a
    basic way of making a "global" variable is like
    this:public class User {
    public static Connection theConnection;
    }Then other classes access it like
    this:Connection conn =
    User.theConnection;When you learn some Java
    you'll find out that this is primitive programming and
    there are better ways, but this will do for a raw
    beginner.It's quite sad that you say this, I have been using java in my degree for the last 3 years. I guess we haven't developed applications from scratch, but I've done tons and tons of assignments in Java. The fact that I'm still at raw beginner level scares me. Perhaps I should not be looking for a programming job next year.

  • What's the difference between global variables and instance variables?

    hi im just a biginner,
    but what is the difference between these two?
    both i declare them above the constructor right.
    and both can access by any method in the class but my teacher said
    global variables are not permitted in java....
    but i don't know what that means....and i got started to confuse these two types,,
    im confusing.......
    and why my teacher said declaring global variables is not permitted,,,,,,
    why.....

    instance variables are kindof like Global variables. I'm not surprised you are confused.
    The difference is not in how they are declared, but rather in how they are used.
    There are two different "styles" of programming
    - procedural programming.
    - object oriented programming.
    Global variables are a term from Procedural programming.
    In this style of programming, you have only one class, and one "main" procedure. You only create one instance of the class, and then "run" it.
    There is one thread of control, which goes through various methods/procedures to accomplish your task.
    In this style of programming instance variables ARE "global" variables. They are accessible to all methods. There is only one instance of the class, and thus only one instance of the variables.
    Global variables are "bad" BECAUSE you can change them in any method you like. Even from places that shouldn't have to. Also if you use the same name as a global variable and a local variable, you can cause great trouble. This can lead to very subtle bugs, as the procedures interact in ways you don't expect.
    The preferred method in procedural programming is to pass the values as parameters to the methods, and only refer to the parameters, and local variables. This means that you can track exactly what your method is doing, and what it affects. It makes it simpler to understand. If you use global variables in your methods, it becomes harder to understand.
    So when are instance variables not global variables?
    When you are actually using the class as an Object, rather than just a program to run. If you are creating multiple instances of an object, all with different values for their instance variables, then they are not global variables. For instance you declare a Person object with an attribute "firstname". Your "main" program then creates many instances of the Person object, each with their own "firstname"
    I guess at the end of all this, it comes down to definitions.
    Certainly you can write procedural code in java. You can treat your instance variables, for all intents and purposes like global variables.
    I can only think to show a sort of example
    public class Test1
       User[] users;
       public void printUsers(){
         // loop through and print all the users
         // uses a global variable
          for(int i=0; i<users.length; i++){
            users.printUser();
    public void printUsers(User[] users){
    // preferred method - pass it the info it needs to do the job
    for(int i=0; i<users.length; i++){
    users[i].printUser();
    public Test1(){
    User u1 = new User("Tom", 20);
    User u2 = new User("Dick", 42);
    User u3 = new User("Harry", 69);
    users = new User[3];
    users[0] = u1;
    users[1] = u2;
    users[2] = u3;
    printUsers();
    printUsers(users);
    public static void main(String[] args)
    new Test1();
    class User{
    String firstName;
    int age;
    public User(String name, int age){
    this.firstName = name;
    this.age = age;
    public void printUser(){
    // here they are used as instance variables and not global variables
    System.out.println(firstName + " Age: " + age);
    Shit thats a lot of typing, and I'm not even sure I've explained it any good.
    Hope you can make some sense out of this drivel.
    Cheers,
    evnafets

  • Can F4IF_INT_TABLE_VALUE_REQUEST FM return a value in a global variable?

    Hi everybody,
    I need to use F4IF_INT_TABLE_VALUE_REQUEST FM because I have to let users select an specific option before choosing another value. The point is that I need to save in a program global variable what the user selects, and decide something with it in the program.
    Is it possible that F4IF_INT_TABLE_VALUE_REQUEST FM returns the value in a sinple variable or it has to be paramter?
    I look in a lot of previous threads but I didn't find anything, and I don't know if it's possible.
    Thanks and kind regards,
    MMP.

    Hi,
    Sure you can. All you need to do is to store what the function returns in your global variable. It don't need to be returned back to screen field.
    DATA: BEGIN OF VALUES OCCURS 0,
             CARRID TYPE SPFLI-CARRID,
             CONNID TYPE SPFLI-CONNID,
           END OF VALUES.
    DATA: VALUES_TAB TYPE TABLE OF VALUES,
              G_VALUE TYPE SPFLI-CONNID.  "global variable to store what is returned
    "in PAI first populate your table
      SELECT  CARRID CONNID
        FROM  SPFLI
        INTO  CORRESPONDING FIELDS OF TABLE VALUES_TAB
        UP TO 10 ROWS.
    "then call the function but don't return the value to screen field
    "If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the useru2019s selection is
    "returned to the corresponding field on the screen. If you specify the table parameter RETURN_TAB, the
    "selection is returned into the table instead.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                RETFIELD         = 'CONNID'
                VALUE_ORG        = 'S'
           TABLES
                VALUE_TAB        = VALUES_TAB
                RETURN_TAB      = RETURN_TAB.
    "now simply read first row of return tab and store the value returned there in some global var
    READ RETURN_TAB INDEX 1.
    MOVE RETURN_TAB-FIELDVAL TO G_VALUE.
    Regards
    Marcin

  • Problem with .DLL and global variables

    Hi,
    I need some helps to figure out my problem.
    I wrote a .dll file to open and run a GUI. When I run it at the first time, it is ok. When I call it again, there is an error "Pointer to free memory passed to library. It will be ok if I completely exit the program that calls the .dll before re-call it. I think there is some problems with global variables when I call another thread. How can I free global variables between threads. Is there any solution for this problem?
    Thanks

    Vinh Pham:
    Are you doing anything intentionally that frees your globals?
    CVI ships with an example program that demonstrates calling a DLL to create a user interface: guidll.cws.
    I made two simple modifications to guidll.cws.
    1. In guidll.c, I made hpanel global by moving its declaration from RunDLLUI() to right below the #include statements.
    2. In useguidll.c, I duplicated the lines calling RunDLLUI () and MessagePopup() to call the DLL gui twice.
    I built the project and ran it.  I had no problems with free'ed globals.
    Take a look at the guidll example.
    Can you either post your code or a modification to guidll that demonstrates the problem you're having?

  • The speed will reduce when using at the same time a lot of global variabl?

    It's seem like that when i use a lot of global variable. Is it correct?

    Take a look at these threads (tagged as Action Engine) to learn about alternatives to Globals.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Please help! My CS6 won't open and Adobe Application Manager keeps popping up to renew CS Cloud subscription.

    Hi there. I recently canceled my CS Cloud subscription about 3 weeks ago and went back to using CS6. I was using CS6 Creative Suite without a problem until 2 days ago. Now my CS6 programs (AI, Photoshop, InDesign, Acrobat) won't open. Instead the Ado

  • Looking for a weather alarm app

    Hi all. I am looking for a voice alarm app that tells me what the weather is currently and what the forecast is for the day when the alarm time comes around. The closest I have found is "morning report" but it does not give the forecast.

  • TP Posting Third Party Remittance Documents Status Incorrect

    Hi everyone, I have run payroll to an employee and posted the results to FI Posting. Documents are posted in FI Posting. By using Tcode PC00_M99_URME - Evaluation Remittance (New) I am able to do the third party evaluation for this employee. Until th

  • Usage decision in QA11 through BAPI_INSPLOT_SETUSAGEDECISION

    Hi Experts, I am trying to do Usage decision thorugh BAPI_INSPLOT_SETUSAGEDECISION. I gave the inputs inspection lot and UD code. I am getting error like this :E QV                   045 You cannot make the UD because of 0001 non-valuated Physical sa

  • Tags don't autocomplete in Wiki Server

    Since the upgrade from 10.7 Server, previously-used tags don't autocomplete when added to a wiki page. There's nothing informative in the logs. Otherwise the server seems to be working. Before filing a bug report, I'd like to know whether anyone can