[LV8.2] "Export string" (captions) strange behaviour

Hi,
I have 2 VIs. One was made with previous versions of LV (called A), and then re-opened and saved with LV8.2, the other was born in LV8.2 (called B). All is ok. I have some "system checkbox" controls in them, I didn't check the "show caption" and "show label".
Their label and caption would be like "W 0", "W 1", ecc...
Open A vi.
Tools -> advanced -> export strings
Export caption for control without caption? -> NO, I don't want
Export block diagram strings? -> NO
Save the file into "strings.txt"
Now open the "strings.txt" with notepad, search "W 0", and it appear a string like:
<CONTROL ID=79 type="Boolean" name="W 0">
<PART ID=82 order=0 type="Caption"><LABEL><STEXT>W 0</STEXT></LABEL></PART>
this last string would not be expected !!! it's an error, because I told him "No" in the first questin before.
infact if I repeat the procedure with B vi, it only appears:
<CONTROL ID=79 type="Boolean" name="W 0">
and not also the other <STEXT>  !!!
I don't know why happens this, is there any particular reason? maybe a general setting that I'm losing? The behaviour is not the same in the two vi.
Thanks

"export caption for control without caption?"
If you turned on your caption at some point, then your control has a
caption, whether or not it is visible.  The question is not "export
caption for controls with hidden captions?"  If you never view the
caption for the control, LabVIEW does not create a caption for a
control.  For example, if you try to get the caption text using a
Proprty node for a control where you haven't viewed the caption, it
will generate an error.
In the attached code, Caption1.vi has a control which the caption has
not been viewed.  If you Answer no to the above question, you will get
Caption1-1.txt.  If you answer yes, you will get Caption1-2.txt.  You
may notice (in LV 8.5 this behavior is there, I do not knwo about 8.2),
that the control now shows its caption and has hidden its label.  The
VI also got saved.  I can now not get Caption1-1.txt to generate again.
In Caption2.vi, I viewed the caption, then hid it again.  Answering no
to the question above, I got caption2-1.txt.  Answering yes, I got
Caption2-2.txt.  The two files are the same becuase the control always
had a caption.
Attachments:
captions.zip ‏8 KB

Similar Messages

  • Strange behaviour of Runtime.getRuntime().exec(command)

    hello guys,
    i wrote a program which executes some commands in commandline (actually tried multiple stuff.)
    what did i try?
    open "cmd.exe" manually (administrator)
    type "echo %PROCESSOR_ARCHITECTURE%" and hit enter, which returns me
    "AMD64"
    type "java -version" and hit enter, which returns me:
    "java version "1.6.0_10-beta"
    Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b25)
    Java HotSpot(TM) 64-Bit Server VM (build 11.0-b12, mixed mode)"
    type "reg query "HKLM\SOFTWARE\7-zip"" returns me:
    HKEY_LOCAL_MACHINE\SOFTWARE\7-zip
    Path REG_SZ C:\Program Files\7-Zip\
    i wrote two functions to execute an command
    1) simply calls exec and reads errin and stdout from the process started:
    public static String execute(String command) {
              String result = "";
              try {
                   // Execute a command
                   Process child = Runtime.getRuntime().exec(command);
                   // Read from an input stream
                   InputStream in = child.getInputStream();
                   int c;
                   while ((c = in.read()) != -1) {
                        result += ((char) c);
                   in.close();
                   in = child.getErrorStream();
                   while ((c = in.read()) != -1) {
                        result += ((char) c);
                   in.close();
              } catch (IOException e) {
              return result;
         }the second function allows me to send multiple commands to the cmd
    public static String exec(String[] commands) {
              String line;
              String result = "";
              OutputStream stdin = null;
              InputStream stderr = null;
              InputStream stdout = null;
              // launch EXE and grab stdin/stdout and stderr
              try {
                   Process process;
                   process = Runtime.getRuntime().exec("cmd.exe");
                   stdin = process.getOutputStream();
                   stderr = process.getErrorStream();
                   stdout = process.getInputStream();
                   // "write" the parms into stdin
                   for (int i = 0; i < commands.length; i++) {
                        line = commands[i] + "\n";
                        stdin.write(line.getBytes());
                        stdin.flush();
                   stdin.close();
                   // clean up if any output in stdout
                   BufferedReader brCleanUp = new BufferedReader(
                             new InputStreamReader(stdout));
                   while ((line = brCleanUp.readLine()) != null) {
                        result += line + "\n";
                   brCleanUp.close();
                   // clean up if any output in stderr
                   brCleanUp = new BufferedReader(new InputStreamReader(stderr));
                   while ((line = brCleanUp.readLine()) != null) {
                        result += "ERR: " + line + "\n";
                   brCleanUp.close();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              return result;
         }so i try to execute the commands from above (yes, i am using \\ and \" in java)
    (1) "echo %PROCESSOR_ARCHITECTURE%"
    (2) "java -version"
    (3) "reg query "HKLM\SOFTWARE\7-zip""
    the first function returns me (note that ALL results are different from the stuff above!):
    (1) "" <-- empty ?!
    (2) java version "1.6.0_11"
    Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
    Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
    (3) ERROR: The system was unable to find the specified registry key or value.
    the second function returns me:
    (1) x86 <-- huh? i have AMD64
    (2) java version "1.6.0_11"
    Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
    Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
    (3) ERROR: The system was unable to find the specified registry key or value.
    horray! in this version the java version is correct! processor architecture is not empty but totally incorrect and the reg query is still err.
    any help is wellcome
    note: i only put stuff here, which returns me strange behaviour, most things are working correct with my functions (using the Runtime.getRuntime().exec(command); code)
    note2: "reg query "HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0" /t REG_SZ" IS working, so why are "some" queries result in ERR, while they are working if typed by hand in cmd.exe?

    ok, i exported a jar file and execute it from cmd:
    java -jar myjar.jar
    now the output is:
    (1) "" if called by version 1, possible to retrieve by version 2 (no clue why!)
    (2) "java version "1.6.0_10-beta"
    Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b25)
    Java HotSpot(TM) 64-Bit Server VM (build 11.0-b12, mixed mode)"
    (3) C:\Program Files\7-Zip\
    so all three problems are gone! (but its a hard way, as i need both functions and parse a lot of text... :/ )
    thanks for the tip, that eclipse changes variables (i really did not knew this one...)

  • Strange behaviour: two servers on the same port

    Hi!
    I hope this is the right section for this post. I need help about a strange behaviour involving a ServerSocket.
    For my thesis I need to write a program that receives data from a pre-existing DSMS client, filters them and then sends them to a pre-existing DSMS server. And here is my problem: if I try to create a ServerSocket on the same port of the DSMS server, my program throws no exception, and the servers seem running on the same port. This is a behaviour that I'd like to avoid, but I cannot understand what the problem is. Can you help me?
    The source code of the DSMS server can be found here (it's written in C++): http://infolab.stanford.edu/stream/code/stream-0.6.0.tar.gz
    The source code of my server class, instead, is this one:
    import java.io.*;
    import java.net.*;
    public class ThreadGenerator {
         private ServerSocket server;
         public void connect(String servPort, String cHost, String cPort) {
              try {
                   server = new ServerSocket(servPort);
                   System.out.println("SERVER running on port "+servPort);
              } catch (BindException e) {
                   System.out.println("Address already in use!");
              } catch (Exception e) {
                   System.err.println(e);
              try {
                   while(true){
                        Socket client = server.accept();
                        StreamThread T = new StreamThread(client, cHost, cPort);
                        T.start();
              } catch (EOFException e) {
                   System.out.println("Server closed connection!");
              } catch (Exception e) {
                   System.err.println(e);
    }I'm programming on Mac OSX Tiger, with Java 1.5.0.
    Thanks in advance for your help.

    The problem is still happening to me, I tried in this very moment. The code I'm using is the one I posted, and the second server is the one that I linked. I don't think there's anything else to add.
    If you're sure that the problem is not in my code, then it means that it is in the linked server, which partially solves the problem. But I'd like to know, if it's possibile, if there is any other way to check if the port is already in use.

  • Strange behaviour from new 2012R2 in old domain

    Hi all,
    At work (education level), I'm starting to take charge of windows admin, so beiing a noob admin I'm finding strange behaviours that I hope you can help me solve them all :-)
    We've one (big) domain with about 5000 computers (workers and students all together), and around 50000 users (again, workers and students all together) setup like this:
    DC-DOMAIN-1:
    Windows Server 2008R2
    Shares NETLOGON and SYSVOL
    DC-DOMAIN-2:
    Windows Server 2003 R2 x64
    Shares CertEnroll, NETLOGON, SMSLOGON, SYSVOL
    Checking RootDSE, I see 'domainControllerFunctionaly is Windows 2003' (DC-DOMAIN-2)
    So, with this setup, I've noticed these strange behaviours, hope list isn't too big  (guess there will be more behaviours but these seemed too odd):
    1) On DC-DOMAIN-2, WinServer 2003 eventlog, inside 'Directory Service', I found this warning event ID 1083 (Source NTDS Replication):
    Active Directory could not update the following object with changes received from the domain controller at the following network address because Active Directory was busy processing information.
    Object:CN=<an user name>, CN=Users, DC=DOMAIN
    Usually followed by an information event (eventid 1955) which says:
    ctive Directory encountered a write conflict when applying replicated changes to the following object.
    Object:
    <SAME USER OBJECT THAN PREVIOUS EVENT ID>
    Time in seconds:
    0
    Event log entries preceding this entry will indicate whether or not the update was accepted.
    A write conflict can be caused by simultaneous changes to the same object or simultaneous changes to other objects that have attributes referencing this object. This commonly occurs when the object represents a large group with many members, and the functional level of the forest is set to Windows 2000. This conflict triggered additional retries of the update. If the system appears slow, it could be because replication of these changes is occurring.
    User Action
    Use smaller groups for this operation or raise the functional level to Windows Server 2003.
    And having as result that user being blocked in domain.
    2) I've added a new print server based on Windows Server 2012R2 (running inside an updated ESX 5.5 with VMXNET3 ethernet adapter as recommended by vmware), and seen in the event viewer these warnings/errors:
    At System log:
    Error Event ID 5783, Source NETLOGON:
    The session setup to the Windows NT or Windows 2000 Domain Controller \\DC-DOMAIN-2.fulldns.name for the domain DOMAIN is not responsive. The current RPC call from Netlogon on \\PRINTSERVER to \\DC-DOMAIN-2.fulldns.name has been cancelled.
    I've seen Event ID 5783 with DC-DOMAIN-1 too....
    Error Event ID 5719, Source NETLOGON:
    This computer was not able to set up a secure session with a domain controller in domain DOMAIN due to the following:
    The remote procedure call failed and did not execute.
    This may lead to authentication problems. Make sure that
    this computer is connected to the network. If the problem persists, please contact your domain administrator.
    ADDITIONAL INFO:
    If this computer is a domain controller for the specified domain, it sets up the secure session to the primary domain controller emulator in the specified domain. Otherwise, this computer sets up the secure session to any domain controller in the specified domain.
    At Microsoft-Windows-TerminalServices-RemoteConnectinoManager/Admin found also this warning:
    Warning Event ID 20499 Source TerminalServices-RemoteConnectionManager:
    Remote Desktop Services has taken too long to load the user configuration from server \\DC-DOMAIN-2.fulldns.name for user administrator
    3) If I try Group Policy Modeling on DC-DOMAIN-1 (server 2008R2), everything works fine, no matter if I try it against DC-DOMAIN-1 or DC-DOMAIN-2, but if I try this from the Server 2012R2 (the one from point 2), I get this:
    Simulation against DC-DOMAIN-2: Gets executed, but all GPO show as inaccessible, empty or disabled.
    Simulation against DC-DOMAIN-1: Sometimes it gets executed as DC-DOMAIN-2, sometimes I get an error saying query can't be executed.
    4) From server 2012R2, I usually manage printing GPO. If I click on the domain root (GPMC, forest, Domains, DOMAIN-NAME-ROOT) right pane, I get a pop up saying: 
    'A processing error ocurred collecting data using this base domain controller. Please change the base domain controller and try again'
    After closing popup, right pane says something like 'DC-DOMAIN-2.fulldns.name' is the baseline domain controller for this domain.
    No infrastructure Status information exists for this domain.
    Click the Detect Now button below to gather infrastructure status from all of the domain controllers in this domain.
    Pressing 'Detect Now' does nothing, and trying to select New Baseline DC shows again same pop up than before.
    5) Last, but not least, I've feeling that GPO takes too much to apply. I've found scenarios in which even after executing 'gpupdate /force' correctly on client computer either local or domain admin, I can't see the new changes (gpresult says it has been
    updated though). But couldn't find anything on eventlog that informs about problems with GPOs...
    For all these strange behaviours I've noticed in last month that I started checking things as sys admin, I believe domain is damaged, or something is wrong there (not just my new server 2012R2, even if it's running inside an ESX, blehh), so please, any hint
    on what to check, what to change, what to fix, would be highly appreciated.
    Thanks in advance.

    Hi Paul,
    Honestly, I'm still trying to figure out all broken things reported by tests :( Guess Jesper's suggestion about adding a new 2008 DC to get rid of 2003 and start checking again after that may be best option.
    I'll try to summarize list of things I believe are wrong:
    running
    DCDIAG /V /C /D /E /s:yourdcname > c:\dcdiag.log  for every DC, shows different errors. They show things such as:
    another domain running here (not administered by us, only relationship is that our users are shared with that domain, nothing else) appear when Printing out pDsInfo (as if they were DC of our domain too, but they do not even share RootDomain). Guess it
    may be for a bug old sys admin had when clonning from his 2008R2 template, that forgot to change SID... I already noticed 1 year ago our print server shared SID with those DC, guess there may be more servers sharing SID too :-(
    Within Starting test: Replications, I see few messages at Replication Latency Check, such as the one for CN=Schema, CN=Configuration, DC=<ourdomain>: 
    Latency information for 35 entries in the vector were ignored.
                      35 were retired Invocations.  0 were either: read-only replicas and are not verifiably latent, or dc's no longer replicating this nc.  0 had no latency information (Win2K DC)
    On Services test, I see an 
       Invalid service type: RpcSs on DC-DOMAIN-3, current value
                WIN32_OWN_PROCESS, expected value WIN32_SHARE_PROCESS
    On SystemLog, I see LOTS of warnings/errors such as:
    A warning event occurred.  EventID: 0x80000002
                Time Generated: 07/28/2014   08:21:54
                (Event String (event log = System) could not be retrieved, error
                0x503)
             An error event occurred.  EventID: 0xC0000003
                Time Generated: 07/28/2014   08:22:18
                (Event String (event log = System) could not be retrieved, error
                0x3afc)
    Missing entries on DNS (we've a static DNS)
    netdiag.exe /v > c:\netdiag.log Showed again DNS problems such as our primary DNS pointing to all DC, secondary
    DNS pointing just to DC with FSMO roles,...
    repadmin.exe /showrepl * /verbose /all /intersite > c:\repl.txt  Gave no errors, now I must check in detail
    if every replica is correct
    And finally,
    dnslint /ad /s "ip address of your dc"  gave more DNS problems:
    One or more DNS servers may not be authoritative for the domain
    One or more DNS servers did not respond to UDP queries
    One or more zone files may have expired
    SOA record data was unavailable and/or missing on one or more DNS servers
    Sumarizing, guess it will be better to fix DNS problems, promote new 2008R2 DC to get rid of 2003 one, promote domain to 2008 too, check again for messages and relationship with other domain, and then come back here for support if needed 
    EDIT: Almost forgot to talk about SYSVOL folder. As said before, there are 426 GPO folders inside Policies. Of them, 375 have an inetres.adm files in it (smallest one 1398 KB, almost all of them 2307 or 2707 kb).... 

  • Strange behaviour on text insert into a HTML pane

    Hi all,
    I am trying to fix a problem on inserting a span tag into an existing html page (in an EDITABLE JEditorPane).
    The behaviour:
    Assuming the cells in a table (3 rows, 2 columns) are numbered from 1 to 6, with cell one being the top left most, cell 2 top right, cell 3 middle left, etc.
    1. Inserting the text "<span></span>" in cell 4 causes during any attempt to later type into cell 5 the characters to be appended instead into cell 4, directly after the close span tag.
    2. The insertion in the first place behaves strange. If I have the caret positioned for cell 5 so that I can insert there
    (via the function void javax.swing.text.html.HTMLEditorKit.insertHTML(HTML Document doc, int offset, String html, int popDepth, int pushDepth, Tag insertTag) )
    even though the caret position is visible in cell 5, the insertion seems to take place in cell 4.
    I can sort of compensate for this by adding 1 to the offset. However, then when inserting into a line of text, for example, "the quick red fox jumped over the lazy dog"
    I insert directly before the 'j' in 'jumped', the insertion looks like this "the quick red fox j<span>..</span>umped over the lazy dog"
    So that is no solution.
    IMPORTANT! Just to prove it is not the span tag causing the trouble, if this span tag already exists in a cell on 'Load' of the html file, the strange behaviour is not observed.
    Something is going wrong here. It is me? Or is it a bug?
    Please help!!
    Here is a test app, and the test html you can use (place in current directory).
    Please test like this:
    1. run application (the html should be loaded into the pane)
    2. the span tag is programmed to automatically insert at cell 4 (by using the +1 method on the insert)
    3. another span tag was already existing in the html file, at cell 8
    4. Attempt to type into cell 5
    result: the text appears instead at cell 4
    5. Type into cell 9
    result: the text correctly is entered into cell 9
    See the difference!!
    Help!
    The test java app:
    package small.test;
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.StringReader;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    import javax.swing.text.JTextComponent;
    import javax.swing.text.html.HTML;
    import javax.swing.text.html.HTMLDocument;
    import javax.swing.text.html.HTMLEditorKit;
    import javax.swing.text.html.parser.ParserDelegator;
    public class HtmlInsertTest extends JEditorPane
         public HtmlInsertTest()
         public static void main(String args[])
              JFrame frame = new JFrame("Loading/Saving Example");
              Container content = frame.getContentPane();
              frame.setSize(600, 600);
              final HtmlInsertTest editorPane = new HtmlInsertTest();
              editorPane.setEditable(true);
              JScrollPane scrollPane = new JScrollPane(editorPane);
              content.add(scrollPane, BorderLayout.CENTER);
              editorPane.setEditorKit(new HTMLEditorKit());
              JPanel panel = new JPanel();
              content.add(panel, BorderLayout.SOUTH);
              frame.setSize(600, 600);
              doLoadCommand(editorPane);
              editorPane.insertHTML("<span>inserted text</span>", 84);
              frame.setVisible(true);
         public static String getHTML()
              return
              "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"+
              "<HTML>"+     "<HEAD>"+
              "     <META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=utf-8\">"+
              "     <TITLE></TITLE>"+          
              "</HEAD>"+
              "<BODY LANG=\"en-AU\" DIR=\"LTR\">"+
              "<P STYLE=\"margin-bottom: 0cm\">This is a test xhtml document. "+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">Here is a table:</P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     <p></p>"+
               "     <TABLE WIDTH=100% BORDER=1 BORDERCOLOR=\"#000000\" CELLPADDING=4 CELLSPACING=0>"+
         "          <TR VALIGN=TOP>"+
         "               <TD WIDTH=50%>"+
         "                    <P>It has</P>"+
         "               </TD>"+
         "               <TD WIDTH=50%>"+
         "                    <P>2 columns</P>"+
         "               </TD>"+
         "          </TR>"+
         "          <TR VALIGN=TOP>"+
         "               <TD WIDTH=50%><P>And 4 rows</P></TD>"+
         "               <TD WIDTH=50%><P></P></TD>"+
         "          </TR>"+
         "          <TR VALIGN=TOP>"+
         "               <TD WIDTH=50%><P></P></TD>"+
         "               <TD WIDTH=50%><P></P></TD>"+
         "          </TR>"+
         "          <TR VALIGN=TOP>"+
         "               <TD WIDTH=50%><P></P></TD>"+
         "               <TD WIDTH=50%><P><span>existing text</span></P></TD>"+
         "          </TR>"+
         "          <TR VALIGN=TOP>"+
         "               <TD WIDTH=50%><P></P></TD>"+
         "               <TD WIDTH=50%><P></P></TD>"+
         "          </TR>"+
         "     </TABLE>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">We will test the drag and drop"+
         "     functionality with this document. "+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">It will be loaded with the hlml editor.</P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     <P STYLE=\"margin-bottom: 0cm\">"+
         "     </P>"+
         "     </BODY>"+
         "     </HTML>";
         public static void doLoadCommand(JTextComponent textComponent)
              StringReader reader = null;
              try
                   System.out.println("Loading");
                   reader = new StringReader(getHTML());
                   // Create empty HTMLDocument to read into
                   HTMLEditorKit htmlKit = new HTMLEditorKit();
                   HTMLDocument htmlDoc = (HTMLDocument)htmlKit.createDefaultDocument();
                   // Create parser (javax.swing.text.html.parser.ParserDelegator)
                   HTMLEditorKit.Parser parser = new ParserDelegator();
                   // Get parser callback from document
                   HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0);
                   // Load it (true means to ignore character set)
                   parser.parse(reader, callback, true);
                   // Replace document
                   textComponent.setDocument(htmlDoc);
                   System.out.println("Loaded");
              catch (Exception exception)
                   System.out.println("Load oops");
                   exception.printStackTrace();
              finally
                   if (reader != null)
                        reader.close();
         public void insertHTML(String text, int offset)
              SwingUtilities.invokeLater(new insertAction(this, text, offset));
         class insertAction implements Runnable
              String text = "";
              int offset = 0;
              JEditorPane jEditorPane1 = null;
              public insertAction(JEditorPane _jEditorPane1, String _text, int _offset)
                   jEditorPane1 = _jEditorPane1;
                   text = _text;
                   offset = _offset;
              @Override
              public void run()
                   HTMLDocument doc = (HTMLDocument)jEditorPane1.getDocument();
                   HTMLEditorKit kit = (HTMLEditorKit)jEditorPane1.getEditorKit();
                   try
                        System.out.println("reading from string reader");
                        kit.insertHTML(     doc,
                                          offset,//+1
                                          text,
                                          0,//0
                                          0,//0
                                          HTML.Tag.SPAN);
                        System.out.println(jEditorPane1.getText());
                   catch (Exception e)
                        System.out.println("error inserting html: " + e);
    }Edited by: svaens on Jul 16, 2009 6:34 PM
    fix another stuffed up attempt at a SSCCE.

    Well, I know nothing about HTML in JEditorPanes. I have never been able to figure out how insertions work.
    My comment was a warning to others. Some people (like me) avoid answering posting of this type for reasons given in the JavaRanch link. Others will answer anyway. Other might first check the other site to see if they are wasting there time, but they can only do that if a link was posted with the original question.
    The only suggestion I have is to repost the question, (since this posting is now completely off topic) making sure to then respond to this posting stating that a fresh question has been asked so you don't get a discussion going on in two places.

  • Strange behaviour BOXI R2

    Post Author: Ermakov Alexey
    CA Forum: .NET
    using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using CrystalDecisions.Enterprise;using BusinessObjects.ReportEngine;using BusinessObjects.Enterprise.Desktop;using System.IO;using System.Runtime.InteropServices;using System.Collections;namespace BusinessObjectsInteroperation{     public class BusinessObjectsInterop     {          public void GetBinaryReportByName(string NameOfTheReport, Stream StreamForDataBeWritten, BOConfigs BOCfg, OutputFormatType OutputFormat, Hashtable PromptValues)          {               EnterpriseSession enterpriseSession = null;               ReportEngines reportEngines = null;               SessionMgr sessionMgr = new SessionMgr();               try               {                    enterpriseSession = sessionMgr.Logon(BOCfg.BO_LoginName, BOCfg.BO_Password, BOCfg.BO_MachineToConnect, BOCfg.BO_LoginType);               }               catch (COMException exc)               {                    int HRESULT = exc.ErrorCode;                    switch (HRESULT)                    {                         case -2147210751:                              throw new ArgumentException(" BO_MachineToConnect");                         case -2147211005:                              throw new ArgumentException(" BO_LoginName");                         case -2147211006:                              throw new ArgumentException(" BO_Password");                         case -2147210653:                              throw new ArgumentException(" BO_LoginType");                         default:                              throw new ArgumentException("");                    }               }               InfoStore iStore = (InfoStore)enterpriseSession.GetService("InfoStore");               UserInfo userInfo = enterpriseSession.UserInfo;               if (enterpriseSession != null)               {                    if (reportEngines == null)                    {                         int iMinuteNumber = 1;                         int iLogonNumber = 1;                          string strToken = enterpriseSession.LogonTokenMgr.CreateWCAToken("", iMinuteNumber, iLogonNumber);                         reportEngines =  new ReportEngines(strToken);                    }               }                              IReportEngine reportEngine = reportEngines.getService(ReportEngineType.FC_ReportEngine);               FullClient ReportToPrint = (FullClient)getReport(iStore, NameOfTheReport, CrystalDecisions.Enterprise.InfoStore.CeKind.FullClient);               IDocumentInstance doc = null;               try               {                    doc = reportEngine.OpenDocument(ReportToPrint.ID); //ERROR Happens here               }               catch(Exception e)               {                    Console.Write(e.StackTrace);               }                              doc.Refresh();               IPrompts prompts = doc.GetPrompts();               foreach (IPrompt ip in prompts)               {                    string OnlyOneValue="";                    try                    {                         OnlyOneValue = (string)PromptValues&#91;ip.Name&#93;;                    }                    catch(IndexOutOfRangeException exc)                    {                         throw new ArgumentException(String.Format("Отчет {0} имеет необходимый параметр , который не был предоставлен.", NameOfTheReport, ip.Name), exc);                    }                    string&#91;&#93; vlArr = ; //Почему одному IPrompt надо передавать массив значений остается загадкой.                    ip.EnterValues(vlArr);               }               doc.SetPrompts();               IBinaryView docBinaryView = (IBinaryView)doc.GetView(OutputFormat);               docBinaryView.WriteContent(StreamForDataBeWritten);               doc.CloseDocument();                              reportEngine.Close();               reportEngines.Close();               iStore.Dispose();               enterpriseSession.Logoff();               enterpriseSession.Dispose();                                        }                    private InfoObject getReport(InfoStore iStore, string Name, string Kind)          {               InfoObjects list = null;               string query = String.Format(@"                SELECT                     SI_ID,                     SI_NAME,                          SI_PARENTID,                         SI_KIND,                          SI_INSTANCE,                          SI_DESCRIPTION                     FROM                         CI_INFOOBJECTS                     WHERE                          SI_KIND='{0}' AND                         SI_NAME=''", Kind, Name);                list = iStore.Query(query);               if (list.Count == 0)               {                    throw new Exception(String.Format("На сервере не существует отчета с именем {0}, его необходимо создать. Либо у вас нет на него прав.", Name));               }               if (list.Count > 1)               {                    throw new Exception(String.Format("На сервере существует более одного отчета с именем {0}, удалите неверный.", Name));               }               foreach (InfoObject obj in list)               {                    return obj;               }               return null;          }          public void ReportInPdfToHTTPResponse(string NameOfTheReport, params Par&#91;&#93; Prompts)          {               Hashtable PromptValues = new Hashtable();               foreach (Par p in Prompts)               {                    PromptValues.Add(p.Key, p.Value);               }               HttpResponse Response = HttpContext.Current.Response;               Response.Clear();               Response.ContentType = "application/pdf";               Response.AddHeader("Content-Type", "application/pdf");               Response.Expires = 0;               GetBinaryReportByName(NameOfTheReport, Response.OutputStream, new BOConfigs(), OutputFormatType.Pdf, PromptValues);               Response.Flush();               Response.End();          }          public void ReportInXlsToHTTPResponse(string NameOfTheReport, params Par&#91;&#93; Prompts)          {               Hashtable PromptValues = new Hashtable();               foreach (Par p in Prompts)               {                    PromptValues.Add(p.Key, p.Value);               }               HttpResponse Response = HttpContext.Current.Response;               Response.Clear();               Response.ContentType = "application/vnd.ms-excel";               Response.AddHeader( "Content-Type", "application/vnd.ms-excel");               Response.Expires = 0;               GetBinaryReportByName(NameOfTheReport, Response.OutputStream, new BOConfigs(), OutputFormatType.Xls, PromptValues);               Response.Flush();               Response.End();          }               }     } I have this code, but it has strange behaviour.When I restart IIS and run this function first time, I get an ArgumentOutOfRangeException in reportEngine.OpenDocument(ReportToPrint.ID);But the most strange thing is that Visual Studia shows me exception dialog and if I press Continue, then it works good.On more strange thing I get about this Code. From time to time server shows me such error:An unhandled exception of type 'BusinessObjects.ThirdParty.OOC.OB.AssertionFailed' occurred in businessobjects.enterprise.sdk.netmodule Additional information: ORBacus encountered an internal error

    Post Author: Ermakov Alexey
    CA Forum: .NET
         mscorlib.dll!System.String.LastIndexOf(char value, int startIndex) + 0x13 bytes           log4net.dll!log4net.Repository.Hierarchy.Hierarchy.UpdateParents(log4net.Repository.Hierarchy.Logger log = {log4net.Repository.Hierarchy.DefaultLoggerFactory.LoggerImpl}) + 0x1cf bytes           log4net.dll!log4net.Repository.Hierarchy.Hierarchy.GetLogger(string name = ".cctor", log4net.Repository.Hierarchy.ILoggerFactory factory = {log4net.Repository.Hierarchy.DefaultLoggerFactory}) + 0x12b bytes           log4net.dll!log4net.Repository.Hierarchy.Hierarchy.GetLogger(string name = ".cctor") + 0x46 bytes           log4net.dll!log4net.Core.LoggerManager.GetLogger(System.Reflection.Assembly repositoryAssembly = {System.Reflection.Assembly}, string name = ".cctor") + 0x94 bytes           log4net.dll!log4net.LogManager.GetLogger(System.Reflection.Assembly repositoryAssembly = {System.Reflection.Assembly}, string name = ".cctor") + 0x1b bytes           log4net.dll!log4net.LogManager.GetLogger(string name = ".cctor") + 0x1e bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Lib.Tracing.CELogger.CELogger(string name = ".cctor") + 0x20 bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Lib.Tracing.TraceManager.LoggerFactoryHelper.makeLogger(string name = ".cctor") + 0x35 bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Lib.Tracing.TraceManager.getLogger(string name = ".cctor") + 0x4a bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.AbstractSchedulableObject..cctor() + 0x23 bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.SchedulableInfoObject.SchedulableInfoObject() + 0xf bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.InfoObjects.newInfoObject(System.Object plgKey = ) + 0xbb bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.InfoObjects.continueUnpack(BusinessObjects.Enterprise.OcaFramework.Oca.InfoStore.info_wire_ob3&#91;&#93; wireObjs = {Length=0x1}) + 0x40a bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.InfoObjects.startUnpack(BusinessObjects.Enterprise.Security.Internal.ISecuritySession session = {BusinessObjects.Enterprise.Security.Internal.SecuritySession}, BusinessObjects.Enterprise.Infostore.IInfoStore infoStore = {BusinessObjects.Enterprise.Infostore.Internal.InfoStore}, BusinessObjects.Enterprise.OcaFramework.Oca.InfoStore.info_wire_ob3&#91;&#93; wireObjs = {Length=0x1}) + 0x9b bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.InfoStore.queryHelper(string query = "SELECT SI_MACHINE, SI_MACHINECHOICE from CI_INFOOBJECTS WHERE SI_ID=2762", BusinessObjects.Enterprise.Infostore.Internal.InfoObjects objs = {BusinessObjects.Enterprise.Infostore.Internal.InfoObjects}) + 0x149 bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Infostore.Internal.InfoStore.Query(string query = "SELECT SI_MACHINE, SI_MACHINECHOICE from CI_INFOOBJECTS WHERE SI_ID=2762") + 0x2f bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Ras21.RASConnection.initServerSpec(BusinessObjects.Enterprise.OcaFramework.ServerSpec serverSpec = {BusinessObjects.Enterprise.OcaFramework.ServerSpec}) + 0x30d bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Ras21.RASConnection.init(BusinessObjects.Enterprise.Ras21.IRASConnectionInitService i_initService = <undefined value>) + 0x422 bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Ras21.RASConnection.RASConnection(string i_sServerKind = "dpscacheFullClient", BusinessObjects.Enterprise.Ras21.Messages.GetConnection i_getConnection = {BusinessObjects.Enterprise.Ras21.Messages.GetConnection}, System.IO.Stream i_documentStream = <undefined value>, BusinessObjects.Enterprise.Ras21.IRASConnectionInitService i_initService = <undefined value>, BusinessObjects.Enterprise.Ras21.Serialization.IServerDeserializerFactory i_deserializerFactory = {BusinessObjects.Enterprise.Ras21.RASConnectionFactory.RASConnectionServerSerializationFactory}, BusinessObjects.Enterprise.Ras21.Serialization.IServerSerializerFactory i_serializerFactory = {BusinessObjects.Enterprise.Ras21.RASConnectionFactory.RASConnectionServerSerializationFactory}) + 0x18a bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Ras21.RASConnectionFactory.getRASConnection(string i_sServerKind = "CrystalEnterprise.FullClient", System.Globalization.CultureInfo i_locale = {System.Globalization.CultureInfo}, BusinessObjects.Enterprise.Security.Internal.ISecuritySession i_secSession = {BusinessObjects.Enterprise.Security.Internal.SecuritySession}, BusinessObjects.Enterprise.Ras21.Messages.GetConnection.DocumentId i_documentId = {BusinessObjects.Enterprise.Ras21.Messages.GetConnection.DocumentId}, System.IO.Stream i_documentStream = <undefined value>, BusinessObjects.Enterprise.Ras21.IRASConnectionInitService i_initService = <undefined value>) + 0x156 bytes           businessobjects.enterprise.sdk.netmodule!BusinessObjects.Enterprise.Ras21.RASConnectionFactory.getRASConnectionObjectId(string i_sServerKind = "CrystalEnterprise.FullClient", System.Globalization.CultureInfo i_locale = {System.Globalization.CultureInfo}, BusinessObjects.Enterprise.Security.Internal.ISecuritySession i_secSession = {BusinessObjects.Enterprise.Security.Internal.SecuritySession}, int i_nObjectId = 0xaca) + 0x108 bytes           businessobjects.reportengine.fc.dll!BusinessObjects.ReportEngine.FC.ras21.XMLviaRAS21Encode.newSession(BusinessObjects.ReportEngine.FC.ras21.RAS21SessionID i_occaSession = {BusinessObjects.ReportEngine.FC.ras21.RAS21SessionID}, string i_sLocale = "en-US", int i_nDocId = 0xaca, string s_iConnID = "1") + 0x107 bytes           businessobjects.reportengine.fc.dll!BusinessObjects.ReportEngine.FC.ras21.RAS21ReportEngineComAdapter.InitRAS21Connection(BusinessObjects.ReportEngine.FC.ras21.RAS21SessionID i_occaSession = {BusinessObjects.ReportEngine.FC.ras21.RAS21SessionID}, string i_sLocale = "", bool i_bNewDoc = false, int i_nDocId = 0xaca, string i_sConnID = "1") + 0x1d bytes           businessobjects.reportengine.fc.dll!BusinessObjects.ReportEngine.FC.ras21.RAS21ReportEngineComAdapter.openDocument(BusinessObjects.ReportEngine.Internal.Utilities.Storage.IStorageManager storageManager = {BusinessObjects.ReportEngine.Internal.Utilities.Storage.ClusterStorageManager}, string sLocale = "", int docID = 0xaca) + 0xde bytes           businessobjects.reportengine.fc.dll!BusinessObjects.ReportEngine.FC.ReportEngineImpl.OpenDocument(int docID = 0xaca) + 0x107 bytes     >     businessobjectinteroperation.dll!BusinessObjectsInteroperation.BusinessObjectsInterop.GetBinaryReportByName(string NameOfTheReport = "DO_Raport", System.IO.Stream StreamForDataBeWritten = {System.Web.HttpResponseStream}, BusinessObjectsInteroperation.BOConfigs BOCfg = {BusinessObjectsInteroperation.BOConfigs}, BusinessObjects.ReportEngine.OutputFormatType OutputFormat = Pdf, System.Collections.Hashtable PromptValues = {Count=0x3}) Line 80 + 0x22 bytes     C#

  • Strange behaviour or not?

    Hi all...I'm new in this forum and I have a question to you. I think my curiosity is about the compiler, so I post here.
    I use Java SE 1.5 and 1.6. If I write a simple class like the following
    public class Prova{
    public static void main(String[] args){
    Integer a1=128;
    Integer a2=128;
    /*1*/System.out.println(a1==a2);
    /*2*/System.out.println(a1);
    /*3*/System.out.println(a2);
    I get the following strange result
    /*1*/ prints true if a1 and a2 are both inizialized between -128 and 127 (exactly 256 values, the ones obtainable from a byte) and false for values less then -128 or bigger then 127...
    Is this a strange behaviour or not? Why do I obtain such results?
    please note that /*2*/ and /*3*/ ALWAYS print the declared values (in this case 128).
    thank you!

    Shadow-DK wrote:
    From version 1.5 that declaration began correct and the result was similar to Integer i = new Integer(100);
    No that wouldn't permit caching. Its like Integer i = Integer.valueOf(100);The caching MUST occur for values -128 thru 127, it may occur for other values. I would not rely on caching not occurring outside that range.
    See [the language spec section on boxing conversion|http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7]
    If you aren't sure what the compiler is doing, it can be informative to use the javap command with the -c option to view the classfile.
    Usage: javap <options> <classes>...
    where options include:
       -c                        Disassemble the code
       -classpath <pathlist>     Specify where to find user class files
       -extdirs <dirs>           Override location of installed extensions
       -help                     Print this usage message
       -J<flag>                  Pass <flag> directly to the runtime system
       -l                        Print line number and local variable tables
       -public                   Show only public classes and members
       -protected                Show protected/public classes and members
       -package                  Show package/protected/public classes
                                 and members (default)
       -private                  Show all classes and members
       -s                        Print internal type signatures
       -bootclasspath <pathlist> Override location of class files loaded
                                 by the bootstrap class loader
       -verbose                  Print stack size, number of locals and args for met
                                 If verifying, print reasons for failureBruce

  • Strange behaviour of jdbc-mysql driver

    I am trying to store japanese characters in mysql and display also after reading from the database using JSP. I am using the following code.
    <%@ page contentType="text/html; charset=UTF-8"%>
    ....... some code ......
    <%
    Class.forName( "org.gjt.mm.mysql.Driver" );
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8", "user", "pass" );
    Statement st = con.createStatement();
    st.executeUpdate( "insert into test values('" + request.getParameter( "imgname" ) + "')" );
    ResultSet rs = st.executeQuery( "select * from test" );
    while( rs.next() ) {
    %> DB Value: <%= rs.getString( "imgname" ) %>
    <% } %>
    I found one strange behaviour. I have to change the DriverManger.getConnection line to the following, to write the data correctly in the database.
    DriverManager.getConnection("jdbc:mysql://localhost:3306/DB","user","pass")
    If I read from the database using the same parameters as above, I am getting garbled data.
    To retrieve the data correctly from the database I have to use the following line instead of the previous one.
    DriverManager.getConnection("jdbc:mysql://localhost:3306/DB?useUnicode=true&characterEncoding=UTF-8", "user", "pass" );
    In short, I have to pass different parameters to DriverManager.getConnection() for writing and reading from the database. But it is not possible practically. I am using mm.mysql-2.0.8 jdbc-mysql driver, mysql is 3.23.47 and english windows 2000.
    I have tried the string.getBytes("UTF-8") and new String( getBytes(string), "UTF-8") methods, but not getting the correct data.
    Can anybody guide me how can I store and display the japanese character correctly?
    Thanks to all,
    gaurang.

    I downloaded the latese driver from sourceforge, but still the same thing is happening. Is there any other thing which I should do?
    Thanks
    gaurang.

  • Strange behaviour of a Simple Servlet.Please explain

    I am experiencing a strange behaviour from this servlet.
    I have written a servlet that expects some data from the client.
    So I startup Tomcat and invoke this servlet thru the brower:
    http://localhost:8080/A_SYMBIAN_SERVLET/servlet/Recieve_Http_Data.
    The Console displays:
    Server Ready to receive Message from Symbian Application...
    How come the console is not displaying
    In Receive_Http_Data [Client] :
    at the same time at the console ? How come it is only displaying the first line?
    Shudnt the 'In Receive_Http_Data [Client] be displayed if you invoke this servlet
    thru the browser?
    Can anyone explain this strange behaviour!!!
    Attached is my servlet:
    public class Recieve_Http_Data extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    System.out.println("Server Ready to receive Message from Symbian Application...");
    BufferedReader br=null;
    /* Data Read by the Servlet*/
    String sMess="";
    // Receive data.
    DataInputStream dis = new DataInputStream(request.getInputStream());
    sMess = dis.readUTF();
    System.out.println("In Receive_Http_Data [Client] : " + sMess);
    Can some one explain this strange behaviouR!!!

    Ok,I will write an inputstream as you have mentioned in yr mail.
    Now,i will write a servlet with the code you have mentioned.
    Now how do I know that the servlet is up and running and ready to
    receive data from an application.
    OK,This is what is the actual application:
    I am supposed to receive some test data from a Mobile device
    which has the Symbian O/S.
    The application on the mobile device is in C++.
    This C++ Application connects to my Servlet and sends in request
    parameters.The application specifically specifies the name of my
    servlet and the protocol(ie method.Connect(URL,'HTTP1.1!))
    I have written this servlet on Tomcat 3.2.4 which will receive
    this request and display it on my console and return a response
    back to the symbian application.(ie the output stream of the servlet).
    So,your code will read the parameters sent in by the Symbian
    application.right?
    Could you also send in the how the outputstream from the servlet
    will be sent to the c++ application.
    An urgent reply is much appreiciated.

  • Strange behaviour whit custom JTextField and JToolTip

    Hello everyone. I hope I'm writing in the right section and sorry if I did not search for this issue but I really don't know which keywords I should use.
    I'm using NetBeans 6.1 on WinXP and JDK 1.6.0_07, I have a custom JTextField with regex validation: when you type something that don't mach regex it shows a JToolTip. This JToolTip should disappear when the text typed is finally correct, or when the textfield loses focus (see code below).
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Point;
    import javax.swing.JToolTip;
    import javax.swing.Popup;
    import javax.swing.PopupFactory;
    public class MyJTextField extends javax.swing.JTextField implements FormComponent
    private static Popup popUpToolTip;
    private static PopupFactory popUpFactory = PopupFactory.getSharedInstance();
    private boolean isValidated = false;
    private String regEx = "a regex";
    public MyJTextField()
    this.addKeyListener(new java.awt.event.KeyAdapter()
    public void keyReleased(java.awt.event.KeyEvent evt)
    if(evt.getKeyCode()!=java.awt.event.KeyEvent.VK_ENTER)
    validateComponent();
    else if(evt.getKeyCode()==java.awt.event.KeyEvent.VK_ENTER)
    if(isValidated)
    ((Component)evt.getSource()).transferFocus();
    this.addFocusListener(new java.awt.event.FocusAdapter()
    public void focusLost(java.awt.event.FocusEvent evt)
    if(popUpToolTip!=null){popUpToolTip.hide();}
    public void validateComponent()
    if(text.matches(regex))
    isValidated = true;
    if(popUpToolTip!=null){popUpToolTip.hide();}
    else
    isValidated = false;
    if(popUpToolTip!=null){popUpToolTip.hide();}
    String error = "C'&egrave; un errore nella validazione di questo campo";
    JToolTip toolTip = createToolTip();
    toolTip.setTipText(error);
    popUpToolTip = null;
    popUpToolTip = popUpFactory.getPopup(
    this,
    toolTip,
    getLocationOnScreen().x,
    getLocationOnScreen().y - this.getPreferredSize().height -1
    popUpToolTip.show();
    }(I've cut it a bit, here's only the lines that involve JToolTip use)
    I have many of them in a form, and when the first tooltip appears (on the first textfield I type in) it never disappears, while nex textfields work just fine.It seems the first tooltip appearing can't be overwritten or something similar. If I use this same component on any other NetBeans project, everithing works without issues.
    I have some other custom components working the same way (JComboBox, JXDatePicker), and they had this "not disappearing tooltip" issue since I changed this
    popUpToolTip = popUpFactory.getPopup(this, toolTip, getLocationOnScreen().x, getLocationOnScreen().y - this.getPreferredSize().height -1);
    whit this
    popUpToolTip = popUpFactory.getPopup(null, toolTip, getLocationOnScreen().x, getLocationOnScreen().y - this.getPreferredSize().height -1);
    but if I try it on the JTextField all textfield's tooltips stay stuck there, not only the first one appeared (while other components still works fine).
    This thing is really driving me crazy. Someone has an hint (or a link to another thread) which could explain this strange behaviour?
    Thanks in advance.

    BoBear2681 wrote:
    Note that an SSCCE wouldn't require you to post any proprietary code.Hmmm... well, I'll try again to reproduce the issue and post an SSCCE.
    BoBear2681 wrote:
    That probably indicates that the problem is somewhere other than where you're currently looking.Yes, I suppose so. Maybe it's some interference between all the custom components I created, or maybe something else that apparently doesn't conern at all. If I cannot reproduce it in an SSCCE and I'll figure out what's the cause of this mess I'll post it here for future knowledge.
    Many thanks for your advices. :)

  • A strange behaviour throwing Threads via anonymous class technique

    Hi friends!
    I've noted a strange behaviour executing the next code:
    public class ResolAnonimes
         private int value;
         public ResolAnonimes(int value)
              this.value = value;
         public ResolAnonimes myMethod(int nThreads)
              final ResolAnonimes a = this;
              int nThreadsFor = nThreads - 1;
              for( int i=0; i < nThreadsFor; i++)
                   new Thread(){
                        public void run()
                                System.out.println(Thread.currentThread().getName() + " has begun processing");
                                     doSomethingWith(a);
                                System.out.println(Thread.currentThread().getName() + " has finished processing");
                   }.start();
                   this.value++;
              }//for loop
              return a;
         public static void doSomethingWith(ResolAnonimes a)
              System.out.println(a.value);
         public static void main(String Args[])
              ResolAnonimes first = new ResolAnonimes(1);
              ResolAnonimes result = first.myMethod(5);
    }When I execute it, that's the output I get:
    Thread-0 has begun processing
    2
    Thread-0 has finished processing
    Thread-0 has begun processing
    3
    Thread-0 has finished processing
    Thread-0 has begun processing
    4
    Thread-0 has finished processing
    Thread-0 has begun processing
    5
    Thread-0 has finished processingWhere's the "1" printed? It doesn't appear! It seems it has thrown only 4 threads, not 5.
    Am I doing anything wrong? Is it a bug?
    Can you help me, please?
    Thank you in advance.

    Oh I'm sorry. I was changing the code because of privacy rerasons and I finally didn't type what I want.
    Consider an array which all cells must be typed with the array lentgh. Moreover, the work is distributed by some threads.
    I'm refering to something like this:
    import java.util.Random;
    import java.util.LinkedList;
    public class MyArray
         private static int initialRow = 0;
         private static int lastRow = 0;
         private int[] vector;
         public MyArray(int size)
              vector = new int[size];
         public static boolean correctIndex(MyArray a )
              for(int i = 0; i< a.vector.length; i++)
                   if(a.vector[i] != a.vector.length)
                        return false;
              return true;
         public String toString()
              String s ="";
              for(int i=0; i < this.vector.length; i++)
                   s += this.vector[i] + " ";
              return s;
         public MyArray  operationWith(int nThreads)
              MyArray a = this;
              MyArray result = null;
              final Contenidor ctros = new Contenidor(new LinkedList());
              result = a.putTheIndexValue(nThreads, ctros);
              Thread consumerThread = new Thread( new Consumer( ctros, nThreads));
              consumerThread.start();
              try
                   consumerThread.join();
              catch(InterruptedException ie){}
              return result;
         public MyArray putTheIndexValue(int nThreads, Contenidor ctros) //Este metode encara es experimental
              final MyArray a = this;
              final MyArray result = new MyArray( a.vector.length);
              final Contenidor ctrosR = ctros;
              for(int i = 0; i < result.vector.length; i++)
                        result.vector= 0;
              int incRows = a.vector.length / nThreads - 1;
              initialRow = 0;
              lastRow= incRows;
              int nFilsFor = nThreads - 1;
              Thread[] vectorFils = new Thread[nThreads];
              for( int i=0; i < nFilsFor; i++)
                   /*vectorFils[i] = */ new Thread()
                                                 public void run()
                                                      System.out.println(Thread.currentThread().getName() + " has begun processing");
                                                      MyArray.putTheIndexValue( a, initialRow, lastRow);
                                                      System.out.println(Thread.currentThread().getName() + " has finished processing");
                                                      String s = Thread.currentThread().getName();
                                                      ctrosR.put(s);                         
                   vectorFils[i]*/.start();
                   initialRow = initialRow + 1;
                   lastRow = initialRow + incRows;
              new Thread()
                   public void run()
                        System.out.println(Thread.currentThread().getName() + " has begun processing");
                        MyArray.putTheIndexValue( a, initialRow, a.vector.length - 1);
                        System.out.println(Thread.currentThread().getName() + " has finished processing");
                        String s = Thread.currentThread().getName();
                        ctrosR.put(s);                         
                   vectorFils[i]*/.start();
              return result;
         public static void putTheIndexValue( MyArray a, int initialRow, int lastRow)
              for(int i = initialRow; i <= lastRow; i++)
                   a.vector[i] = a.vector.length;
    public class Interface
         public static void main(String Args[])
              int nThreads = 2;
              int arraySize = 5;
              MyArray ma = new MyArray(arraySize);
              MyArray result = ma.operationWith(nThreads);
              if(MyArray.correctIndex(result))
                   System.out.println("The operation has been done correctly");
              else
                   System.out.println("THE OPERATION HAS NOT BEEN CORRECTLY!");
              System.out.println(ma.toString());
    public class Consumer implements Runnable
         private Contenidor ctros;
         private int nFils;
         public Consumer(Contenidor ctros, int nFils)
              this.ctros = ctros;
              this.nFils = nFils;
         public void run()
              System.out.println(Thread.currentThread().getName() + "is waiting the total process to be finished");
              for(int i = 0; i< nFils; i++)
                      System.out.println( Thread.currentThread() + " is waiting a thread to give me its chunk");
                      String s = ctros.get();
                      System.out.println( Thread.currentThread() + ":  " + s + " has already given me its chunk");
                 System.out.println(Thread.currentThread().getName() + "says all threads have finished");
    import java.util.Queue;
    import java.util.LinkedList;
    public class Contenidor
        private int nDadesNoves;
        private Queue contenidor;
        public Contenidor(Queue contenidor)
            this.contenidor = contenidor;
            this.nDadesNoves = 0;
        public synchronized String get()
            while(nDadesNoves < 1)
                try
                    wait();
                catch(InterruptedException ie){}
            nDadesNoves--;
            notifyAll();
            return (String)contenidor.poll();
        public synchronized void put(String s)
            contenidor.offer(s);
            nDadesNoves++;
            notifyAll();
    }The output I get sometimes is:
    THE OPERATION HAS NOT BEEN CORRECTLY!
    5 5 5 5 5And I get also sometimes that:
    THE OPERATION HAS NOT BEEN CORRECTLY!
    0 5 5 5 5That's what I wanted to refer last post. I think I'm doing a correct synchronization. Am I wrong?
    I don't understand that behaviour.
    Anyone can help me, please?
    Thank you in advance.

  • Strange behaviour concerning JSF phases

    Hi all,
    I have a JSF page that displays two custom JSF tables, ‘A’ and ‘B’ with his correspondent’s pagers.
    <mycustom:table id="A" ... pager="#{tableA.pager}">
    <mycustom:table id="B" ... pager="#{tableB.pager}">I experiment a strange behaviour when I hit ‘tableA.next’ link.
    This is the flow (summarized):
    First-Page-Load (START)
    encodeA
    encodeB
    First-Page-Load (END)
    <User hits TableA.nextPage pager link>
    decodeA
         pagerA.setNext(true)
    decodeB
    encodeA
         pagerA.getNext() returns ‘false’ ¿? (here is the problem! should return ‘true’)
    encodeB
         pagerB.getNext() returns ‘true’ ¿? (should return ‘false’)Any help will be appreciated...

    Self-solved:
    Inside the ‘decode’ method I must get the ‘pager’:
    pager = getPager(table); //This line is essential!!
    String pLink = (String)requestMap.get("pLink" + clientId);
    if ((pLink != null) && (!pLink.equals(""))) {
         if (pLink.equals("next")) { //Siguientes                                         
              pager.setNext(true);
         } else if (pLink.equals("previous")) { //Anteriores
              pager.setPrevious(true);
    }

  • Strange behaviour of JTree makes it hard to find the mistake.

    Hi,
    I would like to report a problem I actually already solved. But the mistake was not easy to find because of a strange behaviour of the JTree.
    The mistake I made is that I declared a 'treeModel' in a JTree and added new entries to this model but I didnot connect the model to the tree correctely.
    One would expect that simply nothing would happen when calling addNode(). But effectively the first node is added! After calling addNode() again no more nodes are added but the vertical lines of the tree-angles are disapearing (so one thinks the model is connected to the tree correctely because the tree changes its look in a strange way..).
    Whole, compilable code which lets disapear the vertical lines of the tree-angles:
    import javax.swing.*;
    import javax.swing.tree.*;
    public class Strange
        static class MyTree extends JTree
              static DefaultMutableTreeNode root = new  DefaultMutableTreeNode("Root");
              static DefaultTreeModel treeModel = new DefaultTreeModel( root );
              public MyTree()
                   super( root );
              public void addNode()
                   DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("New Node");
                   treeModel.insertNodeInto( newNode, root, root.getChildCount() );
                   expandPath( new javax.swing.tree.TreePath(root) );
         public static void main(String[] args)
              JFrame jframe = new JFrame();
              MyTree mytree = new MyTree();
              jframe.add(mytree);
            jframe.setBounds( 50, 50, 300, 200 );
              jframe.setVisible( true );
              mytree.addNode();
              mytree.addNode();     
              mytree.addNode();
    }Message was edited by:
    MarcMooser

    Simple.... change in constructor super( treeModel );

  • Strange behaviour of CC compiler with templates

    Hello!
    I have noticed a strange behaviour of CC compiler.
    The followint test-case compiles normally:
    #include <stdio.h>
    #include <complex>
    using namespace std;
    extern "C++" {
    template <class FLOAT> complex<FLOAT>
    cos (const complex<FLOAT>& x)
    return complex<FLOAT> (cos (real (x)) * cosh (imag (x)),
    - sin (real (x)) * sinh (imag (x)));
    int main(){
    return 0;
    But if you commenty string
    "using namespace std;" it gives error:
    /opt/ss11/SUNWspro/bin/CC test.cc
    "test.cc", line 8: Error: Templates can only declare classes or functions.
    "test.cc", line 14: Error: A declaration was expected instead of "}".
    2 Error(s) detected.
    make: *** [test.o] Error 2
    ----

    Class 'complex' is defined in the 'std' namespace. When you comment out 'using namespace std' compiler can't find definition of 'complex' and so treats function declaration as invalid construction. But I agree the error message is not quite clear.

  • Strange behaviour in "Do - Until" statement

    Hi,
    I'm having a strange behaviour in a script I'm creating. The purpose of the script is to update some files in some folders. In the case that more folders need to use the script, I'm importing the folders name and path from a CSV file (much easier to read
    it from there instead of hardcoding the folders in the code). As you can see, I add a number at the beginning of the folder's name, and then I let them choose which folder number do they want to update.
    # Import from CSV File
    $name = @()
    $path = @()
    $bkpPath = @()
    Import-Csv $AppsFile |
    ForEach-Object {
    $name += $_.Name
    $path += $_.Path
    $bkpPath += $_.bkpPath
    Write-Host "Choose the folder to update:"
    Write-Host ""
    $count = 1
    foreach ($n in $name) {
    Write-Host $count " - " $n
    $count += 1
    Do {$opt = read-host -prompt "Enter the option number"}
    Until ($opt -lt $count -AND $opt -gt 0)
    The problem appears when I started debuging the script, and try to input strange characters. The idea of the "Do - Until" statement, is that the user enters a loop until they choose a correct option. It works ok when it doesn't let you input letters,
    or numbers outside the range I'm using.
    The strange behaviour appears when I enter for example "0." (The important part is the DOT after the zero). There, it sends me to the last option in my CSV file. If I put "<number>.", it reads it as if it were "<number>".
    And if I input a number out of range plus a final dot, it breaks my script (instead of just keep looping as it's supposed to).
    Does anyone even understand the issue? =P It's really strange, I don't know if there is another way to limit the input...
    Thanks,
    Regards

    $opt is a string, and you're trying to compare it to numbers, which is probably going to give you headaches.  I tend to write those types of loops like this:
    $opt = $null
    while ($true)
    $string = read-host -prompt "Enter the option number"
    if ([int]::TryParse($string, [ref]$opt) -and $opt -lt $count -and $opt -gt 0)
    break
    Simply because the validation can get kind of complex sometimes, and I think it's ugly to jam it in after an "until" statement, even though the end result is the same.

Maybe you are looking for

  • Cannot view media in Pages document after copying folder to desktop

    I have created a document in Pages which includes video, which is saved in a folder called Assignments.I also have a folder marked Pictures and Videos which contains the media from the document contained within the Assignments folder. However, the pr

  • NoSuchMethodError: RichTable.getEstimatedRowCount

    Hi, I am using JDev 11.1.1.3.0 and developing web application with adf. Our test server is Weblogic version 11.1.1.2.0 and we get below error after we deploy our application. We have no problem at development enviroment (JDeveloper). I will be apprec

  • How To Work With Jtree Pls Help

    I heared about JTree but dont have idea to use it in form6i where i can get help or sample form can i use jtree in forms 6i

  • All ivr port busy , the system will prompt the next call that it's full load

    /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in

  • PSE 10 organizer changing date times of photos

    I have been having an issue since PSE9 which continues into PSE 10 organizer. After scaning photos and saving into organizer it will not allow assingment of jsut a year or a year month. If I take an old family photo and change date (scanned date) to