1

I have a connection with basicAuthentication, the getCapabilities and getFeatureStore return me correct data but when i try to commit a transaction I get the next exception: "HTTP response code:401 for url ...."

Here's my code:

public boolean anadirIncidencia(String getCapabilities, String capa,
        SimpleFeature incidencia, String username, String password) throws Exception {
    boolean b = false;
    Map connectionParameters = new HashMap();
connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
                getCapabilities);
connectionParameters.put("WFSDataStoreFactory:USERNAME",username);
connectionParameters.put("WFSDataStoreFactory:PASSWORD",password);

    System.out.println("Connexion Parameters: " + connectionParameters);
    DataStore data = DataStoreFinder.getDataStore(connectionParameters);

    SimpleFeatureSource source = data.getFeatureSource(capa);
    List<SimpleFeature> features = new ArrayList<SimpleFeature>();
    features.add(incidencia);

    Transaction transaction = new DefaultTransaction("add");

    SimpleFeatureStore featureStore = (SimpleFeatureStore) source;
    featureStore.setTransaction(transaction);
    System.out.println("FeatureStore:" + featureStore.getDataStore().getNames());

    try {

        System.out.println("ADD: addFeatures");
        List<FeatureId> added = featureStore.addFeatures(DataUtilities
                .collection(features));
        System.out.println("added: " + added.toString());
        transaction.commit();
        b = true;

    } catch (Exception problem) {
        problem.printStackTrace();
        transaction.rollback();
        b = false;
        error = problem.getLocalizedMessage();
        System.out.println("ADD: rollback ----->" + error);
    } finally {
        transaction.close();
    }
    return b;
}

And the error happens in transaction.commit(); and then after commit fails, transaction.rollback() throws the same error.

Someone can help me?

  • Can you check the server's log to see what is going on there? – Ian Turton May 23 '15 at 7:33
  • Here's the log and Exception: pasted.co/8e270c02 Thanks! – Dani May 25 '15 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.