title: How to fix Saml assertion Exception (NoClassDefFoundError)
body: <p>Hi guys i've created a saml assertion with opensaml-j and when i run the program an exception occurs and throws NoClassDefFoundError 
  i've loaded all the necessary jar files but still don't work
  here's my code:</p>
  
  <pre><code>package memory;
  
  import java.security.SecureRandom;
  
  import org.joda.time.DateTime;
  import org.opensaml.saml.common.SAMLVersion;
  import org.opensaml.saml.saml1.core.AttributeStatement;
  import org.opensaml.saml.saml1.core.AttributeValue;
  import org.opensaml.saml.saml1.core.NameIdentifier;
  import org.opensaml.saml.saml1.core.Subject;
  import org.opensaml.saml.saml1.core.impl.EvidenceBuilder;
  import org.opensaml.saml.saml1.core.impl.NameIdentifierBuilder;
  import org.opensaml.saml.saml1.core.impl.SubjectBuilder;
  import org.opensaml.saml.saml2.core.Action;
  import org.opensaml.saml.saml2.core.Assertion;
  import org.opensaml.saml.saml2.core.Attribute;
  import org.opensaml.saml.saml2.core.AuthzDecisionStatement;
  import org.opensaml.saml.saml2.core.Conditions;
  import org.opensaml.saml.saml2.core.DecisionTypeEnumeration;
  import org.opensaml.saml.saml2.core.Evidence;
  import org.opensaml.saml.saml2.core.Issuer;
  import org.opensaml.saml.saml2.core.impl.ActionBuilder;
  import org.opensaml.saml.saml2.core.impl.AssertionBuilder;
  import org.opensaml.saml.saml2.core.impl.AttributeBuilder;
  import org.opensaml.saml.saml2.core.impl.AttributeStatementBuilder;
  import org.opensaml.saml.saml2.core.impl.AuthzDecisionStatementBuilder;
  import org.opensaml.saml.saml2.core.impl.ConditionsBuilder;
  import org.opensaml.saml.saml2.core.impl.IssuerBuilder;
  
  public class CreateSamlAssertion {
  
  @SuppressWarnings("deprecation")
  public static Assertion createAssertion(){
      Assertion assertion=(Assertion)new AssertionBuilder().buildObject();
      assertion.setID(idGenerator());
      assertion.setVersion(SAMLVersion.VERSION_20);
      assertion.setIssueInstant(new DateTime());
      Issuer issuer=(Issuer)new  IssuerBuilder().buildObject();
      issuer.setNameQualifier("bob");
      assertion.setIssuer(issuer);
      Subject subject=(Subject)new SubjectBuilder().buildObject();
      NameIdentifier nameId=(NameIdentifier)new NameIdentifierBuilder().buildObject();
      nameId.setFormat(NameIdentifier.EMAIL);
      nameId.setNameIdentifier("alice");
      subject.setNameIdentifier(nameId);
      Conditions conditions=(Conditions)new ConditionsBuilder().buildObject();
      conditions.setNotBefore(new DateTime());
      conditions.setNotOnOrAfter(new DateTime().plusMinutes(20));
      assertion.setConditions(conditions);
      AuthzDecisionStatement authDecisionStatement=getAuthzDecisionStatement();
      assertion.getAuthzDecisionStatements().add(authDecisionStatement);
      return assertion;
  }
  
  private static AuthzDecisionStatement getAuthzDecisionStatement(){
      AuthzDecisionStatement aDStatement=(AuthzDecisionStatement)new AuthzDecisionStatementBuilder().buildObject();
       DecisionTypeEnumeration decision = DecisionTypeEnumeration.PERMIT;
      aDStatement.setDecision(decision);
      aDStatement.setResource("http://www.hb.com/Resources/Resource A1");
      Action actions=getAction();
      actions.setNamespace("http://www.hb.com/Resources/");
      aDStatement.getActions().add(actions);
      Evidence evidence=getEvidence();
      aDStatement.setEvidence(evidence);
      return aDStatement;
  }
  
  private static Evidence getEvidence(){
      Evidence evidence=(Evidence)new EvidenceBuilder().buildObject();
      Assertion assertion=(Assertion)new AssertionBuilder().buildObject();
      AttributeStatement aStatement=(AttributeStatement) new AttributeStatementBuilder().buildObject();
      Attribute attribute1=(Attribute)new AttributeBuilder().buildObject();
      attribute1.setName("IssuerCapabilityID");
      AttributeValue aValue1=(AttributeValue) AttributeValue.DEFAULT_ELEMENT_NAME;
      attribute1.getAttributeValues().add(aValue1);
  
      Attribute attribute2=(Attribute)new AttributeBuilder().buildObject();
      attribute2.setName("IssuerCapabilityID");
      AttributeValue aValue2=(AttributeValue) AttributeValue.DEFAULT_ELEMENT_NAME;
      attribute1.getAttributeValues().add(aValue2);
  
      aStatement.getAttributes().add((org.opensaml.saml.saml1.core.Attribute) attribute1);
      aStatement.getAttributes().add((org.opensaml.saml.saml1.core.Attribute) attribute2);
      assertion.getAttributeStatements().add((org.opensaml.saml.saml2.core.AttributeStatement) aStatement);
      evidence.getAssertions().add(assertion);
      return evidence;
  }
  
  private static Action getAction(){
      Action action=(Action)new ActionBuilder().buildObject();
      action.setAction("Read");
      action.setAction("Write");
      return action;
  }
  
  private static String idGenerator(){
      SecureRandom random=new SecureRandom();
      return String.valueOf(random.nextInt());
  }
  }
  </code></pre>
  
  <p>and here's the main class:</p>
  
  <pre><code>package memory;
  
  import org.opensaml.saml.saml2.core.Assertion;
  
  public class SamlTest {
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
      Assertion assertion=CreateSamlAssertion.createAssertion();
      System.out.println(assertion);
  }
  
  }
  </code></pre>
  
  <p>the stack trace</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
   at org.opensaml.core.xml.AbstractXMLObject.&lt;init&gt;(AbstractXMLObject.java:47)
   at org.opensaml.xmlsec.signature.AbstractSignableXMLObject.&lt;init&gt;(AbstractSignableXMLObject.java:47)
   at org.opensaml.saml.common.AbstractSignableSAMLObject.&lt;init&gt;(AbstractSignableSAMLObject.java:44)
   at org.opensaml.saml.saml2.core.impl.AssertionImpl.&lt;init&gt;(AssertionImpl.java:83)
   at org.opensaml.saml.saml2.core.impl.AssertionBuilder.buildObject(AssertionBuilder.java:45)
   at org.opensaml.saml.saml2.core.impl.AssertionBuilder.buildObject(AssertionBuilder.java:40)
   at memory.CreateSamlAssertion.createAssertion(CreateSamlAssertion.java:34)
   at memory.SamlTest.main(SamlTest.java:9)
  Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 8 more</code></pre>
  </div>
  </div>
  </p>
  
  <p>and thanks in advance</p>