Rectangle 27 1

This UnsupportedOperationException comes when you try to perform some operation on collection where its not allowed and in your case, When you call Arrays.asList it does not return a java.util.ArrayList. It returns a java.util.Arrays$ArrayList which is an immutable list. You cannot add to it and you cannot remove from it.

java - Why do I get an UnsupportedOperationException when trying to re...

java exception list arraylist
Rectangle 27 1

This UnsupportedOperationException comes when you try to perform some operation on collection where its not allowed and in your case, When you call Arrays.asList it does not return a java.util.ArrayList. It returns a java.util.Arrays$ArrayList which is an immutable list. You cannot add to it and you cannot remove from it.

java - Why do I get an UnsupportedOperationException when trying to re...

java exception list arraylist
Rectangle 27 1

As other answers have pointed out, the problem you have here is that you are trying to remove from a list while you iterate over it. This isn't allowed in java, except if you remove the element using the iterator's remove method. This means you have two ways about fixing this code.

for(Iterator<Exercise> iterator = z.iterator(); iterator.hasNext();)
{
    Exercise c = iterator.next();
    if(!compareSkillLevel(c,a)|| !compareEquipment(c)|| !compareFocus(c)
            || !compareTraining(c))
        iterator.remove();
}

or, you can loop over the array list using its index, and instead do something like

for(int i = 0;i < z.size(); i++)
{
    Exercise c = z.get(i);
    if(!compareSkillLevel(c,a)|| !compareEquipment(c)|| !compareFocus(c)
            || !compareTraining(c))
        z.remove(i--)
}

Note the i-- here, which is necessary because the act of removing an element from the ArrayList shifts the existing elements over, meaning the next element you want to examine is in the place of the last element.

java - Concurrent Modification Error for Object ArrayList - Stack Over...

java concurrentmodification
Rectangle 27 1

Using two imported elements with the same name will cause this error because JAXB will try to generate two attributes with the same name in a Java class, which isn't allowed.

jaxb2 - JAXB maven plugin Two declarations cause a collision in the Ob...

jaxb jaxb2 maven-jaxb2-plugin
Rectangle 27 0

It is because there is an error in your jrxml file uuid field should be misplaced. If you use ireport tool then you will no need to write jrxml file by your own you will just need to add the bean properties as a filed in that tool and specify its properties and you will get jrxml generated automatically.

I can help you on jasper reports becasue I worked on it for few months on complex reports.

jasper reports - compilation error: ireport with java;Attribute 'uuid'...

java jasper-reports
Rectangle 27 0

That's because the schema does not allow the fixed-rate attribute on that element. My guess is that you want this:

<int:inbound-channel-adapter .... >
    <int:poller >
        <int:interval-trigger fixed-rate=".." />
    </int:poller >
</int:inbound-channel-adapter>

thanks for your suggestion Now I am able to allow fixed-rate but getting another exception " http //www.springframework.org/schema/integration advice-chain ' is expected"

I guess you need to study the schema or some other detailed documentation.

java - Attribute 'fixed-rate' is not allowed to appear in element 'int...

java xml spring
Rectangle 27 0

I've encountered the same problem and I can resolve it like this :

<int:inbound-channel-adapter id="fileTransferChannelAdapter" auto-startup="true" ref="fileTransferCollector" method="poll" channel="fileTransferChannel">
    <int:poller fixed-rate="500">
    </int:poller>
</int:inbound-channel-adapter>

java - Attribute 'fixed-rate' is not allowed to appear in element 'int...

java xml spring
Rectangle 27 0

<bean:beans xmlns:b="http://www.springframework.org/schema/beans"
xmlns="http://www.springframework.org/schema/security"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<http auto-config='true'>
   <intercept-url pattern="/admin**" access="ROLE_USER" />
    <form-login 
        login-page="/login" 
        default-target-url="/welcome" 
        authentication-failure-url="/login?error" 
        username-parameter="username"
        password-parameter="password" />
    <logout logout-success-url="/login?logout"  />
        </http>

<authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="mkyong" password="123456" authorities="ROLE_USER" />
        </user-service>
    </authentication-provider>
</authentication-manager>
</beans:beans>

I have updated your configuration to use version in all XSD schemas

Following error occurs after updating configuration as you said: Line 10 in XML document from ServletContext resource [/WEB-INF/spring-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 118; The prefix "bean" for element "bean:beans" is not bound. org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)

<beans:beans
<bean:beans

I did as you said. There was also an another problem. that is I had did xmlns:b instead of xmlns:beans. Thanks friend for your help. This problem is solved, but now there is another problem. When I submit username and password in login.jsp page, it says that "The requested resource is not available." Please Help me.

java - cvc-complex-type.3.2.2: Attribute 'username-parameter' is not a...

java spring spring-security
Rectangle 27 0

In your source document the attribute is correctly spelled

xsi:schemaLocation

But in the error message it has the spelling

xsi:schemalocation
          ^

I suspect that you are showing us the corrected version, and that the document you actually validated had the incorrect spelling.

java - cvc-complex-type.3.2.2: Attribute 'xsi:schemalocation' is not a...

java xml xsd
Rectangle 27 0

That's because the schema does not allow the fixed-rate attribute on that element. My guess is that you want this:

<int:inbound-channel-adapter .... >
    <int:poller >
        <int:interval-trigger fixed-rate=".." />
    </int:poller >
</int:inbound-channel-adapter>

thanks for your suggestion Now I am able to allow fixed-rate but getting another exception " http //www.springframework.org/schema/integration advice-chain ' is expected"

I guess you need to study the schema or some other detailed documentation.

java - Attribute 'fixed-rate' is not allowed to appear in element 'int...

java xml spring
Rectangle 27 0

package com.ibm.NotesJava.agents;

import lotus.domino.*;

import java.io.File;
import java.io.FileInputStream;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.List;
import java.awt.event.*;
import java.text.SimpleDateFormat;

public class MyJavaAgent extends AgentBase {
   //Main metho which is called by lotus notes
    public void NotesMain() {

        try {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            // (Your code goes here)
            Name n = session.createName(agentContext.getEffectiveUserName());
            String st = n.getCommon();
            Log log=session.createLog("JAVA_AGENT");
            log.openFileLog("JAVA_AGENT.log");
            MessageBox mb = new MessageBox();
            try{
                log.logAction("");
                log.logAction("******************************Starting JAVA AGENT ************************");
                log.logAction("Hello " + st + "!"); 
                log.logAction("Executing JavaAgentTest with Agent: "+agentContext.getCurrentAgent().getName());
                Database db = agentContext.getCurrentDatabase();
                //System.out.println("Loading emaildetails.properties file from following location:C:\\Program Files\\Lotus\\Notes\\framework\\emaildetails.properties");
                log.logAction("Loading emaildetails.properties file from following location:C:\\Program Files\\Lotus\\Notes\\framework\\emaildetails.properties");
                Properties pro = new Properties();
                File fil = new File("C:\\Program Files\\Lotus\\Notes\\framework\\emaildetails.properties");
                //***********LOGIC*********
                DocumentCollection coll=agentContext.getUnprocessedDocuments();
                Document doc=coll.getFirstDocument();
                //get  input from user about the process area 
}
}

/************************Library Code ***********************************/
/* 
 * The MessageBox class allows you to create simple message boxes
 * using only the java.awt classes. All you have to do is create an instance
 * of a MessageBox and use it to call the doOkCancelDialog or the
 * doInputBox methods. You can use a single MessageBox instance to
 * create multiple dialogs.
 *
 * This class has been implemented here as an inner class, but there's
 * no reason why it couldn't be a class all by itself. The functionality to
 * create buttons and messageboxes has been modularized, so it should
 * be easy for you to add your own methods to this class, or make global
 * modifications as you desire.
 *
 * The only really complicated/weird thing I had to do was to write and
 * include the MultiLineLabel class, which is included towards the end
 * of this class as an inner class. Read the comments associated with
 * that class to see what's going on there.
 *
 * Make sure you import java.awt.* and java.awt.event.*
 *
 * Julian Robichaux -- http://www.nsftools.com
 */
class MessageBox {

    public final int NO_ACTION = -1;
    public final int CANCEL_ACTION = 0;
    public final int OK_ACTION = 1;
    int actionCode = NO_ACTION;

    Frame parent;
    Dialog msgbox;
    MultiLineLabel msglabel;        // our custom class, defined later
    Panel buttons;
    Button ok, cancel;
    TextField textbox;
    Choice dropdown;
    List multilist;

    public MessageBox ()  {
        // this is the invisible Frame we'll be using to call all of our Dialogs
        parent = new Frame();
    }

    public void dispose ()  {
        // use this when you're ready to clean up
        try { msgbox.dispose(); }  catch (Exception e)  {}
        try { parent.dispose(); }  catch (Exception e)  {}
    }

    /* 
     * This method will create a simple dialog box with a title, a message,
     * and Ok/Cancel buttons. It will halt execution of your program until
     * one of the buttons is clicked, and it will return either OK_ACTION
     * if the Ok button is clicked, or CANCEL_BUTTON if the Cancel
     * button is clicked.
     */
    public int doOkCancelDialog (String title, String message)  {
        actionCode = NO_ACTION;
        try  {
            // create the messagebox
            msgbox = new Dialog(parent, title, true);
            msgbox.setLayout(new BorderLayout());

            // create the label
            initMsglabel(message);
            msgbox.add("North", msglabel);

            // create the OK and Cancel buttons
            buttons = new Panel();
            buttons.setLayout(new FlowLayout());
            initOkButton();
            buttons.add(ok);
            initCancelButton();
            buttons.add(cancel);
            msgbox.add("South", buttons);

            // display everything (the system will wait until a button is pressed
            // before returning)
            displayMsgbox();
            msgbox.dispose();       // just in case the ActionListeners didn't fire...
        }  catch (Exception e)  {
        }

        return actionCode;
    }

    /* 
     * This method will create a dialog box that allows the user to enter
     * text into a field. It also has a title, a message, and Ok/Cancel buttons, 
     * and will halt execution of your program until one of the buttons is
     * clicked or the user enters text into the field and presses "Enter".
     * If the user clicks the Ok button or enters text and presses "Enter",
     * then the text in the field will be returned; otherwise, this method will
     * return null (which usually indicates that the user clicked Cancel).
     */
    public String doInputBox (String title, String message, String defaultText)  {
        actionCode = NO_ACTION;
        try  {
            // create the messagebox
            msgbox = new Dialog(parent, title, true);
            msgbox.setLayout(new BorderLayout());

            // create the label
            initMsglabel(message);
            msgbox.add("North", msglabel);

            // create the text field
            initTextbox(defaultText);
            msgbox.add("Center", textbox);

            // create the OK and Cancel buttons
            buttons = new Panel();
            buttons.setLayout(new FlowLayout());
            initOkButton();
            buttons.add(ok);
            initCancelButton();
            buttons.add(cancel);
            msgbox.add("South", buttons);

            // display everything (the system will wait until a button is pressed
            // before returning)
            displayMsgbox();
            msgbox.dispose();       // just in case the ActionListeners didn't fire...
        }  catch (Exception e)  {
        }

        if (actionCode == OK_ACTION)
            return textbox.getText();
        else
            return null;
    }

    /* 
     * This method will create a dialog box that allows the user to select from
     * a dropdown list. It also has a title, a message, and Ok/Cancel buttons, 
     * and will halt execution of your program until one of the buttons is
     * clicked. If the user clicks the Ok button then the text in the field will be 
     * returned; otherwise, this method will return null (which usually indicates 
     * that the user clicked Cancel).
     */
    public String doDropdownBox (String title, String message, String[] selections)  {
        actionCode = NO_ACTION;
        try  {
            // create the messagebox
            msgbox = new Dialog(parent, title, true);
            msgbox.setLayout(new BorderLayout());

            // create the label
            initMsglabel(message);
            msgbox.add("North", msglabel);

            // create the dropdown box
            initDropdown(selections);
            msgbox.add("Center", dropdown);

            // create the OK and Cancel buttons
            buttons = new Panel();
            buttons.setLayout(new FlowLayout());
            initOkButton();
            buttons.add(ok);
            initCancelButton();
            buttons.add(cancel);
            msgbox.add("South", buttons);

            // display everything (the system will wait until a button is pressed
            // before returning)
            displayMsgbox();
            msgbox.dispose();       // just in case the ActionListeners didn't fire...
        }  catch (Exception e)  {
        }

        if (actionCode == OK_ACTION)
            return dropdown.getSelectedItem();
        else
            return null;
    }

    /* 
     * This method will create a dialog box that allows the user to select from
     * a list of options (use the allowMultiSelect parameter to indicate whether
     * the user can select multiple items from the list [true] or just one [false]). 
     * It also has a title, a message, and Ok/Cancel buttons, and will halt 
     * execution of your program until one of the buttons is clicked. If the user 
     * clicks the Ok button then the text in the field will be returned; otherwise, 
     * this method will return null (which usually indicates that the user clicked 
     * Cancel or didn't select anything).
     */
    public String[] doMultilistBox (String title, String message, String[] selections, boolean allowMultiSelect)  {
        actionCode = NO_ACTION;
        try  {
            // create the messagebox
            msgbox = new Dialog(parent, title, true);
            msgbox.setLayout(new BorderLayout());

            // create the label
            initMsglabel(message);
            msgbox.add("North", msglabel);

            // create the multilist field
            initMultilist(4, allowMultiSelect, selections);
            msgbox.add("Center", multilist);

            // create the OK and Cancel buttons
            buttons = new Panel();
            buttons.setLayout(new FlowLayout());
            initOkButton();
            buttons.add(ok);
            initCancelButton();
            buttons.add(cancel);
            msgbox.add("South", buttons);

            // display everything (the system will wait until a button is pressed
            // before returning)
            displayMsgbox();
            msgbox.dispose();       // just in case the ActionListeners didn't fire...
        }  catch (Exception e)  {
        }

        if ((actionCode == OK_ACTION) && 
            (java.lang.reflect.Array.getLength(multilist.getSelectedItems()) > 0))
            return multilist.getSelectedItems();
        else
            return null;
    }

    /*
     * The private methods below are simply reusable modular functions for
     * creating various elements that may appear in a MessageBox dialog.
     * They make it easier to write new public methods that create different
     * kinds of dialogs, and also allow you to make global changes to all your
     * dialog components pretty easily.
     */
     private void initMsglabel (String message)  {
        // the actual message in the MessageBox (using the custom
        // MultiLineLabel class, included below)
        msglabel = new MultiLineLabel(message);
     }

    private void initOkButton ()  {
        // the OK button
        ok = new Button("OK");
        ok.addActionListener( new ActionListener()  {
            public void actionPerformed(ActionEvent e)  {
                actionCode = OK_ACTION;
                msgbox.dispose();
            }
        } );
    }

    private void initCancelButton ()  {
        // the Cancel button
        cancel = new Button("Cancel");
        cancel.addActionListener( new ActionListener()  {
            public void actionPerformed(ActionEvent e)  {
                actionCode = CANCEL_ACTION;
                msgbox.dispose();
            }
        } );
    }

    private void initTextbox (String defaultText)  {
        // the field that allows a user to enter text in an InputBox
        textbox = new TextField(defaultText, 40);
        // the ActionListener here will get called if the user presses "Enter"
        textbox.addActionListener( new ActionListener()  {
            public void actionPerformed(ActionEvent e)  {
                actionCode = OK_ACTION;
                msgbox.dispose();
            }
        } );
    }

    private void initDropdown (String[] selections)  {
        // a dropdown box that allows a user to select from a list of
        // multiple items
        dropdown = new Choice();
        for (int i = 0; i < java.lang.reflect.Array.getLength(selections); i++)
            dropdown.add(selections[i]);
    }

    private void initMultilist (int numOfLines, boolean allowMultiSelect, String[] selections)  {
        // a multiple selection box that allows a user to select one or 
        // more items. numOfLines indicates how many lines should be
        // visible at a time, allowMultiSelect is a boolean value indicating 
        // whether or not the user should be allowed to select more than
        // one item from the list, and selections is an array of Strings that 
        // is used to populate the selection box
        multilist = new List(numOfLines, allowMultiSelect);
        for (int i = 0; i < java.lang.reflect.Array.getLength(selections); i++)
            multilist.add(selections[i]);
    }

    private void displayMsgbox ()  {
        // once all of the components have been added to a dialog,
        // use this method to display it
        Dimension d = msgbox.getToolkit().getScreenSize();
        msgbox.setLocation(d.width/3, d.height/3);      // center the dialog (sort of)
        msgbox.pack();                      // organize all its components
        msgbox.setResizable(false);     // make sure the user can't resize it
        msgbox.toFront();                   // give it focus
        msgbox.setVisible(true);                // and display it
    }

    /*
     * Okay, this is a pain, but java.awt doesn't natively have a Label-type class
     * that allows you to display text that's more than one line. So I had to write one
     * myself. The class below is a modification of some code from the fantastic
     * book, "Java in a Nutshell".
     *
     * The big change I made was to allow this multi-line label to have a fixed width,
     * so the Label wouldn't fly off the screen if you had a big paragraph of text to
     * display. The width is specified in "columns", which I defined as the width of
     * the letter "X" in whatever font is being used. The text that you add to the label
     * is automatically split into chunks that are no longer than the number of columns
     * specified (you'll see the code to do this in the parseLabel method).
     *
     * This sample implementation is an inner class of the MessageBox class, although
     * it could also be a separate class all by itself. I made it an inner class to make it
     * easier to copy and paste everything from one agent to another.
     *
     * Julian Robichaux -- http://www.nsftools.com
     */
    class MultiLineLabel extends Canvas  {
        // a custom class that will display a text label at a fixed width across
        // multiple lines
        // (modification of MultiLineLabel class from "Java in a Nutshell")
        String label;
        String[] lines;
        int rows = 1;
        int cols = 40;
        int margin = 6;
        int rowHeight;
        int lineAscent;
        int maxWidth;

        public MultiLineLabel (String text)  {
            // create a label with the default width
            label = text;
        }

        public MultiLineLabel (String text, int columns)  {
            // create a label with the specified number of "columns" (where a column
            // is the width of "X" in the font that we're using)
            if (columns > 0)
                cols = columns;
            label = text;
        }

        protected void measure ()  {
            // get the global values we use in relation to our current font
            FontMetrics fm = this.getFontMetrics(this.getFont());
            if (fm == null)
                return;

            rowHeight = fm.getHeight();
            lineAscent = fm.getAscent();
            maxWidth = fm.stringWidth("X") * cols;
        }

        private int stringWidth (String text)  {
            // calculate the width of a String using our current font
            FontMetrics fm = this.getFontMetrics(this.getFont());
            if (fm == null)
                return 0;
            return fm.stringWidth(text);
        }

        public Font getFont ()  {
            // return the font that we're currently using
            return super.getFont();
        }

        public void setFont (Font f)  {
            // change the font that we're currently using, and redraw the
            // label with the new font
            super.setFont(f);
            repaint();
        }

        public void addNotify ()  {
            // automatically invoked after our label/Canvas is created but 
            // before it's displayed (FontMetrics aren't available until
            // super.addNotify() has been called)
            super.addNotify();
            measure();
        }

        public Dimension getPreferredSize ()  {
            // called by the LayoutManager to find out how big we want to be
            if (lines == null)
                setText(label);
            return new Dimension(maxWidth + (2 * margin), (rows * rowHeight) + (2 * margin));
        }

        public Dimension getMinimumSize ()  {
            // called by the LayoutManager to find out what our bare minimum
            // size requirements are
            if (lines == null)
                setText(label);
            return new Dimension(maxWidth, (rows * rowHeight));
        }

        public void setText (String text)  {
            // change the text we're using for this label
            label = text;
            parseLabel();
        }

        private void parseLabel ()  {
            // parses the text we want to display in the label, so that the lines[]
            // variable contains lines of text that are no wider than maxWidth
            String token, word;
            StringBuffer msg = new StringBuffer("");
            StringBuffer line = new StringBuffer("");

            // do an initial measurement, to make sure we have maxWidth
            measure();
            rows = 0;

            // we'll be tokenizing the label String twice, first at every end-of-line
            // character ('\n') and then at every space (if the lines are too long), 
            // in order to generate an StringBuffer of proper length lines, all 
            // separated by \n
            java.util.StringTokenizer st1 = new java.util.StringTokenizer(label, "\n", false);
            while (st1.hasMoreTokens())  {
                token = st1.nextToken();
                if (stringWidth(token) <= maxWidth)  {
                    // if the whole line is shorter than the maxWidth allowed, we can
                    // just add this line to the buffer and get the next one
                    rows++;
                    msg.append(token + "\n");
                }  else  {
                    // if the line was too long, we'll have to break it up manually by
                    // tokenizing the line at every space and adding words together
                    // one by one until we have a line that's greater than maxWidth;
                    // then we can add that shorter line to the buffer and keep doing
                    // that until we're out of words
                    java.util.StringTokenizer st2 = new java.util.StringTokenizer(token, " ", false);
                    while (st2.hasMoreTokens())  {
                        word = st2.nextToken();
                        if ((stringWidth(line.toString()) + stringWidth(word)) > maxWidth)  {
                            rows++;
                            msg.append(line.toString() + "\n");
                            line.setLength(0);
                            line.append(word + " ");
                        }  else  {
                            line.append(word + " ");
                        }
                    }
                    // after we've run out of words, add any remaining text to the buffer, too
                    if (line.length() > 0)  {
                            rows++;
                            msg.append(line.toString() + "\n");
                    }
                }
            }

            // once we're done, split the buffer into the lines[] array
            java.util.StringTokenizer st = new java.util.StringTokenizer(msg.toString(), "\n");
            lines = new String[rows];
            for (int i = 0; i < rows; i++)
                lines[i] = st.nextToken();

        }

        public void paint (Graphics g)  {
            // draw the actual label to the screen, with space around the edges
            // based on the margins we've specified (for some reason, we have to
            // call setLabel instead of just parseText here in order to get the size
            // right, which is a little redundant, but whatever works...)
            int y;
            setText(label);
            Dimension d = this.getSize();
            y = lineAscent + (d.height - (rows * rowHeight)) / 2;
            for (int i = 0; i < rows; i++, y += rowHeight)
                g.drawString(lines[i], margin, y);
        }

    }
}// end of the MultiLineLabel class

Hi Rajesh, I want to start a thread to process my email (like uploading attachments somewhere and then adding links to the body) after agent has got the document from notes send event. This is because the send event waits for agent to exit (UI hangs because my process could take long) and any threads I start are also terminated (which is natural as the main program exits). Please suggest any alternative approach. I am thinking to bring RMI inside, so java agent would hand it over to an other java program that listens as RMI server. Would that be fine? Thanks & regards, Nadeem Ullah

well seems that the problem is getting complicated..try for the RMI though its not a good solution as it will further complicate the process..and if not handled properly then u may get error which will be hard to detect and fix..performance may still be any issue with RMI..

I have found a workaround for this. I am able to remove attachments using vb script inside the Querysend event of Message form. It works fine. Now there is one question about the template. If user replaces the application design using my template, and later on, suppose, he replaces the design with someone else's template, will my changes be overwritten? Will my template still be working? I am assuming that if the latter template inherits the changes, it should work fine. Thanks & regards

If someone else needs to do the same, I am using Source.Document.RemoveItem("$File") to remove the attachments.

Hi Rajesh, I am using an external jar file that requires its .properties file to be placed in the working directory. What is the working directory for a lotus notes java agent? I can see the Code, Forms folders in my project hierarchy but can't figure out where to place this file. I don't have access to the source of the jar so I cannot make changes to it. Regards,

Lotus notes plugin to intercept outgoing emails (JAVA) - Stack Overflo...

java plugins lotus-notes
Rectangle 27 0

It is Compatibility issue in the ireport. when you are going to open .jrxml in older version of ireport then the version you have created it before you wil get this error. To fix it just strip out the uuid attribute and open it again in the ireport.

jasper reports - compilation error: ireport with java;Attribute 'uuid'...

java jasper-reports
Rectangle 27 0

I know i am late but i am adding this for someone like me who stumbles upon this. Some times it may be due to simple mistakes like not including spring dependencies. I moved application to spring boot and forgot to include following two dependencies and i received this error. You should add version in the dependencies below if directly using in pom without dependencyManagement BOM of spring integration.

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-integration</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-file</artifactId>
        </dependency>

java - Attribute 'fixed-rate' is not allowed to appear in element 'int...

java xml spring
Rectangle 27 0

First, I'm surprised that you don't get an exception with your importNode() call, since you're importing the Document, which shouldn't be allowed (per the JavaDoc).

Now to the question that you asked: if you only want to attach specific node types, you need to make a test using the node's type. A switch statement is the easiest (note: this has not been compiled, may contain syntax errors):

switch (n.getNodeType())
{
    case ELEMENT_NODE :
        // append the node to the other tree
        break;
    default :
        // do nothing
}

No, importNode is returning the node, and if I add the parent noe i.e. <dhruba> instead of trying to add it's child nodes, it is adding fine and generating well formed output , but with <dhruba> parent element which I don't want. In addition, I need all type of nodes , TEXT_NODE or ELEMENT_NODE , so I didn't use the check, and surprisingly, it is returning null for either one of the node type according to given input.

@dhrubo: OK, in that case I have no clue what you're trying to do. I suggest that you edit your post to include a complete, compilable example. Then show input, actual output, and expected output. One thing that I can assure you, however: it is not a problem with the API.

Edited , please let me know if you need any further clarifications, and note the above code compiles. I am currently working with this code, I have just changed my variables.

And where do you define dom? When I say "compiles," I mean that I can copy your post into an editor window and actually compile it. As it stands, I can't do that. And seeing you do things like dom.getParentNode().appendChild(), where dom is almost certainly a Document, neither can you.

I am extremely SORRY, missed couple of line codes from a method. I think everything should be fine now for compilation.

java - Issue with XML child nodes iteration when mix of text and eleme...

java xml
Rectangle 27 0

If you're allowed to sort the arraylist, this becomes pretty simple.

public void removePairedElements(ArrayList<Integer> a){

    Collections.sort(a); //Sort a

    int i = 0;
    while(i < a.size() - 1){
      //Check if i and i+1 are the same element. If so, remove both
      if(a.get(i).equals(a.get(i+1))){
        //Remove i twice - effectively removes i and i+1
        a.remove(i);
        a.remove(i);

        //Move i *back* one index, which is equivalent to 
        //moving forward one because we just removed two elements.
        //Prevent i from becoming negative though.
        i = Math.max(0, (i - 1));
      }
      else{
        i++;
      }
    }
}

O(n log n) time and O(1) space. Probably the cleanest answer. If you aren't allowed to change the ordering of the arraylist you'd have to do something else, but otherwise this should work.

Hmmm, this concept seems to be like a good idea. It's not producing the correct output, but I think I may try to modify it and see if I can figure out whats wrong.

I got the bug, see edit - removing i+1 after removing i is effectively removing i+2, which isn't what we want.

Ah, of course, because everything gets shifted over. This works flawlessly (as far as I've tested it) and looks to be the simplest code to me. Thank you so much for the help, I greatly appreciate it!

Removing pairs of elements in an Arraylist in Java - Stack Overflow

java arraylist compare elements
Rectangle 27 0

First of all, I can only agree that Arrays.asList(T...) is clearly the best solution for Wrapper types or arrays with non-primtive datatypes. This method calls a constructor of a simple private static AbstractList implementation in the Arrays class which basically saves the given array reference as field and simulates a list by overriding the needed methods. If you can choose between a primtive type or a Wrapper type for your array, I would use the Wrapper type for such situations but of course, it's not always useful or required. There would be only two possibilities you can do: 1) You can create a class with a static method for each primitive datatype array (boolean, byte, short, int, long, char, float, double returning an Iterable<WrapperType>. These methods would use anonymous classes of Iterator (besides Iterable) which are allowed to contain the reference of the comprising method's argument (for example an int[]) as field in order to implement the methods.-> This approach is performant and saves you memory (except for the memory of the newly created methods, even though, using Arrays.asList() would take memory in the same way) 2) Since arrays don't have methods (as to be read on the side you linked) they can't provide an Iterator instance either. If you really are too lazy to write new classes, you must use an instance of an already existing class that implements Iterable because there is no other way around than instantiating Iterable or a subtype. The ONLY way to create an existing Collection derivative implementing Iterable is to use a loop (except you use anonymous classes as described above) or you instantiate an Iterable implementing class whose constructor allows a primtive type array (because Object[] doesn't allow arrays with primitive type elements) but as far as I know, the Java API doesn't feature a class like that.The reason for the loop can be explained easily:for each Collection you need Objects and primtive datatypes aren't objects. Objects are much bigger than primitive types so that they require additional data which must be generated for each element of the primitive type array. That means if two ways of three (using Arrays.asList(T...) or using an existing Collection) require an aggregate of objects, you need to create for each primitive value of your int[] array the wrapper object. The third way would use the array as is and use it in an anonymous class as I think it's preferable due to fast performance. There is also a third strategy using an Object as argument for the method where you want to use the array or Iterable and it would require type checks to figure out which type the argument has, however I wouldn't recommend it at all as you usually need to consider that the Object hasn't always the required type and that you need seperate code for certain cases. In conclusion, it's the fault of Java's problematic Generic Type system which doesn't allow to use primitive types as generic type which would save a lot of code by using simply Arrays.asList(T...). So you need to program for each primitive type array, you need, such a method (which basically makes no difference to the memory used by a C++ program which would create for each used type argument a seperate method.

Convert Java Array to Iterable - Stack Overflow

java arrays iterable
Rectangle 27 0

<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns="http://www.springframework.org/schema/security"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security-3.2.xsd 
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util    
http://www.springframework.org/schema/util/spring-util-4.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-4.0.xsd">

java - cvc-complex-type.3.2.2: Attribute 'username-parameter' is not a...

java spring spring-security
Rectangle 27 0

Using two imported elements with the same name will cause this error because JAXB will try to generate two attributes with the same name in a Java class, which isn't allowed.

jaxb2 - JAXB maven plugin Two declarations cause a collision in the Ob...

jaxb jaxb2 maven-jaxb2-plugin
Rectangle 27 0

Another solution would be to use List instead of Set (if you are allowed to do so). List has a method called get(int index) that retrieves the element at the specified index and you can compare them one by one when both your lists have the same size. More on lists: http://docs.oracle.com/javase/7/docs/api/java/util/List.html

Also, avoid using public variables in your classes. A good practice is to make your variables private and use getter and setter methods.

List<ValueObject> list = new ArrayList<>();
    List<DTO> list2 = new ArrayList<>();

    list.add(ValueObject.of(1));
    list.add(ValueObject.of(2));
    list.add(ValueObject.of(3));

    list2.add(DTO.of(1));
    list2.add(DTO.of(2));
    list2.add(DTO.of(34));
public boolean compareLists(List<ValueObject> list, List<DTO> list2) {
    if(list.size() != list2.size()) {
        return false;
    }
    for(int i = 0; i < list.size(); i++) {
        if(list.get(i).id == list2.get(i).id) {
            continue;
        } else {
            return false;
        }
    }
    return true;
}

What would be the difference if I iterate through a set elements one by one, what I actually do.

Lists maintain order of insertion. And from what I gather, you want your result to be true only if each collection has the exact same elements in the exact same positions. If I misinterpreted your question, please let me know.

no, same positions is not a requirement here. Actually I use Set interface which does not require preserving positions

Oh, ok. Then disregard the solution. If I come up with something for sets, I'll post a comment.

java - Compare two sets of differrent types - Stack Overflow

java guava apache-commons
Rectangle 27 0

As other answers have pointed out, the problem you have here is that you are trying to remove from a list while you iterate over it. This isn't allowed in java, except if you remove the element using the iterator's remove method. This means you have two ways about fixing this code.

for(Iterator<Exercise> iterator = z.iterator(); iterator.hasNext();)
{
    Exercise c = iterator.next();
    if(!compareSkillLevel(c,a)|| !compareEquipment(c)|| !compareFocus(c)
            || !compareTraining(c))
        iterator.remove();
}

or, you can loop over the array list using its index, and instead do something like

for(int i = 0;i < z.size(); i++)
{
    Exercise c = z.get(i);
    if(!compareSkillLevel(c,a)|| !compareEquipment(c)|| !compareFocus(c)
            || !compareTraining(c))
        z.remove(i--)
}

Note the i-- here, which is necessary because the act of removing an element from the ArrayList shifts the existing elements over, meaning the next element you want to examine is in the place of the last element.

java - Concurrent Modification Error for Object ArrayList - Stack Over...

java concurrentmodification