Salve a tutti....sto studiando i Web Service in Java e la tecnologia JAXR, ho un pezzo di codice che cerca di creare una nuova organizzazione e cerca di salvarla...ma mi da un NullPointerException e non ho capito bene dove....qualcuno può aiutarmi? Posto il mio codice:
import javax.xml.registry.*;
import javax.xml.registry.infomodel.*;
import javax.naming.*;
import java.util.*;
public class CreateOrg{
public static void main(String[] args){
try{
//Context ctx = new InitialContext();
/*ConnectionFactory factory =(ConnectionFactory) ctx.lookup("javax.xml.registr.ConnectionFactory"); */
ConnectionFactory factory = ConnectionFactory.newInstance();
Properties props = new Properties();
// Specifica l'implemetazione per l'effettiva connection factory
props.put("javax.xml.registry.factoryClass","com.s un.xml.registry.uddi.ConnectionFactoryImpl");
// Specifica la poszione delle API di interrogazione e pubblicazione
props.put("javax.xml.registry.queryManagerURL","ht tp://www-3.ibm.com/services/uddi/testregistry/inquiryapi");
props.put("javax.xml.registry.lifeCycleManagerURL" ,"http://www-3.ibm.com/services/uddi/testregistry/publish");
// Archivia le proprietà
factory.setProperties(props);
// Crea la connessione
Connection conn = factory.createConnection();
// Ottiene RegistryService
RegistryService regService = conn.getRegistryService();
// Ottiene BusinessQueryManager
BusinessLifeCycleManager lifeCycle = regService.getBusinessLifeCycleManager();
// Crea una nuova oragnizzazione
Organization newOrg = lifeCycle.createOrganization("WebServCorp");
// Descrivo l'organizzazione
newOrg.setDescription(lifeCycle.createInternationa lString("Cercherò di fornire dei buoni servizi web prima o poi"));
ArrayList save = new ArrayList();
// Aggiungo l'organizzazione alla collezione
save.add(newOrg);
// Salvo la collezione
BulkResponse resp = lifeCycle.saveObjects(save);
Collection respColl = resp.getCollection();
Iterator iter = respColl.iterator();
// Ottengo la chiave
Key key = (Key) iter.next();
System.out.println("La chiave è "+ key.getId());
}catch (Exception exc){
exc.printStackTrace();
}
}
}
L'errore è il seguente:
java.lang.NullPointerException
at java.lang.String.<init>(String.java:165)
at com.sun.xml.registry.uddi.ConnectionImpl.getAuthTo ken(Unknown Source)
at com.sun.xml.registry.uddi.UDDIMapper.getAuthInfo(U nknown Source)
at com.sun.xml.registry.uddi.UDDIMapper.saveOrganizat ions(Unknown Source)
at com.sun.xml.registry.uddi.UDDIMapper.saveObjects(U nknown Source)
at com.sun.xml.registry.uddi.LifeCycleManagerImpl.sav eObjects(Unknown Source)
at jaxr.CreateOrg.main(CreateOrg.java:36)
Grazie a tutti per l'aiuto.....ciao