This happens in version 1.7.1 rev 4004
Right-mouse select on a layer "Write features in a PostGIS table" (note typo: Should be "into a PostGIS table")
Select format: "PostGIS table (new)"
Tick box: Create a primary key column (gid) for this table
Works.
The table has 6 columns, 1 of which is the "gid" serial column (the primary key).
Later, try again, but this time UNMARK the "create a primary key column" tickbox
An exception results (feels like an index-maximum value is not being properly updated).
The table is created with 5 columns (but no gid column), but no data has been filled in.
org.postgresql.util.PSQLException: The column index is out of range: 7, number of columns: 6. at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:56) at org.postgresql.core.v3.SimpleParameterList.setBinaryParameter(SimpleParameterList.java:122) at org.postgresql.jdbc2.AbstractJdbc2Statement.bindBytes(AbstractJdbc2Statement.java:2292) at org.postgresql.jdbc2.AbstractJdbc2Statement.setInt(AbstractJdbc2Statement.java:1277) at org.openjump.core.ui.plugin.datastore.WritableDataStoreDataSource.setAttributeValues(WritableDataStoreDataSource.java:390) at org.openjump.core.ui.plugin.datastore.postgis2.PostGISDataStoreDataSource.populateTable(PostGISDataStoreDataSource.java:199) at org.openjump.core.ui.plugin.datastore.postgis2.PostGISDataStoreDataSource.createAndPopulateTable(PostGISDataStoreDataSource.java:184) at org.openjump.core.ui.plugin.datastore.WritableDataStoreDataSource$1.executeUpdate(WritableDataStoreDataSource.java:192) at com.vividsolutions.jump.workbench.datasource.AbstractSaveDatasetAsPlugIn.run(AbstractSaveDatasetAsPlugIn.java:33) at com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:152) at java.lang.Thread.run(Thread.java:745)
OK, I see the problem.
The first time you save the layer to PostGIS, the gid attribute is automatically added to the layer and marked as an extern identifier.
The second time you try to save the layer, there is some sort of conflict with this "special" attribute.
If you remove this gid (or make it normal by copying values into a normal attribute) it works again.
I'll try to remove the mark identifying an existing gid from a layer before it is saved into a postgis table.
Should be fixed in the r4028 (also "write feature in postgis" changed into "write features into postgis".
Note there is still an error thrown if you write to postgis with "create a primary key column" checked. Then try to write it again with the same option : in this case, the gid created the first time still exists (it is a "normal" attribute), and the driver can't create a new column with the same name (the cause of the problem is quite clear if you read the detailed error message).
Let me know if the problem is solved for you.