Hi, I finally figured out what was causing an issue with my WFS-T
transactions. I was getting the error:
java.io.IOException: An error occured
at
org.geotools.data.wfs.WFSTransactionState.commit(WFSTransactionState.java:135)
at
org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:176)
at mcmc.client.resource.WFSClient.addTest(WFSClient.java:351)
at mcmc.client.resource.WFSClient.addRoad(WFSClient.java:368)
at mcmc.client.WFSTEntry$1.run(WFSTEntry.java:428)
After checking out a copy of the WFS-T source from the repository, and
doing a bit of digging, it turned out that the error was actually a
classcastexception.
In the WFSTransactionState.java file there is a line:
hints.put(DocumentWriter.SCHEMA_ORDER, ns.toArray(new
String[ns.size()])); // Transaction
The problem is, some of the data types (specifically URI) were not
automatically casting to String so when Java tried to do the ns.ToArray,
it sent up an unchecked exception that showed up later as the previously
mentioned error.
As a test to see if I could get it to work, I iterated over the collection
and forced each element to use it's toString() function. This ended up
working and I can now submit new features to my datastore. This code can
be seen below.
Iterator it = ns.iterator();
String[] nsArr = new String[ns.size()];
int ct = 0;
while(it.hasNext()) {
nsArr[ct++] = "" + it.next();
}
hints.put(DocumentWriter.SCHEMA_ORDER,
nsArr); // Transaction
Yolan
*************************************************
* Yolan (Aaron Jackson) [EMAIL PROTECTED] *
* http://mlug.missouri.edu/~yolan/ *
* AIM: YolanLINUX, YolanOTHER, YolanLAPTOP *
* ICQ: 74624109 *
*************************************************
* Doubling Technologies *
**************************
Jody Garnett wrote:
Lets ask for help from a team that will know, Cory have we tried
deleting a feature from GeoServer 1.3.0a yet?
You may well of found a bug, incidentally is this using GeoTools 2.2.x?
I ran the WFSDataStoreWriteOnlineTest and it failed. Anytime it gets to
a commit it throws an IOException.
-- Delete Output
Running delete...
Source breakpoint occurred at line 122 of
WFSDataStoreWriteOnlineTest.java.
Delete Read 1
Delete Remove [ tasmania_cities.1 ]
Delete Read 2
# == 1 tasmania_cities.2
Delete Commit
java.io.IOException: An error occured
at
org.geotools.data.wfs.WFSTransactionState.commit(WFSTransactionState.java:135)
at
org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:176)
at
mcmc.client.WFSDataStoreWriteOnlineTest.doDelete(WFSDataStoreWriteOnlineTest.java:148)
at
mcmc.client.WFSDataStoreWriteOnlineTest.testEmpty(WFSDataStoreWriteOnlineTest.java:70)
at
mcmc.client.WFSDataStoreWriteOnlineTest.main(WFSDataStoreWriteOnlineTest.java:48)
-- Insert Output
Running insert...
Insert Read 1
Insert Add Features
Insert Read 2
Insert Commit
java.io.IOException: An error occured
at
org.geotools.data.wfs.WFSTransactionState.commit(WFSTransactionState.java:135)
at
org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:176)
at
mcmc.client.WFSDataStoreWriteOnlineTest.doInsert(WFSDataStoreWriteOnlineTest.java:105)
at
mcmc.client.WFSDataStoreWriteOnlineTest.testEmpty(WFSDataStoreWriteOnlineTest.java:75)
at
mcmc.client.WFSDataStoreWriteOnlineTest.main(WFSDataStoreWriteOnlineTest.java:48)
--
Reading data from wfs-t seems to work. Using Mapbuilder, I am able to
insert, delete, update etc the tasmania features so it's not a server
configuration issue. Any ideas?
Yolan
*************************************************
* Yolan (Aaron Jackson) [EMAIL PROTECTED] *
* http://mlug.missouri.edu/~yolan/ *
* AIM: YolanLINUX, YolanOTHER, YolanLAPTOP *
* ICQ: 74624109 *
*************************************************
* Doubling Technologies *
**************************
On Mon, 27 Mar 2006, Jody Garnett wrote:
Aaron Jackson wrote:
Ok, I've been working on a problem with updating data through WFS-T
for a while. I have now managed to update data in a shape file without any
problems. The big problem now is I'm getting a ClassCastException when I
try to use WFS-T to update with the same method. The stack trace I get is:
Exception in thread "Thread-4" java.lang.ClassCastException:
org.geotools.data.wfs.WFSTransactionState
at
org.geotools.data.AbstractDataStore.state(AbstractDataStore.java:455)
at
org.geotools.data.AbstractDataStore.getFeatureWriter(AbstractDataStore.java:513)
at
org.geotools.data.AbstractDataStore.getFeatureWriterAppend(AbstractDataStore.java:531)
at mcmc.client.resource.WFSClient.addRoad(WFSClient.java:306)
at mcmc.client.WFSTEntry$1.run(WFSTEntry.java:428)
I'm just using the default transaction with tasmania_cities. Should I
be doing something different for the Transaction?
Transaction t = new DefaultTransaction();
WFSFeatureStore fs =
(WFSFeatureStore)ds.getFeatureSource("topp:tasmania_cities");
fs.setTransaction(t);
I don't think so - what you did looks good to me. You may want to
check into the WFS test cases, preferably with a debugger to step through
them.
Jody
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users