Java.lang.ClassCastException: java.lang.Short

It(He,She) gives me the exception java.lang. ClassCastException: java.lang. Short, the complete code is:
java.lang.ClassCastException: java.lang.Short
     inventBD.EquipoBD.ConsultarEquipo(EquipoBD.java:36)
In the line 36 what I have is:
     nuevo_equipo.setPart((Integer)traRes.getObject(4));
The information that I spend(pass) this one to him(her) declared as an integer.
Which can be the problem? Something on having done the casting?

It(He,She) it
gives me the exception java.lang.
ClassCastException: java.lang. Short,So what does the API say this means? Ever bothered to have a look?
the complete
code is:
java.lang.ClassCastException: java.lang.Short
     inventBD.EquipoBD.ConsultarEquipo(EquipoBD.java:36)
In the line 36 what I have is:
     nuevo_equipo.setPart((Integer)traRes.getObject(4));
The information that I spend(pass) this one to
him(her) declared as an integer.You cast it to Integer. But it's a Short.

Similar Messages

  • Java.lang.NullPointerException throwed when doing Hibernate Persistence

    Im using Hibernate3.
    I am trying to add a record of "orderdetail", also setting its many-2-one association "order", which include a many-2-one association with "employer".
    Mycode is:
    public class OrderdetailDaoTest {
       public static void main(String[] args) {
          // TODO Auto-generated method stub
          try{
             Orderdetails vo = new Orderdetails();
             IOrdersDAO orderdao = new OrdersDAO();
             Integer orderid = new Integer("1");
             System.out.println("orderid is "+orderid.intValue());
             Orders order = (Orders)orderdao.getOrderByid(orderid);
             vo.setOrders(order);
             IEmployeesDAO eedao = new EmployeesDAO();
             Integer eeid = new Integer("1");
             Employees employee = eedao.getEmployeeByid(eeid);
             vo.setEmployees(employee);
             Calendar startdate = Calendar.getInstance();
             startdate.set(2007, 5, 15);
             //System.out.println("time is "+startdate.getTime());
             vo.setStartDate(startdate.getTime());
             Calendar enddate = Calendar.getInstance();
             startdate.set(2007, 6, 15);
             //System.out.println("time is "+enddate.getTime());
             vo.setEndDate(enddate.getTime());
             Calendar arrdate = Calendar.getInstance();
             arrdate.set(2007, 6, 16);
             //System.out.println("time is "+arrdate.getTime());
             vo.setArrivalDate(arrdate.getTime());
             vo.setArrivalStatus("Experienced Named");
             Calendar repatdate = Calendar.getInstance();
             repatdate.set(2007, 7, 16);
             //System.out.println("time is "+arrdate.getTime());
             vo.setRepatDate(repatdate.getTime());
             vo.setRepatStatus("Other");
             vo.setTransferStatus("Named Transfer");
             Calendar transferdate = Calendar.getInstance();
             transferdate.set(2007, 7, 1);
             //System.out.println("time is "+arrdate.getTime());
             vo.setDateTransferred(transferdate.getTime());
             vo.setNotes("This is a long test note!");
             IArrivalmanifesttblDAO arrivaldao = new ArrivalmanifesttblDAO();
             Arrivalmanifesttbl arrival = arrivaldao.getArrivalByAMNO("am01");
             vo.setArrivalmanifest(arrival);
             IRepatmanifesttblDAO repatdao = new RepatmanifesttblDAO();
             Repatmanifesttbl repat = repatdao.getRepatByRMNO("rm01");
             vo.setRepatmanifest(repat);
             vo.setRepatDetail("This is long test repat detail!");
             vo.setIncludeInArrivalManifest(new Byte("0"));
             vo.setIncludeInRepatManifest(new Byte("0"));
             vo.setTransferred(new Byte("1"));
             vo.setDelete(new Byte("0"));
             vo.setSno(new Short("100"));
             IOrderdetailsDAO dao = new OrderdetailsDAO();
             dao.add(vo);
          catch(ApplicationException e){
             e.getStackTrace();
             System.out.println("Exception throwed!");
    }The stack print like following:
    Exception in thread "main" java.lang.NullPointerException
       at com.farm.vo.Employers.hashCode(Employers.java:270)
       at com.farm.vo.Orders.hashCode(Orders.java:168)
       at java.util.HashMap.put(Unknown Source)
       at java.util.HashSet.add(Unknown Source)
       at java.util.AbstractCollection.addAll(Unknown Source)
       at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:273)
       at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:183)
       at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
       at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
       at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
       at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
       at org.hibernate.loader.Loader.doQuery(Loader.java:717)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
       at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)
       at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
       at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
       at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
       at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1676)
       at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
       at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:755)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:229)
       at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
       at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
       at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
       at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
       at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
       at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
       at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
       at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
       at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
       at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:792)
       at com.farm.dao.OrdersDAO.getOrderByid(OrdersDAO.java:98)
       at com.farm.unitTest.daotest.OrderdetailDaoTest.main(OrderdetailDaoTest.java:33)The mapping file for orderdetail is like:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!--
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="com.farm.vo.Orderdetails" table="orderdetails" catalog="llbv1" lazy="false">
            <id name="orderDetailId" type="java.lang.Integer">
                <column name="OrderDetailID" />
                <generator class="native" />
            </id>
            <many-to-one name="employees" class="com.farm.vo.Employees"  lazy="false">
                <column name="EmployeeID" />
            </many-to-one>
            <many-to-one name="orders" class="com.farm.vo.Orders" lazy="false">
                <column name="OrderID" />
            </many-to-one>
            <many-to-one name="repatmanifest" class="com.farm.vo.Repatmanifesttbl" cascade="all" lazy="false">
                <column name="RepatManifestNo" length="50" />
            </many-to-one>
            <many-to-one name="arrivalmanifest" class="com.farm.vo.Arrivalmanifesttbl" cascade="all" lazy="false">
                <column name="ArrivalManifestNo" length="50" />
            </many-to-one>
            <property name="startDate" type="java.util.Date">
                <column name="StartDate" length="19" />
            </property>
            <property name="endDate" type="java.util.Date">
                <column name="EndDate" length="19" />
            </property>
            <property name="arrivalDate" type="java.util.Date">
                <column name="ArrivalDate" length="19" />
            </property>
            <property name="arrivalStatus" type="java.lang.String">
                <column name="ArrivalStatus" length="21" />
            </property>
            <property name="repatDate" type="java.util.Date">
                <column name="RepatDate" length="19" />
            </property>
            <property name="repatStatus" type="java.lang.String">
                <column name="RepatStatus" length="18" />
            </property>
            <property name="transferStatus" type="java.lang.String">
                <column name="TransferStatus" length="16" />
            </property>
            <property name="dateTransferred" type="java.util.Date">
                <column name="DateTransferred" length="19" />
            </property>
            <property name="notes" type="java.lang.String">
                <column name="Notes" />
            </property>
            <property name="repatDetail" type="java.lang.String">
                <column name="RepatDetail" />
            </property>
            <property name="includeInArrivalManifest" type="java.lang.Byte">
                <column name="IncludeInArrivalManifest" />
            </property>
            <property name="includeInRepatManifest" type="java.lang.Byte">
                <column name="IncludeInRepatManifest" />
            </property>
            <property name="transferred" type="java.lang.Byte">
                <column name="Transferred" />
            </property>
            <property name="iomRemarks" type="java.lang.String">
                <column name="IOM_Remarks" />
            </property>
            <property name="observations" type="java.lang.String">
                <column name="Observations" />
            </property>
            <property name="mitigatingFactors" type="java.lang.String">
                <column name="MitigatingFactors" />
            </property>
            <property name="delete" type="java.lang.Byte">
                <column name="isDelete" />
            </property>
            <property name="employeeRemarks" type="java.lang.String">
                <column name="EmployeeRemarks" />
            </property>
            <property name="nbstatus" type="java.lang.String">
                <column name="NBStatus" length="50" />
            </property>
            <property name="sno" type="java.lang.Short">
                <column name="SNo" />
            </property>
            <property name="userComment" type="java.lang.String">
                <column name="UserComment" />
            </property>
        </class>
    </hibernate-mapping>I am stuck with this problem for several days. Any seggestion is appreciated!
    Thanks in advance.

    It seems that the exception throwed on the hashcode() for NULL value field include in the association.... The many-2-one assciation is bidirectional, by the way.
    Is my hibernate mapping file somewhere implicitly restrict the association fields can not be NULL? If it is, can somebody tells me where?
    Following is "orderdetail"'s bidirectinal association definition, "order" mapping file:
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!--
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="com.farm.vo.Orders" table="orders" catalog="llbv1">
            <id name="orderId" type="java.lang.Integer">
                <column name="OrderID" />
                <generator class="native" />
            </id>
            <many-to-one name="employer"  class="com.farm.vo.Employers" lazy="false">
                <column name="EmployerID"/>
            </many-to-one>
            <property name="hrdcorderCode" type="java.lang.String">
                <column name="HRDCOrderCode" length="50" />
            </property>
            <property name="farmsorderCode" type="java.lang.String">
                <column name="FARMSOrderCode" length="50" />
            </property>
            <property name="orderDate" type="java.util.Date">
                <column name="OrderDate" length="19" />
            </property>
            <property name="startDate" type="java.util.Date">
                <column name="StartDate" length="19" />
            </property>
            <property name="endDate" type="java.util.Date">
                <column name="EndDate" length="19" />
            </property>
            <property name="orderType" type="java.lang.String">
                <column name="OrderType" length="20" not-null="true" />
            </property>
            <property name="noOfWorker" type="java.lang.Short">
                <column name="NoOfWorker" />
            </property>
            <property name="orderStatus" type="java.lang.String">
                <column name="OrderStatus" length="12" />
            </property>
            <property name="notes" type="java.lang.String">
                <column name="Notes" />
            </property>
            <set name="orderdetails" inverse="true" cascade="all-delete-orphan" lazy="false">
               <key column="OrderId"/>
             <one-to-many class="com.farm.vo.Orderdetails"/>
          </set>
        </class> Thank you!

  • Fail to bind Java Short/Byte type in  Oracle Driver in WLS6.1

    Hi,
    In Oracle, the field is defined as Number(5), but we failed to bind
    the Java Short/Byte object to the PreparedStatement in WLS.
    WLS 6.1 with SP2.
    Any hint here? Or other people can succeed with Oracle's own driver.
    I have noticed a post about WLS's Oracle Driver support will be ceded
    in the future. Can we still get support on the Oracle Driver from WLS?
    Thanks,
    Sheng Song

    We get this exception thrown from WLS:
    java.sql.SQLException: Cannot bind object type: java.lang.Short
         at weblogic.jdbc.oci.Statement.setObject(Statement.java:1412)
         at weblogic.jdbc.jts.Statement.setObject(Statement.java:952)
         at
    weblogic.jdbc.rmi.internal.PreparedStatementImpl.setObject(PreparedStatementImpl.java:304)
         at
    weblogic.jdbc.rmi.SerialPreparedStatement.setObject(SerialPreparedStatement.java:386)
    The method is like
         pStmt.setObject(1, new Short(2));
    Seems like the driver failed to bind Short type correctly to Number
    type.
    Thanks
    Sheng Song
    On Thu, 24 Jan 2002 21:11:47 -0800, "Slava Imeshev"
    <[email protected]> wrote:
    Hi Simon,
    Could you show us your code?
    Do you get any exceptions?
    Regards,
    Slava Imeshev
    "Simon Song" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    In Oracle, the field is defined as Number(5), but we failed to bind
    the Java Short/Byte object to the PreparedStatement in WLS.
    WLS 6.1 with SP2.
    Any hint here? Or other people can succeed with Oracle's own driver.
    I have noticed a post about WLS's Oracle Driver support will be ceded
    in the future. Can we still get support on the Oracle Driver from WLS?
    Thanks,
    Sheng Song

  • Does the Number type in Oracle always map to the Java BigDecimal object

    We have noticed that whenever we create a column in a table of type smallint, integer, real, etc. that the type in sqlplus always shows up as number(x). Our problem is that this type always seems to map to java.math.BigDecimal through JDBC. Is this a bug in the JDBC drivers???
    Put another way when I create a column of type smallint I expect that after performing a query I should be able to call the getShort method on the result set in order to get the value from the afore mentioned column. But instead I get a ClassCastException because the Java type for the column is actually a java.math.BigDecimal.
    Thanks,
    Keith
    [email protected]

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Keith Nielsen:
    We have noticed that whenever we create a column in a table of type smallint, integer, real, etc. that the type in sqlplus always shows up as number(x). Our problem is that this type always seems to map to java.math.BigDecimal through JDBC. Is this a bug in the JDBC drivers???
    Put another way when I create a column of type smallint I expect that after performing a query I should be able to call the getShort method on the result set in order to get the value from the afore mentioned column. But instead I get a ClassCastException because the Java type for the column is actually a java.math.BigDecimal.
    Thanks,
    Keith
    [email protected]<HR></BLOCKQUOTE>
    ~~~
    The possible Java types to which SQL NUMBER type can be materialized to include
    oracle.sql.NUMBER
    java.lang.Byte
    java.lang.Short
    java.lang.Integer
    java.lang.Long
    java.lang.Float
    java.lang.Double
    java.math.BigDecimal
    byte,short, int, long, float, double
    For a complete listing for all datatypes mappings refer the Oracle8i JDBC Developer's guide and reference.

  • Problem with PermGen memory (Java) - Tomcat Server - Business Object XI

    We have installed Business Objects XI on a W2003 Standard with SP2 (x86), using Tomcat as web server and MySQL as DBMS. The server has 4 GB of RAM and dual-core processor. From the beginning we have been given the memory problems of the Java virtual machine. The exception that occurs is of type "java.lang.OutOfMemoryError: PermGen space failure". We modify environment variables (JAVA_OPTS) -XX: PermSize = 256m and-XX: MaxPermSize = 512m and install the monitor LambdaProbe to see the use made of memory. We note that at no time was the PermGen memory indicated by these variables, continuing in that has a default 64MB. For this reason we decided to change the Tomcat 5.5 BO included in the version 6.0.20 and also updated Java to version 1.6.0_18-b07, and make deployment by wdeploy.bat file that comes with BusinessObjects (changing config.tomcat55 and tomcat55.xml). The deployment was successful and everything works, but as with the previous version of Java / Tomcat, shortly PermGen memory fills and returns to "hang". In this latest version of Tomcat installed as a service, do not use environment variables, use an application, "Configure Tomcat", which is a tab to pass parameters to the JVM. After looking at many sites, I have seen to be putting "-D" to pass the parameter. Currently this is my configuration:
    -Dcatalina.home = C: \ Program Files \ Apache Software Foundation \ Tomcat 6.0-Dcatalina.base = C: \ Program Files \ Apache Software Foundation \ Tomcat 6.0-Djava.endorsed.dirs = C : \ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ endorsed-Djava.io.tmpdir = C: \ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ temp-Djava.util.logging.manager = org.apache.juli . ClassLoaderLogManager-Djava.util.logging.config.file = C: \ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ conf \ logging.properties-Dcom.sun.management.jmxremote-D-Xms2g-D-Xmx2g-D -XX: + UseConcMarkSweepGC-D-XX:-D PermSize = 256m-XX: MaxPermSize = 512m-Daf.configdir = C: / Program Files / Business Objects / Dashboard and Analytics 12.0-D-verbose: gc-D-XX : + PrintGCTimeStamps-D-XX: + PrintGCDetails
    I tried changing the values of-XX: PermSize and XX: MaxPermSize, and modifying the various policies of the Garbage Collector (-XX: + UseConcMarkSweepGC,-XX: + UseParNewGC,-XX: + UseParallelGC, ...), but nothing. Any idea how to get change the value of the report? Or how to solve this problem?
    Thank you!

    Victor,
    Is the Product you are using BusinessObjects Enterprise XI (Release 1)?
    With XIR2 and XI31, Tomcat 5.0 and Tomcat 5.5 are included with the software, and when installed with the BOE installer, you will get an application installed to the startmenu named "Tomcat Configuration".
    Using this "Tomcat Configuration" utility, there are several configuration options available.  On the JAVA tab, you will see the JAVA_OPTS that are set (These are prefixed with "-D") and also your initial and max memory sizes are listed at the bottom (Max 1024 by default in XI31).
    Here is the default setting for permsize in XI31 Tomcat:
    -XX:MaxPermSize=256M
    From your post, your issue might be the spaces in between your values (there should be no spaces, each "-" parameter on its own line).
    I would suggest starting Tomcat and reviewing your stdout.log file to review what options were set.
    Hope that helps
    -Brian

  • Datasource, POJO and java.sql.Blob

    Hello,
    is "java.sql.Blob" a valid type for a POJO datasource ?
    I declared one but I just dit not succeed in rendering its jpg picture.
    My java code is quite simple :
    ReportClientDocument reportClientDocument = new ReportClientDocument ();
    reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);
    reportClientDocument.open (REPORT_NAME, OpenReportOptions._openAsReadOnly);
    // lBlob is a class which implements java.sql.Blob interface
    LPOJOData [] dataP = {new LPOJOData(new lBlob("Picture.jpg"))};
    POJOResultSetFactory factory = new POJOResultSetFactory(LPOJOData.class);
    POJOResultSet resultSet = factory.createResultSet(dataP);
    reportClientDocument.getDatabaseController().setDataSource(resultSet, "", "");
    and my POJO class :
    public class LPOJOData {          
              private java.sql.Blob zimage;
              public LPOJOData(java.sql.Blob zp){
                   this.zimage = zp;
              public java.sql.Blob getzimage(){
                   return zimage;
    The field "zimage" on the report is designed through a "field definition only" database, zimage is defined as a Blob field.
    Any clues ?
    Regards,
    Serge

    I have just found a list of the data types supported by a POJO Class :
    # boolean
    # byte
    # char
    # double
    # float
    # int
    # short
    # java.lang.Boolean
    # java.lang.Byte
    # java.lang.Double
    # java.lang.Float
    # java.lang.Integer
    # java.lang.Short
    # java.lang.String
    # java.SQL.Date
    # java.SQL.Time
    Well, java.SQL.Blob is not one of them.
    Is java.SQL_Blob will be a valid POJO type in the future ?
    Is there another way than POJO to feed a report from an in-memory datasource ?

  • Connecting java file to jsp

    Hi i'm working on a jsp file and i want my jsp file to access the methods in a java file of mine.I have an idea its got something to do with beans. But i have no knowledge about beans. does anyone know how i can acheive it.

    The following ( from the java tutorial with samples is downloadable) gave me the clarity in understanding how .jsp interact with classes (modified beans)
    This tutorial is available at
    http://java.sun.com
    and follow thelinks for the tutorial.
    Here Goes.....
    Home | Download | PDF | API | FAQ | Search | Feedback | History
    JavaBeans Components
    JavaBeans components are Java classes that can be easily reused and composed together into applications. Any Java class that follows certain design conventions is a JavaBeans component.
    JavaServer Pages technology directly supports using JavaBeans components with standard JSP language elements. You can easily create and initialize beans and get and set the values of their properties.
    JavaBeans Component Design Conventions
    JavaBeans component design conventions govern the properties of the class and govern the public methods that give access to the properties.
    A JavaBeans component property can be
    Read/write, read-only, or write-only
    Simple, which means it contains a single value, or indexed, which means it represents an array of values
    A property does not have to be implemented by an instance variable. It must simply be accessible using public methods that conform to the following conventions:
    For each readable property, the bean must have a method of the form
    PropertyClass getProperty() { ... }
    For each writable property, the bean must have a method of the form
    setProperty(PropertyClass pc) { ... }
    In addition to the property methods, a JavaBeans component must define a constructor that takes no parameters.
    The Duke's Bookstore application JSP pages bookstore.jsp, bookdetails.jsp, catalog.jsp, and showcart.jsp use the database.BookDB and database.BookDetails JavaBeans components. BookDB provides a JavaBeans component front end to the access object database.BookDBAO. The JSP pages showcart.jsp and cashier.jsp access the bean cart.ShoppingCart, which represents a user's shopping cart.
    The BookDB bean has two writable properties, bookId and database, and three readable properties: bookDetails, numberOfBooks, and books. These latter properties do not correspond to any instance variables but rather are a function of the bookId and database properties.
    package database;
    public class BookDB {
    private String bookId = "0";
    private BookDBAO database = null;
    public BookDB () {
    public void setBookId(String bookId) {
    this.bookId = bookId;
    public void setDatabase(BookDBAO database) {
    this.database = database;
    public BookDetails getBookDetails() throws
    BookNotFoundException {
    return (BookDetails)database.getBookDetails(bookId);
    public List getBooks() throws BooksNotFoundException {
    return database.getBooks();
    public void buyBooks(ShoppingCart cart)
    throws OrderException {
    database.buyBooks(cart);
    public int getNumberOfBooks() throws BooksNotFoundException {
    return database.getNumberOfBooks();
    Creating and Using a JavaBeans Component
    To declare that your JSP page will use a JavaBeans component, you use a jsp:useBean element. There are two forms:
    <jsp:useBean id="beanName"
    class="fully_qualified_classname" scope="scope"/>
    and
    <jsp:useBean id="beanName"
    class="fully_qualified_classname" scope="scope">
    <jsp:setProperty .../>
    </jsp:useBean>
    The second form is used when you want to include jsp:setProperty statements, described in the next section, for initializing bean properties.
    The jsp:useBean element declares that the page will use a bean that is stored within and is accessible from the specified scope, which can be application, session, request, or page. If no such bean exists, the statement creates the bean and stores it as an attribute of the scope object (see Using Scope Objects). The value of the id attribute determines the name of the bean in the scope and the identifier used to reference the bean in EL expressions, other JSP elements, and scripting expressions (see Chapter 16). The value supplied for the class attribute must be a fully qualified class name. Note that beans cannot be in the unnamed package. Thus the format of the value must be package_name.class_name.
    The following element creates an instance of mypkg.myLocales if none exists, stores it as an attribute of the application scope, and makes the bean available throughout the application by the identifier locales:
    <jsp:useBean id="locales" scope="application"
    class="mypkg.MyLocales"/>
    Setting JavaBeans Component Properties
    The standard way to set JavaBeans component properties in a JSP page is by using the jsp:setProperty element. The syntax of the jsp:setProperty element depends on the source of the property value. Table 12-3 summarizes the various ways to set a property of a JavaBeans component using the jsp:setProperty element.
    Table 12-3 Valid Bean Property Assignments from String Values Value Source Element Syntax
    String constant <jsp:setProperty name="beanName"
    property="propName" value="string constant"/>
    Request parameter <jsp:setProperty name="beanName"
    property="propName" param="paramName"/>
    Request parameter name that matches bean property <jsp:setProperty name="beanName"
    property="propName"/>
    <jsp:setProperty name="beanName"
    property="*"/>
    Expression <jsp:setProperty name="beanName"
    property="propName" value="expression"/>
    <jsp:setProperty name="beanName"
    property="propName" >
    <jsp:attribute name="value">
    expression
    </jsp:attribute>
    </jsp:setProperty>
    1. beanName must be the same as that specified for the id attribute in a useBean element.
    2. There must be a setPropName method in the JavaBeans component.
    3. paramName must be a request parameter name.
    A property set from a constant string or request parameter must have one of the types listed in Table 12-4. Because constants and request parameters are strings, the web container automatically converts the value to the property's type; the conversion applied is shown in the table.
    String values can be used to assign values to a property that has a PropertyEditor class. When that is the case, the setAsText(String) method is used. A conversion failure arises if the method throws an IllegalArgumentException.
    The value assigned to an indexed property must be an array, and the rules just described apply to the elements.
    Table 12-4 Valid Property Value Assignments from String Values Property Type Conversion on String Value
    Bean Property Uses setAsText(string-literal)
    boolean or Boolean As indicated in java.lang.Boolean.valueOf(String)
    byte or Byte As indicated in java.lang.Byte.valueOf(String)
    char or Character As indicated in java.lang.String.charAt(0)
    double or Double As indicated in java.lang.Double.valueOf(String)
    int or Integer As indicated in java.lang.Integer.valueOf(String)
    float or Float As indicated in java.lang.Float.valueOf(String)
    long or Long As indicated in java.lang.Long.valueOf(String)
    short or Short As indicated in java.lang.Short.valueOf(String)
    Object new String(string-literal)
    You use an expression to set the value of a property whose type is a compound Java programming language type. The type returned from an expression must match or be castable to the type of the property.
    The Duke's Bookstore application demonstrates how to use the setProperty element to set the current book from a request parameter in the database bean in bookstore2/web/bookdetails.jsp:
    <c:set var="bid" value="${param.bookId}"/>
    <jsp:setProperty name="bookDB" property="bookId"
    value="${bid}" />
    The following fragment from the page bookstore2/web/bookshowcart.jsp illustrates how to initialize a BookDB bean with a database object. Because the initialization is nested in a useBean element, it is executed only when the bean is created.
    <jsp:useBean id="bookDB" class="database.BookDB" scope="page">
    <jsp:setProperty name="bookDB" property="database"
    value="${bookDBAO}" />
    </jsp:useBean>
    Retrieving JavaBeans Component Properties
    The main way to retrieve JavaBeans component properties is by using the JSP EL expressions. Thus, to retrieve a book title, the Duke's Bookstore application uses the following expression:
    ${bookDB.bookDetails.title}
    Another way to retrieve component properties is to use the jsp:getProperty element. This element converts the value of the property into a String and inserts the value into the response stream:
    <jsp:getProperty name="beanName" property="propName"/>
    Note that beanName must be the same as that specified for the id attribute in a useBean element, and there must be a getPropName method in the JavaBeans component. Although the preferred approach to getting properties is to use an EL expression, the getProperty element is available if you need to disable expression evaluation.
    All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.
    hope this helps
    regards,

  • WEB-AS JAVA type TS not removable from SLD

    Hi Experts,
    I have a peculiar issue where In I have a ECC 6.0 ( SID :- RD1) added in my SLD of PI 7.0 as WEB-AS ABAP Type Technical System.
    I was able to work with the corresponding Business System in my ID( configuration). But two days back when I logged in to view my SLD , I could see that in my Technical System category there are two instances of RD1 one WEB-AS ABAP and other WEB-AS JAVA . Now I suppose WEB-AS JAVA type TS for RD1 was created by mistake. But now when I am removing it from the TS category and also removing the instances created under BCSystem and SAP JAVA cluster in content maintainence. I see the WEB-AS JAVA type TS appearing again in the TS after some time. I repeated the same several times and also start/stop  the SLD server but then after sometime again the WEB-AS JAVA type TS for RD1( ECC 6.0 - not required) appearing in the list of TS.
    I  am unable to understand this absurd behaviour. I have carefully removed all the instances from the content maintainence but still it appears after sometime.
    Are there any other possible places where there can be instance created for the WEB-AS JAVA type TS in SLD server where from I am supposed to remove it ???
    Regards
    Nishant

    Hi Nishant,
    You question is little confusing
    Case1. Are you saying : You made TS (Say XYZ) for ABAP part of an SAPECC system and next day you found a TS with the same name (XYZ) for the same SAPECC system, but the component was JAVA  In short you have two TS one for each ABAP  & Java Part of the same systems.
    Case2 :1. Are you saying : You made TS (Say XYZ) for ABAP part of an SAPECC system and next day you found a TS with the some other name (ABC) for the same SAPECC system, but the component was JAVA  In short you have a TS for each ABAP  & Java Part of the same system.  If this is the case then, how is this possible both cannot have same name
    Regards
    Suraj

  • Modularize the java code

    Hello All,
    I am working on a Java project in eclipse which has the following structure:
    package
        |---Trie.java
        |---TrieImpl.java
        |---TrieNode.javaThe main class and the operations on the Trie are methods in 'TrieImpl.java'
    In short, the TrieImpl.java file is as:
    import.....
    public class TrieImpl<T> implements Trie<T>
        public boolean delete(String key) {
        public void insert(String key, T value) {
       public void search(String query, int distance) {
       search(root,query,distance,qPos,weight,result,found);
       private void search(TrieNode<T> node, String Q, int D, int qIndex, int W, StringBuilder result, boolean found) {
       while (found == false && qIndex < Q.length() && W <= D ) {
       do something
       search(n, Q, D, qIndex, W, result, found); // recursive search
       public void static main {
           TrieImpl<String> tree = new TrieImpl<String>();
           ......get the query and distance from the user......
           tree.search(query,distance);
      }I would like to use Global variables like the boolean variable found in the search function.
    for e.g. here are some variables I would like to be global
    boolean found
    int distance
    int qIndex
    String Q (the original query string)
    StringBuilder result
    So that when I set the found to true in any on the search recursions, I can exit the search stack.
    The problem right now is that since I am passing the 'found' value at every recursion, each stack has a different boolean value for found.
    Some suggestions I googled instructed to create a global class and access the variables with the class identifier.
    How can I do that here?
    Thanks in advance.

    The problem right now is that since I am passing the 'found' value at every recursion, each stack has a different boolean value for found.Why doesn't your method just return a bool to indicate the result?

  • How fast is Java?

    I am current having a linkedlist of objects(I have to use linkedlist), I populated with 51000 objects inside. These objects have one string in each and each string is small in size and there is no duplicates.
    Now I run through this list to search for one string, let's say "XXXxxxXXX". This string, in worst case, is now being placed at the bottom of the list. Now, I run through 51000 objects to do a string compare and this little program doesn't even have GUI. It runs in 7 seconds.
    I just wonder why it takes so long? my coworker told me that it takes < 7ms to finish this in a PLC. Any idea that I can make this Java program shorter in second? Here is my code:
    public boolean findMessage(Message message){
              int size = messageQueue.size();
              boolean found = false;
              for(int i=size-1;i>=0;i--){
                   Message candidate = messageQueue.get(i);
                   if(message.getMessage().equalsIgnoreCase(candidate.getMessage())){
                        i = -1;
                        found = true;
              return found;
    MessageQueue queue = MessageQueue.getInstance();
                   queue.setMaxSize(51000);
                   for(int i=0;i<51000;i++){
                        queue.addMessage(new Message(Integer.toString(i)));
                   // Find the last one and print
                   long start = System.currentTimeMillis();
                   long queueSize = queue.getMaxSize();
                   boolean found = false;
                   Message search = new Message(Integer.toString(0));
                   if(queue.findMessage(search) == true){
                        found = true;
                   long end = System.currentTimeMillis();
                   long total = end - start;
                   System.out.println("Time used to search("+found+"):" + ((double)total)/((double)1000));

    The hardware is:
    P-D 1.8GHz
    2GB Ram
    WinXP SP2
    Compiler: jdk1.5.0_09
    I am actually writing a program that my coworker's 20 PLCs send signals to my program and my program spawns threads to take care of all requests. Requests are as simple as a string that is asking if the previous PLC has done its job. We are going to use DB to search for the record, as long as the record is inserted there, that PLC knows its previous PLC has done its job so the second one can start its job.
    However, DB takes too long to search especially when you need to re-index it all the time and PLC needs response in 50ms. So I wonder at least if I could take it down to 0.5 second, that should be still possible to take it down more or possibly using jni. Why I don't go for C then? because Java's built-in threading capability is a wonderful product that I should make sure of. Of course if I could make it in pure Java, it would be great because we won't know what platform we will deploy this Java program on.
    So any idea? even if you say assembly language would be fine for me, but please provide me details on it because I am just a beginner. Thanks.

  • How is literal short works...?

    Hi frnds i am new to this forum i have some basic doubt on literals.
    public class example{
    public static void go(Long n){System.out.println("Its Long");};
         public static void go(Short n){System.out.println("Its Short");};
         public static void go(int n){System.out.println("Its Int");};
    public static void main(String[] args) {
    short x=6;
              long y=7;
              go(x);
              go(y);
    The out put of this is:
    Its Int
    Its Long
    why its Int is printed instead its short? I have doubt here how exactly this literals works in case of in and short datatypes?
    any suggestion and explanations ... thanks in advance.

    hi ejp.... thanks for the reply...
    basically i dont have any purpose to work this code to print as its short.
    i just wanna know what exactly making this go(x); to execute go(int n).... even though ther is go(Short n).. method ..?
    x is declared as short.
    when i replace literal to its wrapper class Short (java.lang,Short) out put will be Its short.
    why this not apply for Long..???
    Any explanation..

  • BC4J/Struts java.lang.ClassCastException in UpdateAction

    Dear reader,
    I am facing a problem that I can't address. I have an entity object named 'Employee' and on the password field, there is one validation rule (a method, which checks if the passwords length is between 6 and 12 characters). I have a view called 'EmployeeView' for this entity.
    I have a jsp page, where a form can be used to update an Employee's data (using an update-action servlet). This all works fine if there is no validation rule on one of the fields (as is on password), as soon as the user fills in let's say a too short password, in UpdateAction this line causes an ClassCastException.
    oracle.jbo.html.struts11.actions.UpdateAction.execute(UpdateAction.java:85)
    The source-line it goes wrong:
    ApplicationConfig appConfig = (ApplicationConfig) request.getAttribute(Action.APPLICATION_KEY);
    Apparently it is not set then... But it works fine if the password is filled in within the range of the rule.
    Does anyone have any idea why this is caused? Am I missing something vital? Or am I doing something wrong? Thanx a lot for your time.
    Regards,
    Martijn

    Take a look at the stack trace, it shows you exactly where the error is coming from:
    java.lang.ClassCastException: org.theclass.candidate.view.SearchForm
    org.theclass.candidate.view.CandidateListAction.execute(CandidateListAction.java:41)Line 41 in your CandidateListAction.
    Probably it is failing on a cast of your action form.
    Taking a closer look at your struts-config, you are "chaining" actions.
    Your AddCandidateAction uses the candidateForm, and forwards to CandidateListAction.do
    Your CandidateListAction uses the searchForm.
    That will be the cause of your class cast exception.
    <action path="/Add"
      name="candidateForm"
      type="org.theclass.candidate.view.AddCandidateAction"
      validate ="true"
      input="/jsp/addcandidate.jsp">
      <forward name="success" path="/CandidateList.do"/>
    </action>
    <action path="/CandidateList"
    type="org.theclass.candidate.view.CandidateListAction"
    name="searchForm"
    scope="request" >
    <forward name="failure" path="/jsp/list.jsp"/>
    <forward name="success" path="/jsp/candidatelist.jsp"/>
    </action>Check out: http://struts.apache.org/1.x/faqs/newbie.html#chaining
    Solutions?
    - don't chain actions ;-)
    - use the same action form for both actions (possible?)
    - make the actionForward a "redirect" one. That means a new request, and losing any request parameters/attributes but should prevent this class cast exception.
    Hope this helps,
    evnafets

  • Java.lang.ClassCastException: com.businessobjects.dsws.session.impl.Credent

    Hi All,
    I am trying to create a web session with Java SDK using Eclipse. I am use Business Objects XI R3.1. While creating web session it gives me exception on line SessionInfo boSI = boSession.login(boCredential);
    I have ensured user name password and cms url.
    java.lang.ClassCastException: com.businessobjects.dsws.session.impl.CredentialIm
    pl
            at com.businessobjects.dsws.session.SessionSkeleton.login(Unknown Source
            at com.businessobjects.dsws.session.SessionMessageReceiverInOut.invokeBu
    sinessLogic(Unknown Source)
            at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBus
    inessLogic(AbstractInOutSyncMessageReceiver.java:42)
            at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe
    ssageReceiver.java:96)
            at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
            at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq
    uest(HTTPTransportUtils.java:275)
            at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1
    20)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
            at com.businessobjects.dsws.wsc.common.axis.FlashFilter.doFilter(Unknown
    Source)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
    a:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
    rocessConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
    int.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
    lowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
    ool.java:684)
            at java.lang.Thread.run(Thread.java:595)
    Thanks in advance,
    Rajendra

    I have experienced exactly the same problem with saaj from jwsdp 2.0
    If you found a solution, please give us a short feedback ?
    I juste noticed that the same code works great with axis 1.4 saaj api.

  • Jpql - multi expressions in select query, java.lang.ClassCastException:

    Hello, i'm trying to get a Unit object from the query below.
    i am getting javax.ejb.EJBException in this method
    @NamedQuery(name = "getUnitIdUnitName", query = "SELECT u.unitId,u.unitName FROM Unit u "+ "ORDER BY u.unitName")
    public Unit getUnitsComboBox() {
    //get UnitId, UnitName from Units.
    Unit unitIDUnitName =(Unit) ((List<Object[]>)em.createNamedQuery("getUnitIdUnitName").getResultList()).get(0)[0];
    return unitIDUnitName;
    Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to mmis.entity.Unit
    Must i use an iterator ?
    Thanx

    Amasoni wrote:
    Hello, i'm trying to get a Unit object from the query below.
    i am getting javax.ejb.EJBException in this method
    @NamedQuery(name = "getUnitIdUnitName", query = "SELECT u.unitId,u.unitName FROM Unit u "+ "ORDER BY u.unitName")
    public Unit getUnitsComboBox() {
    //get UnitId, UnitName from Units.
    Unit unitIDUnitName =(Unit) ((List<Object[]>)em.createNamedQuery("getUnitIdUnitName").getResultList()).get(0)[0];
    return unitIDUnitName;
    Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to mmis.entity.Unit
    ThanxYou don't want to select the columns, you want to select the object itself.
    SELECT u FROM Unit u ORDER BY u.unitName
    or even shorter:
    FROM Unit u ORDER BY u.unitName
    Try to reason where to put your question by the way, it is not about Javaserver Faces. If you can't find a forum that clearly matches consider putting it in Java Programming. In this case it was entirely unnecessary since you already posted JPA questions in the EJB forum, which is a decent match.

  • Java.lang.ClassCastException

    My class CDRack is almost ready, but in the last method
    sortAlphabetically() there
    comes java.lang.ClassCastException. I found in the net
    http://java.sun.com/docs/books/tutorial/collections/algorithms/
    that with method Collections.sort(l) I can sort alphabetically.
    The code compiles, but when I run it with a tester program, it stops
    to ClassCastException in the almost last row.
    Something is wrong with Collections.sort(l) ?
    /** Class CDRack represents collections of compact discs. Discs are
    located in the rack in slots numbered from zero upwards. The discs are
    represented by Record objects and empty slots by null values. */
    public class CDRack extends Object {
      private Record[] mRecords;
      private int size;
    /**Creates a new, empty CD rack.
    Parameters:
    size - the size of the new rack, i.e. the number of slots it has */
          public CDRack(int size) {
              mRecords = new Record[size];
              this.size = size;
    /** "Organizes" the discs in the rack so that they will be located in
    consecutive slots starting at slot number zero, and any and all empty
    slots will be at the "end of the rack". After calling this method, the
    discs are in an undefined (i.e. arbitrary) order - the only thing this
    method guarantees is that there aren't any empty slots in between full
    ones.
          public void organize() {
              // Turn array into a list - more flexible
              List l = Arrays.asList(aanilevyt);
              // Remove all nulls from a copy of the list which supports  removal.
              l = new ArrayList(l);
              while (l.remove(null)) /*do nothing*/;
              // Clear the original array.
              for (int i = 0; i < mRecords.length; i++){
                   mRecords[i] = null;
              } // Put the non-nulls back.
              l.toArray(mRecords);
    /**"Organizes" the discs in the rack to the beginning of the rack (see
    the method organize) and sorts them in alphabetical order. Recordings
    by the same artist are placed in alphabetical order by disc name. */
        public void sortAlphabetically() {
              // Turn array into a list - more flexible
              List l = Arrays.asList(aanilevyt);
              // Remove all nulls from a copy of the list which supports  removal.
              l = new ArrayList(l);
              while (l.remove(null)) /*do nothing*/;
              // Clear the original array.
              for (int i = 0; i < mRecords.length; i++){
                   mRecords[i] = null;
              } // Put the non-nulls back.
              l.toArray(mRecords);
              Collections.sort(l);   // alphabetical order. THERE IS CLASSCASTEXCEPTION 
    }

    I have thought and thought but the sorting alphabetically doesnt work.
    I can't use Collections.sort and class Record doesnt implement Comparable(and I can't change it).
    One suggestion was that I could make my own class which implements Comparator. Could it be like this
    import java.util.*;
    public class AlphabeticComparator
    implements Comparator{
      public int compare(Object o1, Object o2) {
        String s1 = (String)o1;
        String s2 = (String)o2;
        return s1.toLowerCase().compareTo(
          s2.toLowerCase());
    }      But how an earth can I tell to CDRack class that it would
    use the class AlphabeticComparator?
    Somebody please save my Christmas!
    /** Class CDRack represents collections of compact discs. Discs are
    located in the rack in slots numbered from zero upwards. The discs are
    represented by Record objects and empty slots by null values. */
    public class CDRack extends Object {
      private Record[] mRecords;
      private int size;
    /**Creates a new, empty CD rack.
    Parameters:
    size - the size of the new rack, i.e. the number of slots it has */
          public CDRack(int size) {
              mRecords = new Record[size];
              this.size = size;
    /** "Organizes" the discs in the rack so that they will be located in
    consecutive slots starting at slot number zero, and any and all empty
    slots will be at the "end of the rack". After calling this method, the
    discs are in an undefined (i.e. arbitrary) order - the only thing this
    method guarantees is that there aren't any empty slots in between full
    ones.
          public void organize() {
              // Turn array into a list - more flexible
              List l = Arrays.asList(aanilevyt);
              // Remove all nulls from a copy of the list which supports  removal.
              l = new ArrayList(l);
              while (l.remove(null)) /*do nothing*/;
              // Clear the original array.
              for (int i = 0; i < mRecords.length; i++){
                   mRecords<i> = null;
              } // Put the non-nulls back.
              l.toArray(mRecords);
    /**"Organizes" the discs in the rack to the beginning of the rack (see
    the method organize) and sorts them in alphabetical order. Recordings
    by the same artist are placed in alphabetical order by disc name. */
        public void sortAlphabetically() {

Maybe you are looking for

  • Regd: Calculation of TOTAL field in ALV report

    Hi All, We have a scenario that we are not getting the total value for numeric fields in ALV report. Below i have given the code used for it. G_KEY = 'X'.   G_NOKEY = SPACE.   G_SUM = 'X'.   G_NOSUM = SPACE.   PERFORM BUILD_FIELDCAT USING 'VBELN'  G_

  • Parse xml file and extract tags (not well formed)

    im writing an xml editor and i would like to extract tags from a string of xml. And the string doesnt have to be well formed xml. An example "</a><b asd="kjkj"></b>" Output end tag (a) start tag (b) end tag (b) Sax nor stax does the job since they wa

  • Why did Apple take MIDI support out of QuickTime 10?

    MIDI may not be a prevalent standard, but there's still quite a lot of music written in it.  Why would Apple drop it?  It seems like a giant departure away from Apple's usual philosophy of "everything just works." If I wanted to use an OS where I had

  • Touch punch

    Hello, We have a problem with the function jQuery UI Touch Punch. it doesn't work on the iPad The object is possible to move, but it don't drop to his place. We spent many hours to find a solution.. but we can't find a solution.. is this a bug?? Plea

  • Problem with E5 - scanlines on screen.

    Hello, I need help with my e5.. here's the background and problems..I recently acquired this phone, as an almost brandnew unit.I have never dropped the phone, and I have seldomly used it because I am busy at work. Now I have time to tinker around the