Properties.store throws NullPointerException

Hi,
I have a strange problem with the java.util.Properties class. Calling
store on a Properties object AFTER I've called System.setProperties
always leads to a NullPointerException.
Code sample 1:
Properties props = new Properties();
props.put("prop1", "val1");
ByteArrayOutputStream out = new ByteArrayOutputStream();
props.store(out, "Header");
Code sample 2:
Properties props = new Properties();
props.put("prop1", "val1");
System.setProperties(props);
ByteArrayOutputStream out = new ByteArrayOutputStream();
props.store(out, "Header");
Code sample 1 works fine, sample 2 throws a NullPointerException in
the last line. Even code sample 3 throws the exception in the last
line.
Code sample 3:
Properties props = new Properties();
props.put("prop1", "val1");
System.setProperties(props);
props = new Properties();
ByteArrayOutputStream out = new ByteArrayOutputStream();
props.store(out, "Header");
How can I avoid this problem. I can't guarantee that no one calls
System.setProperties before the store call, so this is no solution. I
need the store call to save the properties to a String. At a later
time I want to use Properties.load to read the properties from this
String (via ByteArrayInputStream). Perhaps there is another way to
store/load properties to/from a String?
Thanks,
Markus

Hi,
I think the problem is that if u create a new Property it will create a new property with null value
Creates an empty property list with no default values.
and if u try to override the systemproperty creates a null pointer Exception.
Insteda try this
Properties p=System.getProperties();
          p.put("prop1","val1");
          System.setProperties(p);
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          p.store(out, "Header");
means , try to get the property object from the system and go ahead with ur coding is working fine
Greetz
Kumar.R

Similar Messages

  • Properties store problem!!

    Why do I get get a NullPointerException here??
    public static void storeSettings() {
    try {
    File file = new File( System.getProperty("user.home"), "app.properties");
    FileOutputStream fos = new FileOutputStream(file);
    properties.store(fos, "Application Settings");
    fos.close();
    The NullPointerException is throws on property.store...
    Somebody please help.... thx

    Try to print a stacktrace....
    public static void storeSettings() {
      try {
        File file = new File( System.getProperty("user.home"), "app.properties");
        FileOutputStream fos = new FileOutputStream(file);
        properties.store(fos, "Application Settings");
        fos.close();
      } catch(Exception e) {
          e.printStackTrace(System.out);

  • Properties.store produces question marks

    Hi all,
    I'm using java 1.4. My code needs to write a property file, with some user input that contains international chars. The code needs to handle input in all languages, regardless of the system global locale or encoding settings.
    I'm using:
    props.setProperty("x", "<some international string>");
    props.store(myFileStream);I expected the output to be something like:
    x=\u1234\u4321...
    But the output in the file is:
    x=?????
    On the other hand, if I manually create the prop file like so:
    x=\u1234\u4321...
    Then the following code works as needed:
    props.load(myFileStream)
    props.getProperty("x")How do I make Properties.store behave as expected?

    I can't reproduce this here:
    this SSCCE:
    package snippet;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class SSCCE {
         public static void main(final String[] args) throws IOException {
              Properties prop = new Properties()
              prop.put("foo", "&#3585;&#3586;&#3587;");
              FileOutputStream os = new FileOutputStream("foo.properties");
              prop.store(os, "foo");
              os.close();
    }Produces this output for me:
    #foo
    #Thu Oct 22 16:14:45 CEST 2009
    foo=\u0E01\u0E02\u0E03Where do you get your String from? Is it in the .java source file? If so, do you compile your code with the correct source encoding?
    Edit: and do you use an OutputStream or a Writer? I.e. what type is myFileStream?

  • Private Room throws NullPointerException

    Hi,
    I have created a private room and it was sucessfull. i am able to see the room without any problem. but when others(non-members) go to their rooms directory, it throws NullPointerException. This problem is only for private rooms only.
    we are using SP 17
    The exception is
    java.lang.NullPointerException
         at com.sap.ip.collaboration.roomui.api.util.properties.RoomResourceProperties.getPropertyValueAsString(RoomResourceProperties.java:53)
         at com.sap.ip.collaboration.roomui.api.util.properties.RoomResourceProperties.getRoomPrivacy(RoomResourceProperties.java:33)
         at com.sap.netweaver.coll.roomui.api.uicommands.UIRequestMembershipCommand.isExecutable(UIRequestMembershipCommand.java:67)
         at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceCommands(UIGroupCommand.java:78)
         at  ..............
    can anyone reply what might be the reason be?
    Thank you.
    Saravana.
    Edited by: Saravana Parthiban Palaniswamy on Feb 4, 2009 1:22 PM
    Edited by: Saravana Parthiban Palaniswamy on Feb 4, 2009 1:26 PM

    Hi,
    If u goes to room directory in collaboration, there is a tab called Restricted Rooms. End of the room name there is context menu if u click that, it will show the menu there you can see the option called “Request Membership”. If you click that, corresponding room owner will receive the mail if he/she enabled the mail properties.
    If the answer helps your Question, provide the points.
    Regards,
    Kathiresan R

  • CreateEntityManagerFactory throws NullPointerException for ejb3 jse client

    This question has been posted to the Toplink/jpa forum without any reply.
    Dear experts!
    I am trying to create a java standard edition client, to test outside the weblogic server, my ejb 3 entities, declared as shown in the following persistence.xml.
    The java code follows also. I have read about some relevant bugs in eclipselink back in 2006, or 7 or 8 and mostly unanswered threads :
    CreateEntityManagerFactory null pointer exception and
    Returned null to createEntityManagerFactory about tomcat and oc4j.
    Persistence.createEntityManagerFactory() throw NullPointerException in oc4j
    I am using JDeveloper 11g Studio Edition Version 11.1.1.3.0, Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
    Any helping hand available?
    Thank you very much in advance!
    NA
    package chapter12javaseclient;
    import actionbazaar.buslogic.BidException;
    import actionbazaar.persistence.Bid;
    import actionbazaar.persistence.Bidder;
    import actionbazaar.persistence.Item;
    import java.util.HashMap;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import org.eclipse.persistence.config.EntityManagerProperties;
    public class PlaceBidBeanJavaSE {
    private static EntityManagerFactory emf;
    private static EntityManager em;
    public static void main(String[] args) {
    String userId= "idiot";
    Long itemId = new Long (1);
    Double bidPrice = 2001.50;
    try {
    if (emf == null){
    emf = Persistence.createEntityManagerFactory("actionBazaar");
    System.out.println("EntityManagerFactory created!");
    getEntityManager();
    System.out.println("EntityManager created!");
    addBid(userId,itemId,bidPrice);
    commitTransaction();
    } finally {
    // close the EntityManager when done
    em.close();
    emf.close();
    private static void getEntityManager() {
    HashMap emProps = new HashMap();
    emProps.put(EntityManagerProperties.JDBC_USER, "ab");
    emProps.put(EntityManagerProperties.JDBC_PASSWORD, "ab");
    System.out.println("Creating entity manager");
    em = emf.createEntityManager(emProps);
    em.getTransaction().begin();
    private static void commitTransaction() {
    em.getTransaction().commit();
    private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
    Item item = em.find(Item.class,itemId);
    if (item == null)
    throw new BidException("Invalid Item Id");
    Bidder bidder = em.find(Bidder.class,userId);
    if (bidder == null)
    throw new BidException("Invalid Bidder Id");
    Bid bid = new Bid();
    bid.setItem(item);
    bid.setBidBidder(bidder);
    bid.setBidPrice(bidPrice);
    em.persist(bid);
    return bid.getBidId();
    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>actionbazaar.persistence.Bid</class>
    <class>actionbazaar.persistence.Item</class>
    <class>actionbazaar.persistence.User</class>
    <class>actionbazaar.persistence.Bidder</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
    <property name="eclipselink.target-server" value="WebLogic_10"/>
    <property name="eclipselink.target-database" value="Oracle11"/>
    <property name="javax.persistence.jdbc.driver"
    value="oracle.jdbc.OracleDriver"/>
    <property name="javax.persistence.jdbc.password"
    value="ab"/>
    <property name="javax.persistence.jdbc.url"
    value="jdbc:oracle:thin:@hera:1521:orcl"/>
    <property name="javax.persistence.jdbc.user" value="ab"/>
    <property name="eclipselink.logging.level" value="ALL"/>
    </properties>
    </persistence-unit>
    </persistence>

    A solution might be found here:
    Re: createEntityManagerFactory() throws NullPointerException for ejb jse client
    Re: createEntityManagerFactory() throws NullPointerException for ejb jse client
    NA
    [http://nickaiva.blogspot.com/]

  • CreateEntityManagerFactory() throws NullPointerException for ejb jse client

    Dear experts!
    I am trying to create a java standard edition client, to test outside the weblogic server, my ejb 3 entities, declared as shown in the following persistence.xml.
    The java code, and stacktrace follows also. I have read about some relevant bugs in eclipselink back in 2006, or 7 or 8 and mostly unanswered threads :
    CreateEntityManagerFactory null pointer exception and
    Returned null to createEntityManagerFactory about tomcat and oc4j.
    Persistence.createEntityManagerFactory() throw NullPointerException in oc4j
    I am using JDeveloper 11g Studio Edition Version 11.1.1.3.0, Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
    Any helping hand available?
    Thank you very much in advance!
    NA
    package chapter12javaseclient;
    import actionbazaar.buslogic.BidException;
    import actionbazaar.persistence.Bid;
    import actionbazaar.persistence.Bidder;
    import actionbazaar.persistence.Item;
    import java.util.HashMap;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import org.eclipse.persistence.config.EntityManagerProperties;
    public class PlaceBidBeanJavaSE {
    private static EntityManagerFactory emf;
    private static EntityManager em;
    public static void main(String[] args) {
    String userId= "idiot";
    Long itemId = new Long (1);
    Double bidPrice = 2001.50;
    try {
    if (emf == null){
    emf = Persistence.createEntityManagerFactory("actionBazaar");
    System.out.println("EntityManagerFactory created!");
    getEntityManager();
    System.out.println("EntityManager created!");
    addBid(userId,itemId,bidPrice);
    commitTransaction();
    } finally {       
    // close the EntityManager when done
    em.close();
    emf.close();
    private static void getEntityManager() {
    HashMap emProps = new HashMap();
    emProps.put(EntityManagerProperties.JDBC_USER, "ab");
    emProps.put(EntityManagerProperties.JDBC_PASSWORD, "ab");
    System.out.println("Creating entity manager");
    em = emf.createEntityManager(emProps);
    em.getTransaction().begin();
    private static void commitTransaction() {
    em.getTransaction().commit();
    private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
    Item item = em.find(Item.class,itemId);
    if (item == null)
    throw new BidException("Invalid Item Id");
    Bidder bidder = em.find(Bidder.class,userId);
    if (bidder == null)
    throw new BidException("Invalid Bidder Id");
    Bid bid = new Bid();
    bid.setItem(item);
    bid.setBidBidder(bidder);
    bid.setBidPrice(bidPrice);
    em.persist(bid);
    return bid.getBidId();
    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>actionbazaar.persistence.Bid</class>
    <class>actionbazaar.persistence.Item</class>
    <class>actionbazaar.persistence.User</class>
    <class>actionbazaar.persistence.Bidder</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
    <property name="eclipselink.target-server" value="WebLogic_10"/>
    <property name="eclipselink.target-database" value="Oracle11"/>
    <property name="javax.persistence.jdbc.driver"
    value="oracle.jdbc.OracleDriver"/>
    <property name="javax.persistence.jdbc.password"
    value="ab"/>
    <property name="javax.persistence.jdbc.url"
    value="jdbc:oracle:thin:@hera:1521:orcl"/>
    <property name="javax.persistence.jdbc.user" value="ab"/>
    <property name="eclipselink.logging.level" value="ALL"/>
    </properties>
    </persistence-unit>
    </persistence>
    The log output follows:
    C:\Oracle\Middleware\jdev_11gR1\jdk160_18\bin\javaw.exe -client -classpath C:\MyWork\11g\ejb3inaction\.adf;C:\MyWork\11g\ejb3inaction\Chapter12JavaSEClient\classes;C:\MyWork\11g\ejb3inaction\Chapter12\classes;C:\Oracle\Middleware\jdev_11gR1\modules\javax.ejb_3.0.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\com.oracle.toplink_1.0.0.0_11-1-1-3-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\org.eclipse.persistence_1.0.0.0_2-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\com.bea.core.antlr.runtime_2.7.7.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.toplink_11.1.1\javax.persistence_2.0_preview.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.xdk_11.1.0\xmlparserv2.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.xdk_11.1.0\xml.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jsf_1.0.0.0_1-2.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.enterprise.deploy_1.2.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.interceptor_1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jms_1.1.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jsp_1.1.0.0_2-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jws_2.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.activation_1.1.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.mail_1.1.0.0_1-4-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.soap_1.3.1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.rpc_1.2.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.ws_2.1.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.management.j2ee_1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.resource_1.5.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.servlet_1.0.0.0_2-5.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.transaction_1.0.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.stream_1.1.1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.security.jacc_1.0.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.registry_1.0.0.0_1-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.persistence_1.0.0.0_1-0-2.jar;C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\ext\jdbc\oracle\11g\ojdbc6.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-collation.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-lcsd.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-mapping.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-servlet.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-translation.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-utility.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.odl_11.1.1\ojdl.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.dms_11.1.1\dms.jar -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\lib\DemoTrust.jks chapter12javaseclient.PlaceBidBeanJavaSE
    [EL Finest]: 2010-06-25 09:23:10.495--ServerSession(229902)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit actionBazaar; session file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/_actionBazaar; state Initial; factoryCount 0
    [EL Finest]: 2010-06-25 09:23:10.518--ServerSession(229902)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
    [EL Finer]: 2010-06-25 09:23:10.532--ServerSession(229902)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/
    [EL Finer]: 2010-06-25 09:23:10.537--ServerSession(229902)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/
    [EL Config]: 2010-06-25 09:23:10.652--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Item] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.696--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to many mapping element [method getCategorySet] is being defaulted to: class actionbazaar.persistence.Category.
    [EL Config]: 2010-06-25 09:23:10.702--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getBids] is being defaulted to: class actionbazaar.persistence.Bid.
    [EL Config]: 2010-06-25 09:23:10.71--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getSeller] is being defaulted to: class actionbazaar.persistence.Seller.
    [EL Config]: 2010-06-25 09:23:10.71--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.User] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.711--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getCategories] is being defaulted to: class actionbazaar.persistence.Category.
    [EL Config]: 2010-06-25 09:23:10.716--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [method getBillingInfo] is being defaulted to: class actionbazaar.persistence.BillingInfo.
    [EL Config]: 2010-06-25 09:23:10.717--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [method getContactInfo] is being defaulted to: class actionbazaar.persistence.ContactInfo.
    [EL Config]: 2010-06-25 09:23:10.718--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Bidder] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.72--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getBids] is being defaulted to: class actionbazaar.persistence.Bid.
    [EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Bid] is set to [PROPERTY].
    [EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getBidBidder] is being defaulted to: class actionbazaar.persistence.Bidder.
    [EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getItem] is being defaulted to: class actionbazaar.persistence.Item.
    [EL Config]: 2010-06-25 09:23:10.722--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Item] is being defaulted to: Item.
    [EL Config]: 2010-06-25 09:23:10.746--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Bidder] is being defaulted to: Bidder.
    [EL Config]: 2010-06-25 09:23:10.746--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.User] is being defaulted to: User.
    [EL Config]: 2010-06-25 09:23:10.753--ServerSession(229902)--Thread(Thread[main,5,main])--The table name for entity [class actionbazaar.persistence.Bidder] is being defaulted to: USERS.
    [EL Config]: 2010-06-25 09:23:10.753--ServerSession(229902)--Thread(Thread[main,5,main])--The discriminator column name for the root inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: DTYPE.
    [EL Config]: 2010-06-25 09:23:10.755--ServerSession(229902)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: USER_ID.
    [EL Config]: 2010-06-25 09:23:10.755--ServerSession(229902)--Thread(Thread[main,5,main])--The foreign key column name for the inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: USER_ID.
    [EL Config]: 2010-06-25 09:23:10.758--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Bid] is being defaulted to: Bid.
    Exception in thread "main" java.lang.NullPointerException
         at chapter12javaseclient.PlaceBidBeanJavaSE.main(PlaceBidBeanJavaSE.java:43)
    Process exited with exit code 1.

    Thank you for your reply!
    The client now works correctly. It seems that the line
    em = emf.createEntityManager(emProps);//
    throws an exception when no argument is given for em = emf.createEntityManager();// emProps missing!
    There was also a warning in jdev editor, about the line you mentioned:
    <property name="eclipselink.target-server" value="WebLogic 10"/>
    Carry on with your good work!
    The updated persistence.xml and java source code shown below:
    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>actionbazaar.persistence.Bid</class>
    <class>actionbazaar.persistence.Item</class>
    <class>actionbazaar.persistence.User</class>
    <class>actionbazaar.persistence.Bidder</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
    <property name="eclipselink.target-database" value="Oracle11"/>
    <property name="javax.persistence.jdbc.driver"
    value="oracle.jdbc.OracleDriver"/>
    <property name="javax.persistence.jdbc.password"
    value="29E8BD11B89A62E3862F19C4F84B7DB0"/>
    <property name="javax.persistence.jdbc.user" value="ab"/>
    <property name="eclipselink.logging.level" value="ALL"/>
    <property name="eclipselink.orm.validate.schema" value="true"/>
    <property name="javax.persistence.jdbc.url"
    value="jdbc:oracle:thin:@hera:1521:orcl"/>
    </properties>
    </persistence-unit>
    </persistence>
    package chapter12javaseclient;
    import actionbazaar.buslogic.BidException;
    import actionbazaar.persistence.Bid;
    import actionbazaar.persistence.Bidder;
    import actionbazaar.persistence.Item;
    import java.util.HashMap;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import org.eclipse.persistence.config.EntityManagerProperties;
    public class PlaceBidBeanJavaSE {
    private static EntityManagerFactory emf;
    private static EntityManager em;
    private static Hashtable emProps = new Hashtable();
    public static void main(String[] args) {
    String userId= "idiot";
    Long itemId = new Long (2);
    Double bidPrice = 2002.50;
    try {
    if (emf == null){
    emf = Persistence.createEntityManagerFactory("actionBazaar");
    System.out.println("EntityManagerFactory created!");
    getEntityManager();
    System.out.println("EntityManager created!");
    addBid(userId,itemId,bidPrice);
    commitTransaction();
    } finally {       
    // close the EntityManager when done
    em.close();
    emf.close();
    private static void getEntityManager() {
    try {
    System.out.println("Creating entity manager");
    em = emf.createEntityManager(emProps);// if argument is missing exception is thrown!
    em.getTransaction().begin();
    } catch (Exception ne) {
    // TODO: Add catch code
    ne.printStackTrace();
    private static void commitTransaction() {
    em.getTransaction().commit();
    private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
    Item item = em.find(Item.class,itemId);
    if (item == null)
    throw new BidException("Invalid Item Id");
    Bidder bidder = em.find(Bidder.class,userId);
    if (bidder == null)
    throw new BidException("Invalid Bidder Id");
    Bid bid = new Bid();
    bid.setItem(item);
    bid.setBidBidder(bidder);
    bid.setBidPrice(bidPrice);
    em.persist(bid);
    return bid.getBidId();
    NA
    [http://nickaiva.blogspot.com/]

  • Properties.store(OutputStream) destroys order and comments of *.properties

    Hi!
    After searching for hours in different forums I have come to the point, that either
    1)I'm not good in searching forums
    2)This problem has not been discussed yet
    no 1 seems much more likely...
    So, here it it is:
    I'm trying to implement a kind of property-loader which loads keys from a text file (in my case called *.properties file) into the java.util.properties class, manipulates it, and then stores it again.
    Apart from my manipulation, I want the *.properties file to stay exactly the same.
    As I have it now store(FileOutputStream) seems to changes many things in the file: It adds the date, deletes the comments, changes the order of the keys
    Here is the test code:
    public class IoTestMain {
         public static void main(String[] args)
             Properties properties = new Properties();
             try {
                 properties.load(new FileInputStream("C:\\eclipse\\workspace\\IoTest\\iotest\\filename.properties"));
                 properties.setProperty("Test1","1");            
             } catch (IOException e) {
                  e.printStackTrace();
             try {
                 properties.store(new FileOutputStream("C:\\eclipse\\workspace\\IoTest\\iotest\\filename.properties"),null);
             } catch (IOException e) {
                  e.printStackTrace();
    }This changes my "beautiful" filename.properties file from
    [filestart]
    Test2=1
    #comment
    !comment
    Test1=2
    [fileend]
    to that:
    [filestart]
    #Wed Sep 14 12:23:10 CEST 2005
    Test1=1
    Test2=1
    [fileend]
    I'd like to have a properties file with comments and defined order. Does someone have suggestions?
    Regards
    Phil

    Properties is not meant to keep the order of it's entries or comments. It's a very simple tools for very simple requirements. It provides only the very simple function of mapping keys to strings, no fancy "keep the format when storing" and no "remember the comments to write it back".
    Ceci hinted at java.util.prefs.Preferences as the prefered way to store user preferences ('though I've never used it, so I can't comment on it).

  • XMLBean.validate() throws NullPointerException

    I have an XML file that is valid against a schema. I created the XMLBeans for the schema and can create (in code) the XMLBean and call .validate() on the XMLBean and it is in fact valid. I can also validate the XML file just fine.
    I then send that XMLBean (either loaded from a file or created in code) (as a string of XML) to an EJB. The EJB creates the XMLBean successfully, but when it calls .validate() it throws a NullPointerException. Here is the stack trace:
    Valid: true
    Exception in thread "main" java.rmi.RemoteException: EJB Exception: ; nested exc
    eption is:
    java.lang.NullPointerException
    at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.j
    ava:108)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
    ef.java:284)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
    ef.java:244)
    at aaa.bbb.ccc.ddd.ejb.FOOCatalog_2fiik0_EOImpl_813_WLStub.create(
    Unknown Source)
    at aaa.bbb.ccc.ddd.CatalogProxy.create(FooCatalogProxy.java:234)
    at FooPublish.main(MDCPublish.java:137)
    Caused by: java.lang.NullPointerException
    at com.bea.xbean.validator.Validator.beginEvent(Validator.java:331)
    at com.bea.xbean.validator.Validator.nextEvent(Validator.java:187)
    at com.bea.xbean.store.Saver$ValidatorSaver.emitEvent(Saver.java:3757)
    at com.bea.xbean.store.Saver$ValidatorSaver.emitEvent(Saver.java:3720)
    at com.bea.xbean.store.Saver$ValidatorSaver.emitContainer(Saver.java:364
    2)
    at com.bea.xbean.store.Saver.processContainer(Saver.java:775)
    at com.bea.xbean.store.Saver.process(Saver.java:518)
    at com.bea.xbean.store.Saver$ValidatorSaver.<init>(Saver.java:3546)
    at com.bea.xbean.store.Type.validate(Type.java:280)
    at com.bea.xbean.values.XmlObjectBase.validate(XmlObjectBase.java:310)
    Any ideas?
    Thanks

    The problem was that the weblogic server had a previously-compiled version of the same XMLBean in its classpath. Once I removed the old XMLBean from the classpath the problem went away.

  • Persistence.createEntityManagerFactory() throw NullPointerException in oc4j

    Hi,
    I am trying to use JPA(toplink essential) with EJB 2.0 spec using the DAO pattern. Outside the oc4j container all my DAO unit tests passes but when I run the same code inside oc4j the Persistence.createEntityManagerFactory() method throws a NPE. I verified that META-INF/persistence.xml file is available through the classpath inside the container but I don’t see any toplink specific logs in oc4j. Do I need to do anything to tell oc4j load up persistence.xml? I have been trying many different options in persistence.xml but I always get the same exception. Any help will be appreciated.
    Code:
    Persistence.createEntityManagerFactory(“default”, new HashMap());
    Exception:
    07/07/06 17:25:21 java.lang.NullPointerException
    07/07/06 17:25:21 at oracle.toplink.essentials.ejb.cmp3.EntityManagerFacto
    ryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:120)
    07/07/06 17:25:21 at javax.persistence.Persistence.createEntityManagerFact
    ory(Persistence.java:59)
    07/07/06 17:25:21 at com.retek.rib.domain.hospital.dao.toplink.ToplinkSess
    ionDispenser.currentEntityManager(ToplinkSessionDispenser.java:31)
    Config File:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:
    xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.
    sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_
    0.xsd">
    <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
    <!--persistence-unit name="ribPersistenceUnit" transaction-type="JTA"-->
    <!--provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
    </provider-->
    <provider>
    oracle.toplink.essentials.PersistenceProvider
    </provider>
    <!--jta-data-source>jdbc/OracleRibDs</jta-data-source-->
    <class>com.retek.rib.domain.hospital.bo.impl.HospitalEntryImpl</class>
    <class>com.retek.rib.domain.ribmessage.bo.impl.RibMessageFailureImpl</class>
    <class>com.retek.rib.domain.ribmessage.bo.impl.RibMessageRoutingInfoImpl</class>
    <class>com.retek.rib.domain.ribmessage.bo.impl.RibMessageHospitalRefImpl</class>
    <!--properties>
    <property name="toplink.jdbc.url" value="jdbc:derby://localhost:1527/testD
    B"/>
    <property name="toplink.jdbc.user" value="APP"/>
    <property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.ClientDr
    iver"/>
    <property name="toplink.jdbc.password" value="APP"/>
    </properties-->
    <properties>
    <property name="toplink.jdbc.url" value="jdbc:oracle:thin:@pbora-lnx:1521:
    orcl"/>
    <property name="toplink.jdbc.user" value="stubby2"/>
    <property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDrive
    r"/>
    <property name="toplink.jdbc.password" value="retek"/>
    <property name="toplink.logging.level" value="FINE"/>
    </properties>
    <!--properties>
    <!--property name="toplink.server.platform.class.name" value="oracle.topli
    nk.essentials.platform.server.oc4j.Oc4jPlatform"/- ->
    <property name="toplink.logging.level" value="FINE"/>
    </properties-->
    </persistence-unit>
    </persistence>

    Hi,
    I am trying to use JPA(toplink essential) with EJB 2.0 spec using the DAO pattern. Outside the oc4j container all my DAO unit tests passes but when I run the same code inside oc4j the Persistence.createEntityManagerFactory() method throws a NPE. I verified that META-INF/persistence.xml file is available through the classpath inside the container but I don’t see any toplink specific logs in oc4j. Do I need to do anything to tell oc4j load up persistence.xml? I have been trying many different options in persistence.xml but I always get the same exception. Any help will be appreciated.
    Code:
    Persistence.createEntityManagerFactory(“default”, new HashMap());
    Exception:
    07/07/06 17:25:21 java.lang.NullPointerException
    07/07/06 17:25:21 at oracle.toplink.essentials.ejb.cmp3.EntityManagerFacto
    ryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:120)
    07/07/06 17:25:21 at javax.persistence.Persistence.createEntityManagerFact
    ory(Persistence.java:59)
    07/07/06 17:25:21 at com.retek.rib.domain.hospital.dao.toplink.ToplinkSess
    ionDispenser.currentEntityManager(ToplinkSessionDispenser.java:31)
    Config File:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:
    xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.
    sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_
    0.xsd">
    <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
    <!--persistence-unit name="ribPersistenceUnit" transaction-type="JTA"-->
    <!--provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
    </provider-->
    <provider>
    oracle.toplink.essentials.PersistenceProvider
    </provider>
    <!--jta-data-source>jdbc/OracleRibDs</jta-data-source-->
    <class>com.retek.rib.domain.hospital.bo.impl.HospitalEntryImpl</class>
    <class>com.retek.rib.domain.ribmessage.bo.impl.RibMessageFailureImpl</class>
    <class>com.retek.rib.domain.ribmessage.bo.impl.RibMessageRoutingInfoImpl</class>
    <class>com.retek.rib.domain.ribmessage.bo.impl.RibMessageHospitalRefImpl</class>
    <!--properties>
    <property name="toplink.jdbc.url" value="jdbc:derby://localhost:1527/testD
    B"/>
    <property name="toplink.jdbc.user" value="APP"/>
    <property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.ClientDr
    iver"/>
    <property name="toplink.jdbc.password" value="APP"/>
    </properties-->
    <properties>
    <property name="toplink.jdbc.url" value="jdbc:oracle:thin:@pbora-lnx:1521:
    orcl"/>
    <property name="toplink.jdbc.user" value="stubby2"/>
    <property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDrive
    r"/>
    <property name="toplink.jdbc.password" value="retek"/>
    <property name="toplink.logging.level" value="FINE"/>
    </properties>
    <!--properties>
    <!--property name="toplink.server.platform.class.name" value="oracle.topli
    nk.essentials.platform.server.oc4j.Oc4jPlatform"/- ->
    <property name="toplink.logging.level" value="FINE"/>
    </properties-->
    </persistence-unit>
    </persistence>

  • DefaultTreeModel.removeNodeFromParent throwing NullPointerException

    I have an applet which involves editing data represented by a JTree. However, I'm getting this exception when I try to remove a node from the tree (to move it by subsequently inserting it at +/-1 position):
    java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicTreeUI.completeEditing(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI.completeEditing(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI$TreeSelectionHandler.valueChanged(Unknown Source)
    at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source)
    at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source)
    at javax.swing.tree.DefaultTreeSelectionModel.removeSelectionPaths(Unknown Source)
    at javax.swing.JTree.removeDescendantSelectedPaths(Unknown Source)
    at javax.swing.JTree.removeDescendantSelectedPaths(Unknown Source)
    at javax.swing.JTree$TreeModelHandler.treeNodesRemoved(Unknown Source)
    at javax.swing.tree.DefaultTreeModel.fireTreeNodesRemoved(Unknown Source)
    at javax.swing.tree.DefaultTreeModel.nodesWereRemoved(Unknown Source)
    at javax.swing.tree.DefaultTreeModel.removeNodeFromParent(Unknown Source)
    at ...[my code from here]This is the code that moves the node:
    DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)myTree.getLastSelectedPathComponent();
    factbookTree.setEnabled(false);
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode)selectedNode.getParent();
    DefaultTreeModel treeModel = (DefaultTreeModel)factbookTree.getModel();
    int oldIndex = treeModel.getIndexOfChild(parent,selectedNode);
    int newIndex = oldIndex + move;
    //throws exception here:
    treeModel.removeNodeFromParent(selectedNode);
    //This also causes exception:
    //parent.remove(selectedNode);
    //treeModel.nodesWereRemoved(parent, new int[] {oldIndex}, new Object[] {selectedNode});Any ideas as to what the problem is?
    It started throwing this error when I changed my objects overriding JTree and TreeNode, but I'm not doing anything far out here, just getting the CellRenderer to include a JCheckBox and adding code to store the state of the JCheckBox. There is no multithreading that I'm adding. The node is being visibly removed from the applet before the exception. My only thought was that I needed to initialise the tree model somwhere myself - the tree is being constructed by passing it the root node.
    I'm using JDK 1.4.1 as a JApplet with the Java Plug-In on W2K.
    cheers,
    Andy

    Yeah, I checked that it wasn't null. I've hacked the code down and here's a complete listing which shows the problem, apologies for dodgy formatting. The code is modified from the JCheckTree implementation I found at http://www.fawcette.com/archives/premier/mgznarch/javapro/2001/01jan01/vc0101/vc0101.asp
    // FactbookBrowser.java
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class FactbookBrowser extends JApplet implements ActionListener {
         JButton upButton;
         JButton downButton;
         JCheckTree factbookTree;
         public FactbookBrowser() {
              //Set up the tree display
              CheckTreeNode root = new CheckTreeNode("Root");
              CheckTreeNode one = new CheckTreeNode("one");
              CheckTreeNode two = new CheckTreeNode("two");
              CheckTreeNode three = new CheckTreeNode("three");
              root.add(one);
              root.add(two);
              root.add(three);
              factbookTree = new JCheckTree(root);
              factbookTree.getSelectionModel().setSelectionMode(
                   TreeSelectionModel.SINGLE_TREE_SELECTION
              factbookTree.putClientProperty("JTree.lineStyle", "Angled");
              JPanel moveButtons = new JPanel();
              upButton = new JButton("up");
              downButton = new JButton("down");
              moveButtons.add(upButton);
              moveButtons.add(downButton);
              upButton.addActionListener(this);
              downButton.addActionListener(this);
              //Add everything to scrollpanes, split panes and this
              JScrollPane treeScroll = new JScrollPane(factbookTree);
              JPanel treePanel = new JPanel();
              treePanel.setLayout(new BorderLayout());
              treePanel.add(treeScroll, BorderLayout.CENTER);
              treePanel.add(moveButtons, BorderLayout.SOUTH);
              this.getContentPane().setLayout(new BorderLayout());
              this.getContentPane().add(treePanel, BorderLayout.CENTER);
         private void moveNode(int move) {
              DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)factbookTree.getLastSelectedPathComponent();
            if ((move == -1) && (selectedNode.getPreviousSibling() == null)) {
                   System.out.println("Node already at start of section, can't move up");
                   return;
              } else if ((move == 1) && (selectedNode.getNextSibling() == null)) {
                   System.out.println("Node already at end of section, can't move down");
                   return;
              } else if ((move != 1) && (move != -1)) {
                   System.out.println("Can't move node more than one place");
                   return;
              DefaultMutableTreeNode parent = (DefaultMutableTreeNode)selectedNode.getParent();
              DefaultTreeModel treeModel = (DefaultTreeModel)factbookTree.getModel();
              int oldIndex = treeModel.getIndexOfChild(parent,selectedNode);
              int newIndex = oldIndex + move;
    System.out.println("*** treeModel:"+treeModel+" selectedNode:"+selectedNode+" new index:"+newIndex);
    //@todo Throwing exception here! WHY?
              treeModel.removeNodeFromParent(selectedNode);
              //parent.remove(selectedNode);
              //treeModel.nodesWereRemoved(parent, new int[] {oldIndex}, new Object[] {selectedNode});
    System.out.println("*** Removed node, inserting");
              treeModel.insertNodeInto(selectedNode,parent,newIndex);
    System.out.println("*** Inserted Node");
              TreePath newPath = new TreePath(selectedNode.getPath());
              factbookTree.scrollPathToVisible(newPath);
              factbookTree.setSelectionPath(newPath);
              factbookTree.repaint();
         public void actionPerformed(ActionEvent ae) {
              if (ae.getSource() == upButton) {
                   //Move the currently selected node up within its folder
                   moveNode(-1);
              } else if (ae.getSource() == downButton) {
                   //Move the currently selected node up within its folder
                   moveNode(1);
        public static void main(String[] args) {
            FactbookBrowser browser = new FactbookBrowser();
    // JCheckTree.java
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    public class JCheckTree extends JTree {
      public JCheckTree(TreeNode root) {
        super(root);
        super.setCellRenderer(new CheckTreeCellRenderer(this));
        setCellEditor(new CheckTreeCellEditor(this));
        setEditable(true);
      public void setCellRenderer(TreeCellRenderer renderer) {
        super.setCellRenderer(new CheckTreeCellRenderer(this, renderer));
      public void setEditorRenderer(TreeCellRenderer renderer) {
        setCellEditor(new CheckTreeCellEditor(this, renderer));
    // CheckTreeNode.java
    import java.util.*;
    import javax.swing.tree.*;
    public class CheckTreeNode extends DefaultMutableTreeNode {
         protected boolean selected, propagate;
         public CheckTreeNode(Object data) {
              this(data, false, true);
         public CheckTreeNode(Object data, boolean selected) {
              this(data, selected, true);
         public CheckTreeNode(Object data, boolean selected, boolean propagate) {
              super(data);
              this.selected = selected;
              this.propagate = propagate;
         public boolean isSelected() {
              return selected;
         public void setSelected(boolean selected) {
              this.selected = selected;
              if (propagate)
              propagateSelected(selected);
         public void propagateSelected(boolean selected) {
              Enumeration enum = children();
              while (enum.hasMoreElements()) {
                   CheckTreeNode node = (CheckTreeNode)enum.nextElement();
                   node.setSelected(selected);
         public void setUserObject(Object obj) {
              if (obj == this) return;
              super.setUserObject(obj);
    // CheckTreeCellRenderer.java
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    public class CheckTreeCellRenderer extends JPanel implements TreeCellRenderer {
         protected CheckTreeNode node;
         protected TreeCellRenderer renderer;
         protected JCheckBox check;
         public CheckTreeCellRenderer(JTree tree) {
              this(tree, new DefaultTreeCellRenderer());
         public CheckTreeCellRenderer(JTree tree, TreeCellRenderer renderer) {
              setLayout(new BorderLayout());
              this.renderer = renderer;
              add(BorderLayout.CENTER,
              renderer.getTreeCellRendererComponent(tree, "", true, true, true, 0, true));
              check = new JCheckBox();
              add(BorderLayout.WEST, check);
         public Component getTreeCellRendererComponent(JTree tree,
                                  Object value,
                                  boolean selected,
                                  boolean expanded,
                                  boolean leaf,
                                  int row,
                                  boolean hasFocus) {
              if (value instanceof CheckTreeNode) {
                   node = (CheckTreeNode)value;
                   check.setSelected(node.isSelected());
                   value = node.getUserObject();
              renderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
              return this;
    // CheckTreeCellEditor.java
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class CheckTreeCellEditor extends CheckTreeCellRenderer implements TreeCellEditor, ActionListener {
      protected CellEditorListener list;
      public CheckTreeCellEditor(JTree tree)
        this(tree, new DefaultTreeCellRenderer());
      public CheckTreeCellEditor(JTree tree, TreeCellRenderer renderer)
        super(tree, renderer);
        check.addActionListener(this);
      public Component getTreeCellEditorComponent(
        JTree tree, Object value, boolean selected,
        boolean expanded, boolean leaf, int row)
        return getTreeCellRendererComponent(
          tree, value, true, expanded, leaf, row, true);
      public boolean stopCellEditing()
        return true;
      public Object getCellEditorValue()
        node.setSelected(check.isSelected());
        return node;
      public boolean isCellEditable(EventObject event)
        return true;
      public boolean shouldSelectCell(EventObject event)
        return true;
      public void  cancelCellEditing()
        fireEditingCanceled();
         HashSet listeners = new HashSet();
      public void addCellEditorListener(CellEditorListener listener) {
        listeners.add(listener);
      public void removeCellEditorListener(CellEditorListener listener) {
        listeners.remove(listener);
      protected void fireEditingStopped() {
         Iterator i = listeners.iterator();
         while (i.hasNext()) {
              ((CellEditorListener)i.next()).editingStopped(new ChangeEvent(this));
      protected void fireEditingCanceled() {
         Iterator i = listeners.iterator();
         while (i.hasNext()) {
              ((CellEditorListener)i.next()).editingCanceled(new ChangeEvent(this));
      public void actionPerformed(ActionEvent event) {
        fireEditingStopped();
    }

  • Weblogic throws NullPointerException when using ServiceControl.setTimeout

    We are invoking a SOAP service via a com.bea.control.ServiceControl that was generated from a WSDL (right click WSDL, Generate Service Control) using Weblogic 8.1.6.
    SOAP service execution is successful using an http and https endpoint. However, when setting a timeout via ServiceControl.setTimeout(int millisecods) method, the Weblogic API is throwing a NullPointerException when using an https endpoint. When using an http endpoint with the setTimeout method execution is successful.
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: opening connection to https://[... edit removed ...]
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: Response generation exception
    Throwable: java.lang.NullPointerException
    Stack Trace:
    java.lang.NullPointerException
         at weblogic.net.http.HttpsClient.openWrappedSSLSocket(HttpsClient.java:455)
         at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:235)
         at weblogic.net.http.HttpsClient.openServer(HttpsClient.java:389)
         at weblogic.net.http.HttpsClient.<init>(HttpsClient.java:209)
         at weblogic.net.http.HttpClient.New(HttpClient.java:228)
         at weblogic.net.http.HttpsURLConnection.getHttpClient(HttpsURLConnection.java:246)
         at weblogic.net.http.HttpsURLConnection.connect(HttpsURLConnection.java:217)
         at weblogic.net.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:189)
         at com.bea.wlw.runtime.jws.call.SoapHttpCall.invoke(SoapHttpCall.java:179)
         at com.bea.wlw.runtime.jws.call.SoapHttpCall.invoke(SoapHttpCall.java:80)
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1288)
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1155)
         at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
         at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:388)
    DEBUG com.bea.wlw.runtime.jws.call.SoapFault [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: SoapFault exception throwable e
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: response code=0, responseMsg=null
    DEBUG com.bea.wlw.runtime.jws.call.SoapHttpCall [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: closed connection to https://[... edit removed ...]
    WARN WLW.INVOKE.[... edit removed ...] [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: Id=[... edit removed id ...] Method=[... edit removed method ...]; Failure=com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.NullPointerException
    String:null
    Detail:
    END SERVICE FAULT
    ERROR [... edit removed ...]
    [ExecuteThread: '10' for queue: 'weblogic.kernel.Default']: ServiceControlException
    com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.NullPointerException
    String:null
    Detail:
    END SERVICE FAULT
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1268)
         at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
         at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:388)

    Thanks for the suggestion. But with -DUseSunHttpHandler=true the Weblogic API is throwing a ClassCastException with or without the timeout value set.
    Failure=com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.ClassCastException
    String:null
    Detail:
    END SERVICE FAULT
    ERROR: ServiceControlException
    com.bea.control.ServiceControlException: SERVICE FAULT:
    Code:java.lang.ClassCastException
    String:null
    Detail:
    END SERVICE FAULT
         at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:1268)
         at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
         at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
         at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:388)

  • Af:inputListOfValues without values throws NullPointerException

    Hello!
    In some cases we have an af:inputListOfValues without any values, due to restrictions in the query. Unfortunately, a NullPointerException is thrown in this case. Actually, we are using JDev 11.1.1.5.
    Is there any solution or workaround to allow empty af:inputListOfValues?
    Regards,
    Christoph
    Edited by: mephistopheles on Sep 3, 2012 11:47 PM

    Hi,
    can you verify with JDeveloper 11.1.1.6 and provide a reproducible set of steps if it reproduces? Also I am wondering if the NPE is throw when you close the LOV or when you submit the form later
    Frank

  • Edit locally throws NullPointerException

    Hi All,
    While doing EditLocally  in a Custom Repository Manager,it throws a null pointer Exception.
    As per the Repository Manager Implementation
    log ,we don’t any exception. So as there is no such relevent error realted to repository manager in default.trc file.
    RF doesn’t pass call to setContent() method of ContentManager.
    We failed to do so in Nw04 SPS11 and Nw04 SPS14.
    Where as we can able to edit successfully in NW04 SPS09.
    Regards
    Arati
    Following is the stack trace we got in iview of edit locally
    Please wait
    Your request is being processed
    System Error
    An exception occurred during the program execution. Below you will find technical information pertaining to this exception that you might want to forward to your system administrator.
    Exception Class 
    Call Stack java.lang.NullPointerException
            at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.renderLockedByUser(ResourceClientSideEditControl.java:1029)
            at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.renderIsLockedByOther(ResourceClientSideEditControl.java:344)
            at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.renderCurrentConditions(ResourceClientSideEditControl.java:302)
            at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.render(ResourceClientSideEditControl.java:191)
            at com.sapportals.wdf.layout.HorizontalLayout.renderControls(HorizontalLayout.java:42)
            at com.sapportals.wdf.stack.Pane.render(Pane.java:155)
            at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
            at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
            at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
            at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
            at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
            at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
            at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
            at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
            at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
            at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
            at com.sapportals.wdf.WdfCompositeController.internalRender(WdfCompositeController.java:696)
            at com.sapportals.wdf.WdfCompositeController.buildComposition(WdfCompositeController.java:664)
            at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
            at com.sapportals.htmlb.Container.preRender(Container.java:118)
            at com.sapportals.htmlb.Container.preRender(Container.java:118)
            at com.sapportals.htmlb.Container.preRender(Container.java:118)
            at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:413)
            at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:237)
            at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:130)
            at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:129)
            at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
            at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:73)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.doRefresh(AbstractPortalComponent.java:355)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:188)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
            at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
            at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
            at com.sapportals.portal.pb.IviewModeProxy.doContent(IviewModeProxy.java:20)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
            at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
            at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
            at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:646)
            at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
            at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
            at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
            at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
            at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
            at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
            at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
            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:95)
            at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
    Report Error

    Some more behavior of this problem
    1)when try to edit locally>file download started and open the file in approprite application>and in the KM iview got the null pointer exception(which usually have check in now, check in later, cancel local editing buttons)
    2) When resume local editing...nothing happens. Even doesn’t through error in iview
    3) when do a lock explicitly to any document- through selection->lock,it puts a check_out_by_me symbol rather than lock_by_me symbol
    Please any body help to resolve the issue,
    Regards
    arati

  • Starting soa_server1 server throws NullPointerException

    Hi
    I installed SOA Suite 11.1.1.2 on Oracle Red Hat 5. When I start soa_server1 for the first time I get:
    Caused By: java.lang.NullPointerException
    at oracle.fabric.BPELServiceEngine.getDaoFactory(BPELServiceEngine.java:
    105)
    at com.collaxa.cube.engine.CubeEngineBase.setCubeServiceEngine(CubeEngin
    eBase.java:230)
    at com.collaxa.cube.engine.CubeEngineBase.setServerManager(CubeEngineBas
    e.java:222)
    at com.collaxa.cube.admin.ServerManager.__init(ServerManager.java:130)
    at com.collaxa.cube.admin.ServerManager.init(ServerManager.java:117)
    Truncated. see log file for complete stacktrace
    Regards,
    Néstor Boscán

    Hi
    I installed SOA Suite 11.1.1.2 on Oracle Red Hat 5. When I start soa_server1 for the first time I get:
    Caused By: java.lang.NullPointerException
    at oracle.fabric.BPELServiceEngine.getDaoFactory(BPELServiceEngine.java:
    105)
    at com.collaxa.cube.engine.CubeEngineBase.setCubeServiceEngine(CubeEngin
    eBase.java:230)
    at com.collaxa.cube.engine.CubeEngineBase.setServerManager(CubeEngineBas
    e.java:222)
    at com.collaxa.cube.admin.ServerManager.__init(ServerManager.java:130)
    at com.collaxa.cube.admin.ServerManager.init(ServerManager.java:117)
    Truncated. see log file for complete stacktrace
    Regards,
    Néstor Boscán

  • HttpConnection throws NullPointerException

    Hi everybody !
    I'm faceing an odd problem here. I have developed an J2ME (MIDP1.0) application that, among other things, needs to comunicate with my server. The application woks fine on the emulator, it even works great on my phone (Nokia 2650) and on my partners phone (Nokia 6610), but when tested on other phones (SonyErricson, Sagem, Motorola, even an smartphone from Nokia, a 7610 i think) it throws a NullPointerException. I've run out of ideeas regading how to solve this. Here's the piece of code that bugs me:
    public void run(){
            Pachet raspuns = null;               
            display.setCurrent(forma);
            progress.setLabel("Trying to connect");       
            try {
                conn = (HttpConnection) Connector.open(URL, Connector.READ_WRITE);
                conn.setRequestMethod( HttpConnection.POST );
                conn.setRequestProperty("Content-Type", "application/vnd.wap.wmlc");
                byte[] dataForSend = deTrimis.getRawData();
                conn.setRequestProperty("Content-Length", ""+dataForSend.length);
                progress.setLabel("Sending request");
                progress.setValue(25);                      
                forma.append("Opening outputstream\n");
                os = conn.openOutputStream();
                forma.append("Sending data\n");           
                os.write( dataForSend );
                forma.append("Flushing data\n");           
                os.flush();      // this throws the exception
                forma.append("Closing stream\n");           
                os.close();    // if i remove the "os.flush()", the exception is thrown here
                forma.append("Getting response code\n");
                int code = conn.getResponseCode(); // if i remove both os.flush() and os.close() the exception is thrown here !!!
                forma.append("Response code = "+code+"\n");                          
                progress.setLabel("Checking response");
                progress.setValue(50);
                if (code != HttpConnection.HTTP_OK){
                     throw new Exception (conn.getResponseMessage()+"("+code+")");
                progress.setLabel("Reading data");
                progress.setValue(75);           
                if (!aborted){
                    dIn = conn.openDataInputStream();               
                    raspuns = new Pachet();
                    raspuns.readPackage(dIn);
                if (!aborted)
                    listener.packageReceived(raspuns);           
            } catch (Exception e) {
                forma.append("Connection failed. Reason: "+e.getMessage());           
                e.printStackTrace();
            } finally{
                cleanUp();
        }I really need to get this working, so could please someone give me a hint.
    Thank you,
    Daniel Comsa.

    Hi
    I solved this problem.
    There is nothing wrong with the device but the connection that we use.
    Our service provider does not provide the pure HTTP connection rather it goes over WAP and thats where the problem comes.
    Cause we attach our header for the server and WAP sticks his header in between , thats why server does not handle the request and consider it as bad request.
    I have commented the following lines for my code to work
    connection.setRequestProperty("User-Agent",
    System.getProperty("microedition.profiles"));
    connection.setRequestProperty("Content-Type",
    "application/octet-stream");
    Regards,
    Sushil

Maybe you are looking for

  • My front camera won't load, how can I fix it?

    My regular camera is working, however, when I try to flip it the camera will not load!

  • Speaker setup for Apple TV

    I am interested in purchasing Apple TV to be able to play itunes and other music apps (spotify, iheart radio, pandora) thru my ipad to the TV speakers when my MacBook is turned off.  Is this possible?  The other capability I am looking for is multipl

  • IChat Video Encryption

    Hello Everybody I have a family account for MobileMe and each account has a security certificate so we can chat securely. When we are text chatting both mine and the other persons chat window show a black closed padlock and it says the chat is encryp

  • Reflect on a Function object?

    I'm trying to discover information about a Function object at runtime. Specifically, I'd like to know the number and types of parameters the Function expects. Calling flash.utils.describeType() on my Function object doesn't give me this information.

  • Copy express add on  sap 8.8 -PLD coping problem

    Dear Experts    While coping the PLD  from one database to another by using copy express ( sap 8.8 PL 00 ) only the empty layout (without any field) was creating. Pleas give the solution. Thanks