Cannot cast boolean to BigDicemal??

i am new in reporting
i am using iReport 3.0...
i want to show my line in report if a field value is greater than 5000
my field type is BigDecimal
i wrote formula as
(($F{AvgAmount}.intValue() >= 5000 )? true : false )
when i check expression result is Expression successfully validated.
when i Run report error accour
Errors compiling .\BranchWiseAverage.jasper.
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Cannot cast from boolean to BigDecimal                 value = (java.math.BigDecimal)(((((java.math.BigDecimal)field_AvgAmount.getValue()).intValue() >= 5000 )? true : false ));//$JR_EXPR_ID=14$                         <---------------------------------------------------------------------------------------------------------------> 2. Cannot cast from boolean to BigDecimal                 value = (java.math.BigDecimal)(((((java.math.BigDecimal)field_AvgAmount.getOldValue()).intValue() >= 5000 )? true : false ));//$JR_EXPR_ID=14$                         <------------------------------------------------------------------------------------------------------------------> 3. Cannot cast from boolean to BigDecimal                 value = (java.math.BigDecimal)(((((java.math.BigDecimal)field_AvgAmount.getValue()).intValue() >= 5000 )? true : false ));//$JR_EXPR_ID=14$                         <---------------------------------------------------------------------------------------------------------------> 3 errors      at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:193)     at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:591)     at java.lang.Thread.run(Unknown Source)
Compilation running time: 328
how can i remove this error.
thanks

Hi Les,
where there is a will, there is a script:
Get-ADUser -Filter * -SearchBase "OU=Departments,dc=contoso,dc=com" -Properties * | select Name, @{ n = "Enabled"; e = { [int]$_.Enabled } }, Canon* | export-csv departments.csv
Cheers,
Fred
There's no place like 127.0.0.1

Similar Messages

  • Exception:[java.lang.IllegalArgumentException: Cannot cast 02 to boolean]

    Hi Friends,
    I am facing a issue in mapping. My scenario is IDOC to JDBC.
    I have done mapping in the give below way.
    If segment1 and segment2 both exists and attyp(field of segment1) is equal to '00' or '01' then segment1 replicate into table.
    I am facing a error while testing the mapping is:
    RuntimeException in Message-Mapping transformation: Exception:[java.lang.IllegalArgumentException: Cannot cast 02 to boolean] in class com.sap.aii.mappingtool.flib3.Bool method or[02, 01, com.sap.aii.mappingtool.tf3.rt.Context@459926e5]
    Kindly suggest me on this.
    Regards,
    Narendra Goyal

    My Mapping in such a way:
                              01      attyp
                                \          \               segment1
                                or   -  equals           \
                                 /          \                then
                               02         and   -    if              ->       Table
    segment1 - exists   \      /                 else
                                  and                      /
    segmen2 - exists   /             some more condition

  • RUNTIME EXCEPTION-Cannot cast null to boolean'.

    Hi Friends,
    I have the below mapping.The if condition is satisfied,even though 'then' value is going to the target field.
    When i try to check the queue of the 'IF' function it is throwing error RUNTIME EXCEPTION-Cannot cast null to boolean
                   >splitbyvalue(eachvalue)----> then
                  ->splitbyvalue(eachvalue)>if---->target field
                                     ->mapwithdefault->else
    Please help !!!
    Regards,
    Suresh.

    Hi,
    Thanks for the input!!
    In the below mapping suppose both 'equals' are satisfied then constant value '123' will go to target field otherwise 'else' value will go.
    constant(123)----
                              >concat>splitbyvalue(eachvalue)----
    > then
    E1K1456(source segment)-->\
    equals/
             >and--
    ---equals-\
                                                             concat>splitbyvalue(eachvalue)>if------>target field
    E1K1456(source segment)----
    >\
                                                              source field ->mapwithdefault->else
    Regards,
    Suresh.

  • Cannot cast from SOMETHING to SOMETHING (Error in 1.4) (Works in 1.6)

    Our company have developed an accounting program, and it is already near completion.
    We developed it with JavaBean and Eclipse in Windows Environment with JRE 1.6.0_05
    When we tried to compile and run the program in our linux environment (Server) that runs on 1.4 , the casting error occured..
    we have written a program to generate all casting errors that occurred in our project.
    import java.math.*;
    import java.util.*;
    public class testnow {
         public static void main(String[] args){
              //Declare ALL Primitive!
              int TestINT = 150;
              Boolean TestBOOL = true;
              String TestSTR = "Streng" + "th";
              BigDecimal TestDCM = BigDecimal.valueOf(20);
              Date TestDATE = new Date();
              //Declare ALL Object
              Object TestINTObj = 150;
              Object TestSTRObj = "Strength";
              Object TestDCMObj = BigDecimal.valueOf(20);
              Object TestBOOLObj = true;
              Object TestDATEObj = new Date();
              if(TestINT == (Integer)TestINTObj){
                   System.out.println("TEST Integer PASSED");
              if(TestSTR.equals((String)TestSTRObj)){
                   System.out.println("TEST String PASSED");
              if(TestDCM.equals(TestDCMObj)){
                   System.out.println("TEST Decimal PASSED");
              if(TestBOOL == (Boolean)TestBOOLObj){
                   System.out.println("TEST Boolean PASSED");
              if(TestDATE.equals((Date)TestDATEObj)){
                   System.out.println("TEST Date PASSED");
    }the following is what happened when i run javac testnow.java
    1. ERROR in testnow.java
    (at line 6)
    Integer TestINT = 150;
    ^^^^^^^
    Type mismatch: cannot convert from int to Integer
    2. ERROR in testnow.java
    (at line 7)
    Boolean TestBOOL = (Boolean)true;
    ^^^^^^^^^^^^^
    Cannot cast from boolean to Boolean
    3. ERROR in testnow.java
    (at line 11)
    Object TestINTObj = (Object)150;
    ^^^^^^^^^^^
    Cannot cast from int to Object
    4. ERROR in testnow.java
    (at line 14)
    Object TestBOOLObj = true;
    ^^^^^^^^^^^
    Type mismatch: cannot convert from boolean to Object
    4 problems (4 errors)
    in our windows development JRE 1.6 , it run well and gives the following output :
    TEST Integer PASSED
    TEST String PASSED
    TEST Decimal PASSED
    TEST Boolean PASSED
    TEST Date PASSED
    how do we solve this? i mean we have been using this "convenience" casting all over our code . :(
    please help
    thanks a lot.
    Cheers and God Bless,
    Chowi

    You've got a lot of problems there, and not all of them are due to Java version incompatibilites. I'll take them in the order I see them. public static Object FindDataInTable(ArrayList TargetTable, String TypeColumn,
             String TargetColumn, Object TargetData, String ReturnedColumn)&#x7B; The convention is to give methods and variables names that start with lowercase letters. That makes your code easier to read, which makes it easier for us to help you. Later on, I see you also use a mix of underscores and camelcase. Underscores should be used only in constant names; class, method and variable names should use only camelcase.
    Also, if you don't have a good reason to make that first argument an ArrayList, you should declare it as a List instead. That leaves the calling code the option of using a different List implementation should they need to.
    Next, you assign a primitive value to an Object reference: Object ReturnedObject = 0; That requires autoboxing, as others have pointed out, which didn't exist in JDK 1.4. Even if you could use autoboxing though, that assignment would be a bad idea; a variable of type Object should be assigned a default value of {color:000080}null{color}, not a number. However, you may not need to declare that variable at all, as I explain later.
    Next you use a "foreach" loop, another feature that was added in JDK 1.5; you'll have to switch to the old-style loop if you want this code to work under JDK 1.4. While you're at it, you should declare your "SingleRow" variable inside the loop, since it's not used anywhere else: for (Iterator it = TargetTable.iterator(); it.hasNext(); ) {
        Model_DatabaseQuery SingleRow = (Model_DatabaseQuery)it.next(); Next I see you using matches() to compare String values: if(TypeColumn.matches("String")){
        if(((String)TargetData).matches((String)CheckData))&#x7B; You get away with that because the strings contain only letters, but you need to look up the docs for matches() so you'll understand why you shoudn't be using it here. But this is nothing compared to the next issue: if((Integer)TargetData == (Integer)CheckData)&#x7B; // WRONG WRONG WRONG That can't possibly have worked right, no matter what version of Java you ran it under. You NEVER use == to compare the values objects! You should have been using equals() for all those comparisions, not matches(), and definitely not ==.
    But I don't see why you're doing all those checks on the column type anyway. All you ever do after that is compare the same two values, so just do it: for (Iterator it = targetTable.iterator(); it.hasNext(); ) {
        Model_DatabaseQuery SingleRow = (Model_DatabaseQuery)it.next();
        Object CheckData = SingleRow.Get_object(TargetColumn);
        if (CheckData != null && CheckData.equals(TargetData)) {
            return SingleRow.Get_object(ReturnedColumn);
    } If there are other columns that you're supposed to ignore, you may still need to check the column type, but you could do that in one {color:000080}if{color} statement; you don't have to check them all separately.

  • Mapping Error: Cannot cast to float

    Hello Everyone,
    Has anyone seen this error in Message Mapping in XI?  What did you do to resolve it?
    13:59:10 Start of test
    Compilation of JobPositionPublication2PositionOpening_M successful Runtime exception during processing target field mapping /ns1:PositionOpening/ns1:PositionProfile/ns1:PositionDetail. The message is: Exception:[java.lang.IllegalArgumentException: Cannot cast to float. ] in class com.sap.aii.mappingtool.flib3.Arithm method greater[, 0, com.sap.aii.mappingtool.tf3.rt.Context@8e6076] com.sap.aii.mappingtool.tf3.MessageMappingException: Runtime exception during processing target field mapping /ns1:PositionOpening/ns1:PositionProfile/ns1:PositionDetail. The message is: Exception:[java.lang.IllegalArgumentException: Cannot cast to float. ] in class com.sap.aii.mappingtool.flib3.Arithm method greater[, 0, com.sap.aii.mappingtool.tf3.rt.Context@8e6076] at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:284) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:352) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:60) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.execute(MapServiceRemoteObjectImpl0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:309) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:194) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:122) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: com.sap.aii.utilxi.misc.api.BaseRuntimeException: Exception:[java.lang.IllegalArgumentException: Cannot cast to float. ] in class com.sap.aii.mappingtool.flib3.Arithm method greater[, 0, com.sap.aii.mappingtool.tf3.rt.Context@8e6076] at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:56) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:41) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:41) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:41) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:220) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:352) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:60) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.execute(MapServiceRemoteObjectImpl0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:309) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:194) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:122) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Root Cause: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor248.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:47) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:41) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:41) at com.sap.aii.mappingtool.tf3.rt.FunctionWrapper.getValue(FunctionWrapper.java:41) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:220) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238) at com.sap.aii.mappingtool.tf3.AMappingProgram.processNode(AMappingProgram.java:238) at com.sap.aii.mappingtool.tf3.AMappingProgram.start(AMappingProgram.java:352) at com.sap.aii.mappingtool.tf3.Transformer.start(Transformer.java:60) at com.sap.aii.mappingtool.tf3.AMappingProgram.execute(AMappingProgram.java:105) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInternal(ServerMapService.java:431) at com.sap.aii.ibrep.server.mapping.ServerMapService.execute(ServerMapService.java:169) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.execute(MapServiceBean.java:52) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.execute(MapServiceRemoteObjectImpl0.java:301) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:146) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:309) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:194) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:122) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.lang.IllegalArgumentException: Cannot cast to float. at com.sap.aii.mappingtool.flib3.Arithm.toFloat(Arithm.java:19) at com.sap.aii.mappingtool.flib3.Arithm.greater(Arithm.java:72) ... 27 more RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns1:PositionOpening/ns1:PositionProfile/ns1:PositionDetail. The message is: Exception:[java.lang.IllegalArgumentException: Cannot cast to float. ] in class com.sap.aii.mappingtool.flib3.Arithm method greater[, 0, com.sap.aii.mappingtool.tf3.rt.Context@8e6076]
    13:59:12 End of test

    If you are using a UDF, then the input and the output from the UDF is in the form of a string.If a float value is passed to the UDF,and if there are some arithmetic operations done on that float value then you need to convert the string to float - something like the below.
    String s = "100.00";
          try {
             float f = Float.valueOf(s.trim()).floatValue();
             System.out.println("float f = " + f);
          } catch (NumberFormatException nfe) {
             System.out.println("NumberFormatException: " + nfe.getMessage());
    Then before returning the value to the target field,convert the value back to string  like this -
    Float.toString(float f)
    In case you are using some other standard functions,do let us know of that as well so that we can suggest resolutions to this error.
    thanks\
    Priyanka

  • Using BC4J, Cannot Cast an Oracle Number to a java int

    Hi,
    I am using bc4j in jdev 9i, version 9.0.2.822. I have a type Row, to get the data from oracle, bc4j, and all work fine, except that I cannot
    cast or convert the number returned to an int where I can use it for other java functions.
    Is there any way to convert the number, using a wrapper or a function to do so?
    Any help is greatly appreciated.

    Use Number.intValue() method.

  • Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast '' to

    Hi Experts,
    i need to map sourse type as decimal with target type also decimal. in the mapping logic i need perform arthemetic logic like exchange rate=exchangerate*sourceunit/targetunit
    i mapped as per the logic but i tested in display queue i am getting this below error
    Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast '' to decimal number] in class com.sap.aii.mappingtool.flib7.Arithm method mul[, , com.sap.aii.mappingtool.tf7.rt.Context@13133cec] See error logs for details
    is this required to  use UDF to perform my logic. if it required please suggest me the UDF.
    thanks,
    pavan
    Edited by: Pavan Kumar Thiruveedula on Dec 19, 2011 7:12 AM

    Enter the value in test tab for the field and then check Display queue.
    i Guess you are testing with blank value

  • Cannot cast beans.dataView.Presentation to beans.graph.ThinGraph

    Hi,
    I get following error when try to cast Presentation to ThinGraph.
    Cannot cast oracle.dss.thin.beans.dataView.Presentation to oracle.dss.thin.beans.graph.ThinGraph
    These are the codes which I get errors on them:
    <% (ThinCrosstab)simpleCrosstab).getModel().setDataSource(((ThinGraph)simpleGraph).getModel().getDataSource()); %>
    <% ((ThinGraph)simpleGraph).setImagemapAction( ThinGraph.Y1TITLE, ThinGraph.SERIES_UNDEFINED, ThinGraph.GROUP_UNDEFINED, action);
    %>
    I don't know how to cast these to types.
    Please help me,
    Sincerely,
    Mozhdeh

    I'm getting the same error with BI beans version: 10.1.2.67.0
    I see that most of the sample code cast's presentation to ThinCrossTab...
    so not sure if I'm missing something here.
    Anyone knows how to resolve?
    Thanks.

  • Cannot cast java.io.serialiazable to int Error

    Dear Members,
    I have procedure in AM which is as follows:
    public int countRecs(String headerID)
    int count=0;
    count= integer value assigned from SQL Query*
    return count;
    I am calling this procedure from the CO of the page as follows:
    String headerID="123"
    int     count=0;
    *Serialiazable para[]={headerID};*
    count=(int)am.invokeMethod("countRecs",headerID);
    When I am compiling my CO I am getting the below error:
    Cannot cast java.io.serialiazable to int
    Kindly please help me in resolving this error.
    Many thanks in advance.
    Best Regards,
    Arun Reddy D.

    the signature of the method you are invoking is
    public Serializable invokeMethod(String methodName,
    Serializable[] methodParams)
    so the return type is also serializable. so you should change your method signature accordingly
    public int countRecs(String headerID)
    int count=0;
    count= integer value assigned from SQL Query*
    return count;
    public String countRecs(String headerID)
    //just change last statement
    return ""+count;}
    your CO call should be
    count=(int)am.invokeMethod("countRecs",headerID);count = Integer.parseInt(am.invokeMethod("countRecs",para));
    so finally your count variable will hold an integer
    you may need to keep the above statement in try catch block
    Regards
    Ravi

  • Cannot cast trouble.

    L.S.
    In my MySQL database I've got a column companyId with datatype INT(8).
    In my application I built a login use case after the Login1 - Login 4 examples in the FieldGuide. In my LoginBean code I declarated a property private int companyId.
    In the isLoginGood I would like to set the property's value using the following code:
    companyId = Integer.parseInt((String)authorisationDataProvider.
    getValue("authorisation.companyId "));
    When I run my application I get the following error:
    database: java.lang.Long cannot be cast to java.lang.String
    I haven't got a clue how to solve this problem, getValue return an Object, the datatype in my MySQL table INT(8), where does this long come from and how to I get it right?
    Thanks,
    Annet.

    getValue returns an object whose type is based on the underlying database type. In your case, INT(8) maps to a Long. Try usingcompanyId = (Long)authorisationDataProvider.getValue("authorisation.companyId ");

  • Cannot use BOOLEAN in Oracle

    Why we can't use BOOLEAN in SQL statement but we can use it in PL/SQL statement. But what does that mean? Thanks.

    grus wrote:
    Why we can't use BOOLEAN in SQL statement but we can use it in PL/SQL statement. But what does that mean? Thanks.As already explained, SQL and PL (Programming Logic) are different computer languages and have different data types. Though PL typically supports most SQL data types too.
    Oracle however allows you to define your own SQL data types - and create these in a similar way as you would define an object orientated class. These data types have constructors, properties and methods, static class methods - and supports abstract definitions and inheritance. All the basics of an o-o class definition is supported.
    This allows you to, for example, create your own boolean data type that you can use in both SQL and PL. Not that this is specifically a good idea for boolean values (as a single character column with a Y/N constraint can do the job equally well to). But even so, to define your own data types is a very powerful feature that can be used to deal with non-common data types in specialised database implementations.
    An example of how to create a SQL boolean type was posted some time ago in [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=2116991#2116991].

  • Cannot Cast List ? extends Object as List Object

    I apologize if this is a common question but I could not seem to find the proper set of search terms that yielded an answer.
    Basically I have an RMI application and on the 'middle-tier' I would like to pass around references to the implementation objects and only convert to the interface type when dealing with them over RMI (I never pass an object back to the middle-tier).
    public interface Questionnaire implements Remote {
        public List<? extends Comment> getComments() throws RemoteException;
    public class QuestionnaireImpl extends UnicastRemoteObject implements Questionnaire {
        public List<CommentImpl> getComments() {...}
    }This works fine, the issue arises when I try to do the following:
    public List<Comment> getComments(int questionnaireId) throws RemoteException {
        return classLoader.getQuestionnaire(questionnaireId).getComments();
    }The compiler issues a Type mismatch: cannot convert from List<capture#8-of ? extends Comment> to List<Comment> Which I find perplexing as the compiler can assure that at the very least it is a List of Comment objects.

    public List<? extends Comment> getComments() throws RemoteException;
    public List<Comment> getComments(int questionnaireId) throws RemoteException {
    return classLoader.getQuestionnaire(questionnaireId).getComments();
    The compiler issues a Type mismatch: cannot convert from List<capture#8-of ? extends Comment> to List<Comment> Which I find perplexing as the compiler can assure that at the very least it is a List of Comment objects.Yes, however Java's generics work correctly to prevent you from shooting yourself in the foot. If you have a List<Superclass> pointing at a List<Subclass>, you would be entirely within your rights to try to store an object that is not castable to Subclass in it, this breaks type safety, so the compiler will not let you do it.
    Instead, create a new List<Supertype> and copy over the elements from the list returned by getComments(). There is a constructor that will do this for you.

  • Cast boolean to int

    Hi,
    I am frequently using PS to prepare various reports.
    For example, I am frequently running reports of enabled/disabled users in Departments in our AD.
    Example
    Get-ADUser -Filter * -SearchBase "OU=Departments,dc=contoso,dc=com" -Properties * | select Name,Enabled,Canon* | export-csv departments.csv
    The problem is that "Enabled" column shows True/False and I would like it to show 1/0 . When I show that data in Excel I could then sum "Enabled" column.
    Is there any way to do it elegantly?
    Thanks in advance,
    Les

    Hi Les,
    where there is a will, there is a script:
    Get-ADUser -Filter * -SearchBase "OU=Departments,dc=contoso,dc=com" -Properties * | select Name, @{ n = "Enabled"; e = { [int]$_.Enabled } }, Canon* | export-csv departments.csv
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • JPA with EclipseLink, error Entity cannot be cast to Entity, any help?

    Hello, I'm currently deploying a JPA project with EclipseLink on a MySQL db, it's been working fine, however, I'm receiving a problem of this type:
    java.lang.ClassCastException: beans.Empleado cannot be cast to beans.Empleado
    Where Empleado is my Entity, basically the problem happens here, where I store a result from a SQL select into a List and then assign the results into variables, it was working with no problems before, but now, everytime I run the code, the error shows up, and the only way to make it work at least 2 - 3 times, is restarting the Glassfish Server, here's the code:
    Query q = em.createNamedQuery("Empleado.findByIdEmpleado");
    q.setParameter("idEmpleado", 2);
    List<Empleado> listaEmpleado = q.getResultList();
    for(Empleado empleado1 : listaEmpleado){
    testString = empleado1.getTecnologia();
    But as I said, it was working fine before, so I don't think is actually a code problem, I guess the "cast" reference is happening here:
    for(Empleado empleado1 : listaEmpleado)
    The errors shows up with every function where I make this kind of casting......
    As a comment, I have a similar project at home, and I don't have these problems, this is happening on a project at work, but both project are the same, it's just I'm doing this one at work and the other at home, which is working fine, thanks in advanced, have a nice day, I just hope I was clear about this!
    Edited by: user3538005 on 08-11-2011 09:08 AM

    Hola,
    It's quite strange stuff :) Mainly the exception, beans.Empleado cannot be cast to beans.Empleado.
    I think it's because of some configuration problem, related to classloader:
    EclipseLink has it's own classloader, if your beans.Empleado is loaded by EclipseLink's classloader, and by a different one (default classloader), you will have two beans.Empleado classes in your JVM, and these classes are different, so you cannot cast them :O
    so your eclipselink's classloader has its beans.Empleado(1) class, and after executing your query you have a list with the results each of them in beans.Empleado(1).
    and your dao class, or whatever, tries to cast the beans.Empleado(1) to the default classloader's beans.Empleado(2).
    what did you change in the config when it started not to work?

  • How do I cast a String to an int ?  HELP !

    Dear Java People,
    If I have a program that outputs a String of the time ie
    09:25
    How do I code in Java to check this String to see if it is greater than 12 o'clock and if so tack on a String of "PM'.....
    I tried
    if ((int) hours.getDisplayValue()> 12 )
    to attempt to add "PM" at the end of the String
    The error message says:
    "ClockDisplay.java": Error cannot cast java.lang.String to int at line 88, column 12
    below is the program
    Thank you in advance
    Stan
    * The ClockDisplay class implements a digital clock display for a
    * European-style 24 hour clock. The clock shows hours and minutes. The
    * range of the clock is 00:00 (midnight) to 23:59 (one minute before
    * midnight).
    * The clock display receives "ticks" (via the timeTick method) every minute
    * and reacts by incrementing the display. This is done in the usual clock
    * fashion: the hour increments when the minutes roll over to zero.
    * @author Michael Kolling and David J. Barnes
    * @version 2001.05.26
    public class ClockDisplay
    private NumberDisplay hours;
    private NumberDisplay minutes;
    private String displayString; // simulates the actual display
    * Constructor for ClockDisplay objects. This constructor
    * creates a new clock set at 00:00.
    public ClockDisplay()
    hours = new NumberDisplay(24);
    minutes = new NumberDisplay(60);
    updateDisplay();
    * Constructor for ClockDisplay objects. This constructor
    * creates a new clock set at the time specified by the
    * parameters.
    public ClockDisplay(int hour, int minute)
    hours = new NumberDisplay(24);
    minutes = new NumberDisplay(60);
    setTime(hour, minute);
    * This method should get called once every minute - it makes
    * the clock display go one minute forward.
    public void timeTick()
    minutes.increment();
    if(minutes.getValue() == 0) { // it just rolled over!
    hours.increment();
    updateDisplay();
    * Set the time of the display to the specified hour and
    * minute.
    public void setTime(int hour, int minute)
    //Exercise 3.19 This condition will insure that it will be a 12 hour clock
    if(hour > 12)
    hour = hour - 12;
    hours.setValue(hour);
    minutes.setValue(minute);
    updateDisplay();
    * Return the current time of this display in the format HH:MM.
    public String getTime()
    return displayString;
    * Update the internal string that represents the display.
    private void updateDisplay()
    if ((int) hours.getDisplayValue() > 12 )
    displayString = hours.getDisplayValue() + ":" +
    minutes.getDisplayValue() ;
    * The NumberDisplay class represents a digital number display that can hold
    * values from zero to a given limit. The limit can be specified when creating
    * the display. The values range from zero (inclusive) to limit-1. If used,
    * for example, for the seconds on a digital clock, the limit would be 60,
    * resulting in display values from 0 to 59. When incremented, the display
    * automatically rolls over to zero when reaching the limit.
    * @author Michael Kolling and David J. Barnes
    * @version 2001.05.26
    public class NumberDisplay
    private int limit;
    private int value;
    * Constructor for objects of class Display
    public NumberDisplay(int rollOverLimit)
    limit = rollOverLimit;
    value = 0;
    * Return the current value.
    public int getValue()
    return value;
    * Return the display value (that is, the current value as a two-digit
    * String. If the value is less than ten, it will be padded with a leading
    * zero).
    public String getDisplayValue()
    if(value < 10)
    return "0" + value;
    else
    return "" + value;
    * Set the value of the display to the new specified value. If the new
    * value is less than zero or over the limit, do nothing.
    public void setValue(int replacementValue)
    if((replacementValue >= 0) && (replacementValue < limit))
    value = replacementValue;
    * Increment the display value by one, rolling over to zero if the
    * limit is reached.
    public void increment()
    value = (value + 1) % limit;
    public class TryClockDisplay
    public static void main(String[] args)
    ClockDisplay clockDisplay_1 = new ClockDisplay();
    clockDisplay_1.setTime(17,40);
    System.out.println("\nThe time now is " + clockDisplay_1.getTime());
    clockDisplay_1.timeTick();
    clockDisplay_1.timeTick();
    clockDisplay_1.timeTick();
    clockDisplay_1.timeTick();
    clockDisplay_1.timeTick();
    clockDisplay_1.timeTick();
    clockDisplay_1.timeTick();
    System.out.println("\nThe time now is " + clockDisplay_1.getTime());

    String time = "09:25";
    String hrs = time.substring(0,2);
    int hrsInt = Integer.parseInt(hrs);
    if(hrsInt>12){
        time += "PM";
    System.out.println(time);                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for