Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9826 > unrolled thread
| Started by | ptreves <ptreves@gmail.com> |
|---|---|
| First post | 2011-11-10 08:23 -0800 |
| Last post | 2011-11-10 15:03 -0800 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
Object IllegalStateException Problem ptreves <ptreves@gmail.com> - 2011-11-10 08:23 -0800
Re: Object IllegalStateException Problem Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-10 16:51 +0000
Re: Object IllegalStateException Problem ptreves <ptreves@gmail.com> - 2011-11-10 08:59 -0800
Re: Object IllegalStateException Problem Patricia Shanahan <pats@acm.org> - 2011-11-10 10:21 -0800
Re: Object IllegalStateException Problem Lew <lewbloch@gmail.com> - 2011-11-10 15:03 -0800
| From | ptreves <ptreves@gmail.com> |
|---|---|
| Date | 2011-11-10 08:23 -0800 |
| Subject | Object IllegalStateException Problem |
| Message-ID | <ba4fae99-a9a7-4299-b0dd-94a999e2a57c@a5g2000vbb.googlegroups.com> |
Hello,
I am working on a Java application, and run into the following
exception when trying to save my Network Configuration Parameters. I
have been looking at the execution stack trace for clues to the
problems.
This is the save() method that calls the different objects to save the
individual Configuration<Types>:
public void save() throws XmlException, IOException {
if (logger.isDebugEnabled()) {
logger.debug("Saving systemwide config...");
}
if(!systemwideConfiguration.equals(null)) {
systemwideConfiguration.bufferedSave();
}
if(!rtdbConfiguration.equals(null)) {
rtdbConfiguration.bufferedSave();
}
if(!localeConfiguration.equals(null)) {
localeConfiguration.saveAsCommitted();
}
if(!hmiAccessMgrModel.equals(null)) {
hmiAccessMgrModel.save();
}
if (!CommunicationManager.getInstance().getIsDNA()){
runtimeGUIConfiguration.bufferedSave();
eventLoggerConfiguration.bufferedSave();
dhcpModel.save();
}
if (CommunicationManager.getInstance().getIsDNA()){
if(!timeSyncModel.equals(null)) {
timeSyncModel.save();
}
}
if (logger.isDebugEnabled()) {
logger.debug("Saving systemwide config...completed");
}
setModified(false);
}
Here is the corresponding stack trace:
java.lang.IllegalStateException: Please load a version of an object
before saving!
java.lang.IllegalStateException: Please load a version of an object
before saving!
at
com.gepower.d400.model.config.ConfigurationImpl.getSaveFile(ConfigurationImpl.java:
309)
at
com.gepower.d400.model.config.ConfigurationImpl.bufferedSave(ConfigurationImpl.java:
357)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.gepower.d400.model.config.ConfigurationManager
$SaveProxy.invoke(ConfigurationManager.java:400)
at $Proxy0.bufferedSave(Unknown Source)
at
com.gepower.d400.view.config.systemwide.SystemwideModel.save(SystemwideModel.java:
366)
at com.gepower.d400.view.config.systemwide.SystemwideController
$SaveAction.doLongOperation(SystemwideController.java:272)
at com.gepower.d400.swing.BusyThread.run(BusyThread.java:103)
Now, I am thincking that the command:
hmiAccessMgrModel.equals(null)
is causing the problem and should be re-written as:
hmiAccessMgrModel == null
Suggestions as to what the problem might be ?
Paolo
[toc] | [next] | [standalone]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2011-11-10 16:51 +0000 |
| Message-ID | <slrnjbo07q.fvg.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #9826 |
ptreves <ptreves@gmail.com> wrote: > java.lang.IllegalStateException: Please load a version of an object > before saving! > at > com.gepower.d400.model.config.ConfigurationImpl.getSaveFile(ConfigurationImpl.java: > 309) Have a closer look at ConfigurationImpl.getSaveFile! If you quote the method, don't forget to insert a comment indicating which of the lines is number 309 within ConfigurationImpl.java. > Now, I am thincking that the command: > hmiAccessMgrModel.equals(null) > is causing the problem and should be re-written as: > hmiAccessMgrModel == null Yes, it really should be re-written as you say. As it is: if the left side ever *was* null, then you get a NullPointerException rather than a true result from xyz.equals(null)
[toc] | [prev] | [next] | [standalone]
| From | ptreves <ptreves@gmail.com> |
|---|---|
| Date | 2011-11-10 08:59 -0800 |
| Message-ID | <b07905c0-175e-4853-a7fa-7796a800be78@n6g2000vbg.googlegroups.com> |
| In reply to | #9827 |
This is the getSaveFile() method:
private FileInfo getSaveFile() throws IOException {
if (object == null) {
throw new IllegalStateException("Please load a version of
an object before saving!");
}
// get the uncommitted version if it is there
FileInfo saveFile =
getConfigurationVersions().get(ConfigurationVersion.UNCOMMITTED);
if (saveFile == null) {
// otherwise create a new temp file
saveFile =
FileInfo.createTempFile(getConfigurationFileName(),
getConfigurationDirectory());
}
return saveFile;
}
Paolo
[toc] | [prev] | [next] | [standalone]
| From | Patricia Shanahan <pats@acm.org> |
|---|---|
| Date | 2011-11-10 10:21 -0800 |
| Message-ID | <CPednc-_VpS0iyHTnZ2dnUVZ_oednZ2d@earthlink.com> |
| In reply to | #9828 |
On 11/10/2011 8:59 AM, ptreves wrote:
> This is the getSaveFile() method:
>
> private FileInfo getSaveFile() throws IOException {
> if (object == null) {
> throw new IllegalStateException("Please load a version of
> an object before saving!");
> }
>
> // get the uncommitted version if it is there
> FileInfo saveFile =
> getConfigurationVersions().get(ConfigurationVersion.UNCOMMITTED);
>
> if (saveFile == null) {
> // otherwise create a new temp file
> saveFile =
> FileInfo.createTempFile(getConfigurationFileName(),
> getConfigurationDirectory());
> }
>
> return saveFile;
> }
>
> Paolo
Where is "object" defined, and what is supposed give it a non-null value?
Patricia
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2011-11-10 15:03 -0800 |
| Message-ID | <10130030.857.1320966182398.JavaMail.geo-discussion-forums@prap37> |
| In reply to | #9828 |
ptreves wrote:
> This is the getSaveFile() method:
>
> private FileInfo getSaveFile() throws IOException {
> if (object == null) {
> throw new IllegalStateException("Please load a version of
> an object before saving!");
> }
>
> // get the uncommitted version if it is there
> FileInfo saveFile =
> getConfigurationVersions().get(ConfigurationVersion.UNCOMMITTED);
>
> if (saveFile == null) {
> // otherwise create a new temp file
> saveFile =
> FileInfo.createTempFile(getConfigurationFileName(),
> getConfigurationDirectory());
> }
>
> return saveFile;
> }
You completely ignored Andreas's advice!
Here's what you need to provide us:
http://sscce.org/
--
Lew
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web