Problem using SmartCard with 2 Certificates stored and SunPKCS11

Hi,
I'm trying to access one SmartCard token in Java 1.5 using SunPKCS11 provider for crypt, decrypt and digital signature operations.
I have 2 certificates stored on Token:
- CertA;
- CertB.
There are also 2 PIN:
- PIN1;
- PIN2.
I use:
- PIN1 for logging into the token;
- PIN1 for operation involving CertA;
- PIN2 for operation involving CertB;
There is no problem to logging into the token using Java and, without any troubles, I can read certificates and key from the
cryptographic card.
There is no problem using CertA for all my operation, but every attempt of using Private Key of CertB (for the same operations) returns with an Exception:
java.security.ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
Here there's an extract of my source code.
public void loginToken() {
Provider UserProvider = new sun.security.pkcs11.SunPKCS11(C:\\pkcs11.cfg);
Security.addProvider(UserProvider);
try {
KeyStore ks = null;
X509Certificate UserCert = null;
PrivateKey UserCertPrivKey = null;
PublicKey UserCertPubKey = null;
//PIN
char PIN1[] = "11111".toCharArray();
char PIN2[] = "22222".toCharArray();
//logging into token
ks = KeyStore.getInstance("PKCS11", UserProvider);
ks.load(null, PIN1);
//enumeration alias
String alias = "";
Enumeration e = ks.aliases();
while (e.hasMoreElements()) {
alias = (String) e.nextElement();
//Certificate
UserCert = (X509Certificate) ks.getCertificate(alias);
//PublicKey
UserCertPubKey = (PublicKey) ks.getCertificate(alias).getPublicKey();
if (alias.compareToIgnoreCase("Cert1") == 0) {
     //PrivateKey reference     
UserCertPrivKey = (PrivateKey) ks.getKey(alias, PIN1);
} else if (alias.compareToIgnoreCase("Cert2") == 0) {
//PrivateKey reference
UserCertPrivKey = (PrivateKey) ks.getKey(alias, PIN2);
} else {
System.out.println("ALIAS UNKNOW");
System.exit(1);
//Signature Test
if (!MakeSignature(UserCertPrivKey, UserProvider))
System.out.println(" *** SIGNATURE OK *** ");
else
System.out.println(" *** SIGNATURE KO *** ");
catch (Exception ex) {
System.out.println("ERROR: " + ex);
public boolean MakeSign(PrivateKey PrivKey, Provider p) {
try {
//File I/O
FileInputStream txtfis = new FileInputStream("C:\\Test.txt");
FileOutputStream sigfos = new FileOutputStream("C:\\Test_Signature.txt");
//Signature Obj init
Signature dsa = Signature.getInstance("SHA1withRSA", p.getName());
dsa.initSign(PrivKey);
//Update data
BufferedInputStream bufin = new BufferedInputStream(txtfis);
byte[] buffer = new byte[1024];
int len;
while (bufin.available() != 0) {
len = bufin.read(buffer);
dsa.update(buffer, 0, len);
bufin.close();
//Make signature
byte[] realSig = dsa.sign();
//save signature on file
sigfos.write(realSig);
sigfos.close();
return true;
catch (Exception ex) {
System.out.println("ERROR: " + ex);
return false;
Any help would be grateful...
Thanks in advance.
P.S. Sorry for my English

This is the same my initial problem.
I resolved it using IAIK-PKCS#11Wrapper (it is FREE) insted of sun.security.pkcs11.SunPKCS11.
You can find it here:
http://jce.iaik.tugraz.at/sic/products/core_crypto_toolkits/pkcs_11_wrapper
Here an exemple of code.
The main class:
import iaik.pkcs.pkcs11.Module;
import iaik.pkcs.pkcs11.DefaultInitializeArgs;
import java.util.Hashtable;
import iaik.pkcs.pkcs11.Token;
import iaik.pkcs.pkcs11.Slot;
import iaik.pkcs.pkcs11.Session;
import iaik.pkcs.pkcs11.objects.RSAPrivateKey;
import java.util.Vector;
import iaik.pkcs.pkcs11.objects.PrivateKey;
import iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate;
import java.util.Enumeration;
import iaik.pkcs.pkcs11.objects.Key;
import java.security.cert.CertificateFactory;
import java.io.ByteArrayInputStream;
import iaik.pkcs.pkcs11.Mechanism;
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.io.File;
import java.io.FileInputStream;
import org.bouncycastle.cms.CMSSignedDataGenerator;
import org.bouncycastle.cms.CMSProcessableByteArray;
import java.util.ArrayList;
import java.security.cert.CertStore;
import java.security.cert.CollectionCertStoreParameters;
import org.bouncycastle.cms.CMSSignedData;
import java.io.FileOutputStream;
import java.security.cert.X509Certificate;
import iaik.pkcs.pkcs11.TokenInfo;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
public class MakeSignature {
  public static void main(String[] args) {
     String USER_PIN = "12345678";
     String DLL_NAME = "C:\\windows\\system32\\dll_P11_name.dll";
     String OBJ_LABEL1 = "CNS0"; //this is the label of my 1th cert
     String OBJ_LABEL2 = "CNS1"; //this is the label of my 2th cert
     String INPUT_FILE = "C:\\Temp\\test.txt";
     String OUTPUT_FILE = "C:\\Temp\\test.p7m";
    try {
       // ********** INITIALIZE PKCS#11 MODULE WITH DEFAULT PARAMETERS **********
      Module pkcs11Module = Module.getInstance(DLL_NAME);
      pkcs11Module.initialize(new DefaultInitializeArgs());
       // ********** SELECT TOKEN **********
      Slot[] slotsWithToken = pkcs11Module.getSlotList(Module.SlotRequirement.TOKEN_PRESENT);
      Token[] tokens = new Token[slotsWithToken.length];
      Hashtable tokenIDtoToken = new Hashtable(tokens.length);
      long tokenID = -1;
      Token tokenUsed = null;
      //enum readers
      for (int i = 0; i < slotsWithToken.length; i++) {
        tokens[i] = slotsWithToken.getToken();
tokenID = tokens[i].getTokenID();
tokenIDtoToken.put(new Long(tokenID), tokens[i]);
System.out.println("Active tokens:");
System.out.println("Token ID: " + tokenID);
if (tokens.length == 0) { //No SC found
System.out.println("No SC presents");
else {
System.out.println("Using token: " + tokens[0].getTokenID());
tokenUsed = tokens[0];
     //Note: if you have more reader and more SC inserted, you have to write
     //here the code for select the right token
     // ********** OPEN SESSION VS THE TOKEN AND IF REQUIRED SUBMIT PIN **********
TokenInfo tokenInfo = tokenUsed.getTokenInfo();
Session session = tokenUsed.openSession(Token.SessionType.SERIAL_SESSION, false, null, null);
if (tokenInfo.isLoginRequired()) {
session.login(Session.UserType.USER, USER_PIN.toCharArray());
     // ********** SET SEARCH TEMPLATE FOR THE P11 OBJECT **********
RSAPrivateKey privateSignatureKeyTemplate = new RSAPrivateKey();
privateSignatureKeyTemplate.getSign().setBooleanValue(Boolean.TRUE);
privateSignatureKeyTemplate.getLabel().setCharArrayValue(OBJ_LABEL2.toCharArray());
     // ********** SEARCH P11 OBJECT USING TEMPLATE **********
Vector keyList = new Vector(4);
session.findObjectsInit(privateSignatureKeyTemplate);
Object[] matchingKeys;
while ( (matchingKeys = session.findObjects(1)).length > 0) {
keyList.addElement(matchingKeys[0]);
session.findObjectsFinal();
     //Try to find the corresponding certificates for the signature keys
Hashtable keyToCertificateTable = new Hashtable(4);
Enumeration keyListEnumeration = keyList.elements();
while (keyListEnumeration.hasMoreElements()) {
PrivateKey signatureKey = (PrivateKey) keyListEnumeration.nextElement();
byte[] keyID = signatureKey.getId().getByteArrayValue();
X509PublicKeyCertificate certificateTemplate = new X509PublicKeyCertificate();
certificateTemplate.getId().setByteArrayValue(keyID);
session.findObjectsInit(certificateTemplate);
Object[] correspondingCertificates = session.findObjects(1);
if (correspondingCertificates.length > 0) {
keyToCertificateTable.put(signatureKey, correspondingCertificates[0]);
session.findObjectsFinal();
     //There are three cases now: 1 no obj found; 2 found only one obj, 3 found more obj
Key selectedKey = null;
X509PublicKeyCertificate correspondingCertificate = null;
//no object found for template
if (keyList.size() == 0) {
System.out.println("No object found for template");
throw new Exception("No object found for template");
//Founf only one object
else if (keyList.size() == 1) {
selectedKey = (Key) keyList.elementAt(0);
// create a IAIK JCE certificate from the PKCS11 certificate
          correspondingCertificate = (X509PublicKeyCertificate)keyToCertificateTable.get(selectedKey);
System.out.println("One object Found");
//Found more object ... user can select one
else {
     System.out.println("Many obj found!!!");
//write here the code for select the right object
     // ********** GET THE OBJECT **********
RSAPrivateKey signerPriKey = (RSAPrivateKey) selectedKey;
java.security.cert.CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
byte[] derEncodedCertificate = correspondingCertificate.getValue().getByteArrayValue();
//Cast to java.security.cert.X509Certificate
java.security.cert.X509Certificate signerCert = (java.security.cert.X509Certificate) certificateFactory.
generateCertificate(new ByteArrayInputStream(derEncodedCertificate));
     // ********** SIGNATURE OPERATION **********
//Add BouncyCastle as provider
Security.addProvider(new BouncyCastleProvider());
//initialize signature operation
session.signInit(Mechanism.RSA_PKCS, (PrivateKey) signerPriKey);
//get input data
File src = new File(INPUT_FILE);
int sizecontent = ( (int) src.length());
byte[] contentData = new byte[sizecontent];
FileInputStream freader = new FileInputStream(src);
freader.read(contentData, 0, sizecontent);
freader.close();
     //calculate digest of the input data
byte[] toEncrypt = buildBits(contentData); //I've already posted the code for this function
//make signature
byte[] signature = session.sign(toEncrypt);
     // ********** MAKE P7 WELL FORMAT DOCUMENT **********
//CMSSignedDataGenerator fact = new CMSSignedDataGenerator();
Signature2CMSSignedData fact = new Signature2CMSSignedData();
CMSProcessableByteArray content = new CMSProcessableByteArray(contentData);
//Creation of BC CertStore
ArrayList certList = new ArrayList();
certList.add(signerCert);
CertStore certs = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");
//Signature Alg
String algorithm = CMSSignedDataGenerator.DIGEST_SHA1;
//add element to P7
fact.addSignature(signature, signerCert, algorithm);
fact.addCertificatesAndCRLs(certs);
//generate enveloped using Bouncycastle provider
     CMSSignedData envdata = fact.generate(PKCSObjectIdentifiers.data.getId(), content, true);
byte[] enveloped = envdata.getEncoded();
//Write P7 file
FileOutputStream efos = new FileOutputStream(OUTPUT_FILE);
efos.write(enveloped);
efos.close();
// ********** END **********
session.closeSession();
pkcs11Module.finalize(null);
catch (Exception ex) {
ex.printStackTrace();
}Main class uses buildBits function (already posted in this topic) and Signature2CMSSignedData class.import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.security.cert.CertStore;
import java.security.cert.X509CRL;
import java.security.cert.X509Certificate;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.BERConstructedOctetString;
import org.bouncycastle.asn1.DEREncodable;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.IssuerAndSerialNumber;
import org.bouncycastle.asn1.cms.SignedData;
import org.bouncycastle.asn1.cms.SignerIdentifier;
import org.bouncycastle.asn1.cms.SignerInfo;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.asn1.x509.TBSCertificateStructure;
import org.bouncycastle.asn1.x509.X509CertificateStructure;
import org.bouncycastle.cms.CMSProcessable;
import org.bouncycastle.cms.CMSSignedData;
* class for generating a RSA pkcs7-signature message.
public class Signature2CMSSignedData2 {
CertStore certStore;
List certs = new ArrayList();
List crls = new ArrayList();
List signerInfs = new ArrayList();
List signers = new ArrayList();
public static final String DATA = PKCSObjectIdentifiers.data.getId();
public static final String ENCRYPTION_RSA = "1.2.840.113549.1.1.1";
private byte[] signatureData = null;
private X509Certificate cert = null;
private String digestOID = null;
private String encOID = null;
public Signature2CMSSignedData2() {
public void addSignature(byte[] signatureData, X509Certificate cert, String digestOID) {
this.signatureData = signatureData;
this.cert = cert;
this.digestOID = digestOID;
this.encOID = ENCRYPTION_RSA;
public void addCertificatesAndCRLs(CertStore certStore) throws Exception{
try {
Iterator it = certStore.getCertificates(null).iterator();
while (it.hasNext()) {
X509Certificate c = (X509Certificate) it.next();
certs.add(new X509CertificateStructure((ASN1Sequence) makeObj(c.getEncoded())));
Iterator it2 = certStore.getCRLs(null).iterator();
while (it2.hasNext()) {
X509CRL c = (X509CRL) it2.next();
crls.add(new CertificateList((ASN1Sequence) makeObj(c.getEncoded())));
catch (Exception e) {
throw new Exception(e.getMessage());
private DERObject makeObj(byte[] encoding) throws Exception {
if (encoding == null) {
return null;
ByteArrayInputStream bIn = new ByteArrayInputStream(encoding);
ASN1InputStream aIn = new ASN1InputStream(bIn);
return aIn.readObject();
public CMSSignedData generate(String signedContentType, CMSProcessable content, boolean encapsulate) throws Exception {
try {
ASN1EncodableVector digestAlgs = new ASN1EncodableVector();
ASN1EncodableVector signerInfos = new ASN1EncodableVector();
DERObjectIdentifier contentTypeOID = new DERObjectIdentifier(signedContentType);
// add the SignerInfo objects
Iterator it = signerInfs.iterator();
AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(new DERObjectIdentifier(digestOID), new DERNull());
AlgorithmIdentifier encAlgId;
encAlgId = new AlgorithmIdentifier(new DERObjectIdentifier(encOID), new DERNull());
digestAlgs.add(digAlgId);
ASN1Set signedAttr = null;
ASN1Set unsignedAttr = null;
ASN1OctetString encDigest = new DEROctetString(signatureData);
ByteArrayInputStream bIn = new ByteArrayInputStream(cert.getTBSCertificate());
ASN1InputStream aIn = new ASN1InputStream(bIn);
TBSCertificateStructure tbs = TBSCertificateStructure.getInstance(aIn.readObject());
IssuerAndSerialNumber encSid = new IssuerAndSerialNumber(tbs.getIssuer(), tbs.getSerialNumber().getValue());
signerInfos.add(new SignerInfo(new SignerIdentifier(encSid), digAlgId, signedAttr, encAlgId, encDigest, unsignedAttr));
ASN1Set certificates = null;
if (certs.size() != 0) {
ASN1EncodableVector v = new ASN1EncodableVector();
it = certs.iterator();
while (it.hasNext()) {
v.add( (DEREncodable) it.next());
certificates = new DERSet(v);
ASN1Set certrevlist = null;
if (crls.size() != 0) {
ASN1EncodableVector v = new ASN1EncodableVector();
it = crls.iterator();
while (it.hasNext()) {
v.add( (DEREncodable) it.next());
certrevlist = new DERSet(v);
ContentInfo encInfo;
if (encapsulate) {
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
content.write(bOut);
ASN1OctetString octs = new BERConstructedOctetString(bOut.toByteArray());
encInfo = new ContentInfo(contentTypeOID, octs);
else {
encInfo = new ContentInfo(contentTypeOID, null);
SignedData sd = new SignedData(new DERSet(digestAlgs), encInfo, certificates, certrevlist, new DERSet(signerInfos));
ContentInfo contentInfo = new ContentInfo(PKCSObjectIdentifiers.signedData, sd);
return new CMSSignedData(content, contentInfo);
catch (Exception e) {
throw new Exception(e.getMessage());
}Bye.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

Similar Messages

  • Hello! I'm using Aperture with Efex plugins and notice, what when I saving result in plugin and go back to aperture, preview mode is going to grey color and not working until I reboot Aperture. Did you saw this problem?

    Hello! I'm using Aperture with Efex plugins and notice, what when I saving result in plugin and go back to aperture, preview mode is going to grey color and not working until I reboot Aperture. What is intresting - in full screen mode everything works fine. Did you saw this problem?

    It seems there's a workaround here:
    https://discussions.apple.com/thread/5566037?tstart=0

  • Any Problems using SSL with Safari and the move with Internet explorer to require only TLS encryption.

    Any Problems using SSL with Safari and the move with Internet explorer to require only TLS encryption.

    Hi .
    Apple no longer supports Safari for Windows if that's what you are asking >  Apple apparently kills Windows PC support in Safari 6.0
    Microsoft has not written IE for Safari for many years.

  • File to SOAP (Synchronous) with certificates Encryption and Descryption

    Hi,
    Can anybody advice me how can I develop the scenario file to SOAP (Synchronous Process) with certificates encryption and descryption.
    Thanks,
    Naidu.

    For file to soap sync scenario without using BPM, you need to use the following adapter modules.
    http://help.sap.com/saphelp_nw04/helpdata/en/45/20c210c20a0732e10000000a155369/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/45/20cc5dc2180733e10000000a155369/content.htm
    For applying certificates, you need to configure SSL on java stack.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/197e6aec-0701-0010-4cbe-ad5ff6703c16
    Regards,
    Prateek

  • Problem using Toplink with JUnit

    Hi,
    I have a problem using Toplink with JUnit. Method under test is very simple: it use a static EntityManager object to open a transaction and persists data to db. When I invoke the method from a test method, it gives me the exception:
    java.lang.AssertionError
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.computePURootURL(PersistenceUnitProcessor.java:248)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:232)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:216)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:239)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initializeFromMain(JavaSECMPInitializer.java:278)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.getJavaSECMPInitializer(JavaSECMPInitializer.java:81)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:119)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
         at it.valerio.electromanager.model.EntityFacade.<clinit>(EntityFacade.java:12)
         at it.valerio.electromanager.business.ClienteBiz.insertIntoDatabase(ClienteBiz.java:36)
         at it.valerio.electromanager.test.model.ClienteTest.insertDBTest(ClienteTest.java:30)
         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 org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
         at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
         at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
         at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
         at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
         at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
         at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
         at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
         at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Where is the problem???
    Regards,
    Valerio

    EntityFacade class is very simple and it uses a static EntityManager object. Here the code:
    public class EntityFacade {
         private static EntityManager em = Persistence.createEntityManagerFactory("ElectroManager").createEntityManager();
         private static Logger logger=Logger.getLogger(EntityFacade.class);
         public static void insertCliente(Cliente c)
              logger.debug("Inserisco cliente nel db: " + c);
              em.getTransaction().begin();
              c.setId(getNextIdForTable("Cliente"));
              em.persist(c);
              em.getTransaction().commit();
    If I call the method from inside a main it works well, so I think the problem is not the classpath neither the URL in the persistence.xml. However the URL is:
    <property name="toplink.jdbc.url" value="jdbc:derby:c:/programmi/ElectroManager/db/electroManager"/>
    I use the latest build version of TopLink.
    Thanks.

  • Problem using ViewObject with bc4j:table

    Hello !!
    This is the query of my ViewObject:
    select * from speiseplan order by jahr desc, kw desc;
    and everything works fine in the BC4J tester:
    jahr kw
    2003 52
    2003 7
    2003 3
    2002 51
    But in my uix page the rows are not correctly sorted:
    jahr kw
    2003 3
    2003 7
    2003 52
    2002 51
    What's going wrong here?
    Thanks for your help.
    Regards,
    Mareike

    Duplicate post.
    Original problem using ViewObject with <bc4j:table>

  • The new ibook app and ibook update is designed for iPhone 5 operating system.   When my iPhone4 recently updated the ibook app, it created many problems using the ibook to download and read my books.    Can I get the previous ibook app back on my phone.

    The new ibook app and ibook update is designed for iPhone 5 operating system.   When my iPhone4 recently updated the ibook app, it created many problems using the ibook to download and read my books.    Can I get the previous ibook app back on my phone.

    Check your trash can on the desktop. The old version is automatically moved to the trashcan. You should be able to move it from the trashcan back to the Apps folder within the iTunes folder. The update that was pushed out was for iBooks to work with iOS 7 not iPhone 5. iOS 7 was released today.

  • Problems using iCloud with Mountain Lion on iMac8,1

    problems using iCloud with Mountain Lion on iMac8,1 - about 5J old - iMac gets slower and slower - total free memory is used in some minutes - no more reaction on input

    Download > http://codykrieger.com/gfxCardStatus Open it and select Integrated Only. It's a bug with NVIDIA graphic cards

  • I am trying to use livetype with persian alphabet and it doesn't work. what should I do?

    I am trying to use livetype with persian alphabet and it doesn't work. what should I do?

    There is no more LiveType with Motion 5.  You may want to go to the Final Cut Express forum, as that's the only place it's existed for the last few years.

  • How can I use LCCS with ActionScript 3 and Flash CS4?

    Hi,
    Using Stratus I was able to create an an application using Action Script 3 and Flash CS4.  The sample code on the Adobe site was quite straight forward and easy to understand.  I now want to switch over to  LCCS but can't find anything any where on how to use Action Script 3 and Flash CS4 with LCCS.  Do I need to know Flex to be able to use LCCS?  Everything was quite simple and easy to understand with Stratus and makes complete sense.  But LCCS is really confusing.  Is there any sample code on how to establish a connection in Action Script 3 and then stream from a webcam to a client.  There is nothing in the  LCCS SDK that covers Flash and Action Script 3.  Please help!  I found the link below on some forum but it takes me nowhere.
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=75 9&threadid=1407833&enterthread=y

    Thanks Arun!
    Date: Thu, 29 Apr 2010 11:44:10 -0600
    From: [email protected]
    To: [email protected]
    Subject: How can I use LCCS with ActionScript 3 and Flash CS4?
    Hi,
    Welcome to the LCCS world.
    Please refer to the SDK's sampleApps folder. There would be an app called FlashUserList. The app demonstrates how LCCS can be used with Flash CS4. Its a  pretty basic app, but should help you moving.
    We are trying to improve our efforts to help developers in understanding our samples. Please do let us know if we can add something that would help others.
    Thanks
    Arun
    >

  • Good Morning.  I'm having a problem using both my Photoshop elements and premiere programs.  I've installed the programs, redeemed my code and entered the serial numbers, and created the adobe log-in.  I am able to open up the organizer without problems,

    Good Morning.  I'm having a problem using both my Photoshop elements and premiere programs.  I've installed the programs, redeemed my code and entered the serial numbers, and created the adobe log-in.  I am able to open up the organizer without problems, but when I try to open up the photo editor (either by trying to open up the program from the main menu, or right-clicking on a photo in the organizer to edit in elements), the program asks me to sign in to adobe (which I can do and it doesn't give an an "incorrect password" or log-in ID error) then accept the terms and conditions.  When I click to accept the terms and conditions, nothing happens and the editor fails to open.  Everytime I click on the program, I get this same "loop" of signing in and accepting T&C's, but the program fails to open.  Any advice?

      Premiere Elements 10 is now 64 bit, but not PSE10.
    Take a look at your scratch disk set-up and if you have a spare volume, allocate that first before the C drive. Elements use scratch disks when it gets low on RAM.
    Click image to enlarge
    Turn off face recognition and the auto-analyzer to improve performance.
    When editing photos or videos check the task manager to see what background processes may be running and end them temporarily if not needed.

  • Using Icloud with Outlook 2007 and windows 7, I cannot get my calendar to list the scheduled appointments as it used to do before I cloud.  The to do bar just shows no upcoming appointments when my calendar is filled with them.  How do I fix this

    Since using ICloud with Office 2007 and Windows 7, the to-do-list will not show any appointments.  If has the notation that no appointments are available?  My calendar is full of appointments.  How do I correct this?

    I don't have a password on my phone. After attaching the phone to the Windows 7 computer, my DCIM folder is always empty. Here's the solution:  While the phone is plugged in to the computer, pick it up and select the Photos application. A dialog box appears and asks if you trust this computer. Obviously, select the "Trust" option. Then the photos will download. If you have a password on your phone, I'm guessing you have to enter it before you open the photo application.

  • I am using Firefox with OS X and suddenly I lost the slot in which I type URL's in the top of the browser. How can I get it back?

    I am using FIREFOX with OS X and suddenly I lost the slot at the top of the browswer in which to type the URL's. It just disappeared.
    How can I get it back?

    View --> Toolbars --> Navigation Toolbar

  • Problem in Multisim with transient analysis and initial conditions

    Hello everyone,
    I have a problem in multisim with transient analysis and initial conditions.
    If I do transient analysis with automatically determined initial conditions the circuits works.
    If I do transient analysis with user-defined initial conditions the circuits works in cases.
    --Working with user-defined---
    *## Multisim Component V2 ##*
    vV2 3 0 pwl(0 0 0.001 0 {0.001+1e-008} 3 {0.001+1e-008+1} 3)
    *## Multisim Component R1 ##*
    rR1 3 0 10000 vresR1
    .model vresR1 r( )
    --Working with user-defined----------
    *## Multisim Component V2 ##*
    vV2 1 0 pwl(0 0 0.001 0 {0.001+1e-008} 3 {0.001+1e-008+1} 3)
    *## Multisim Component U1 ##*
    xU1 1 0 MEMRISTOR__MEMS__1__1
    --Not Working with user-defined-------
    *## Multisim Component V2 ##*
    vV2 3 0 pwl(0 0 0.001 0 {0.001+1e-008} 3 {0.001+1e-008+1} -3)
    *## Multisim Component R1 ##*
    rR1 3 1 10000 vresR1
    .model vresR1 r( )
    *## Multisim Component U1 ##*
    xU1 1 0 MEMRISTOR__MEMS__1__1
    The costum component includes something like that:
    .subckt MEMRISTOR__MEMS__1__1 plus minus PARAMS:
    *Parameters values
    +rmin=100 rmax=390 rinit=390 alpha=1E3 beta=0 gamma=0.1 VtR=1.5 VtL=-1.5 yo=0.0001
    +m=82 fo=310 Lo=5
    blah blah ...
    .ends Memristor
    Namely, if I combine the resistor and my custom component in one circuit, transient analysis with user defined initial conditions gives an error (timestep too small).

    Hi  Nik,
    If possible, please post the Multisim file. This way, I can get access to all your settings.
    Tien P.
    National Instruments

  • Problem Using Multiple With Statements

    I'm having a problem using multiple WITH statements. Oracle seems to be expecting a SELECT statement after the first one. I need two in order to reference stuff from the second one in another query.
    Here's my code:
    <code>
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy)
    /*Use terms from calculate_terms to generate attendance periods*/
    WITH gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    SELECT *
    FROM gen_attn_terms
    <code>
    I get ORA-00928: missing SELECT keyword error. What could be the problem?

    You can just separate them with a comma:
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy),
    /*Use terms from calculate_terms to generate attendance periods*/
    gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    )Not tested because there are no scripts.

Maybe you are looking for

  • How to Get One MQ Message at a time from MQ Queue

    Hi, Before posting my query here is the configuration I am using:_ Weblogic Server 10.3.3 Soa Server 11.1.1.3.0 Oracle JDeveloper 11.1.1.3.0 Till now I have done the following things:_ 1) created an MQ Queue 2) Producing MQ Messages in the Queue with

  • Error 1305: Data1.cab

    When I was updating my Adobe Reader to 9.3, it got to 99.9 then I got a message saying that I had to "Verify that the file exists and that you can access it." Well, it was in a folder on my desktop where it was supposed to be, I opened the cabinet fi

  • OpenSuse Undo/Redo doesn't work when click on web links

    OpenSuse 12.2 Firefox 17 Undo/Redo doesn't work when click on link . All web pages have some problem. Undo/Redo working for web page "Find" text box. All web pages

  • How to find delivery note in purchase requisition form

    Hello gurus, i have one problem in doing purchase requistion form. I need to find delivery note(field name is lfsnr) from purchase requisition. where can i get it. waiting from ur favourable replies. regards Maruthi

  • Can I use adobe elements 12 on more than one computer?

    can I put elements 12 on both of my computers?