BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Deen
Obsidian | Level 7

NOTE: PROCEDURE HTTP used (Total process time):
      real time           8.63 seconds
      cpu time            0.21 seconds



NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.15 seconds
      cpu time            0.01 seconds


NOTE: The ADD CLASSPATH command completed.
NOTE: The ADD CLASSPATH command completed.
NOTE: The ADD CLASSPATH command completed.
java.lang.IllegalArgumentException: Failed to find sasjar commons_codec
1.7.0.0_SAS_20121211183158.
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44)
     at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java
:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
     at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
     at
org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
     at
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(Con
structorSite.java:84)
     at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
     at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
     at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
     at Script9.findJar(Script9.groovy:2)
     at Script9$findJar.callCurrent(Unknown Source)
     at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
     at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
     at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:159)
     at Script9.run(Script9.groovy:3)
ERROR: Failed to add sasjar commons_codec.
ERROR: The SUBMIT command failed.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script14592196615082045114769.groovy: 6: unable to resolve class
org.apache.commons.codec.binary.Base64
 @ line 6, column 1.
   import org.apache.commons.codec.binary.Base64
   ^

1 error

     at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
     at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:860)
     at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521)
     at
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
     at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292)
     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:263)
     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:207)
     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:217)
ERROR: The SUBMIT command failed.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script10.groovy: 1: unable to resolve class DeenHash
 @ line 1, column 7.
   foo = new DeenHash()
         ^

1 error

     at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
     at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:860)
     at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521)
     at
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
     at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
     at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292)
     at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
     at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
     at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
     at groovy.lang.GroovyShell.parse(GroovyShell.java:757)

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE GROOVY used (Total process time):
      real time           1.31 seconds
      cpu time            0.00 seconds




NOTE: The data set WORK.FOO has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.00 seconds



WARNING: Could not initialize classpath.  Classpath variable is not set.
ERROR: Could not find class DeenHash at line 925 column 17.  Please ensure that the CLASSPATH
       is correct.
ERROR: DATA STEP Component Object failure.  Aborted during the EXECUTION phase.
java.lang.ClassNotFoundException: DeenHash
     at java.lang.ClassNotFoundException.<init>(ClassNotFoundException.java:77)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:385)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
     at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:674)
     at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:773)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.FOO.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.00 seconds

/*****Here is the code which I used for above log file***********/

filename groovy '$DATA/deen_temp.html'; proc http method='get' url="http://central.maven.org/maven2/org/codehaus/groovy/groovy-all/2.4.6/groovy-all-2.4.6.jar" out=groovy; run; filename xmlbind '$DATA/deen_xml.html'; proc http method='get' url="http://central.maven.org/maven2/javax/xml/bind/jaxb-api/2.2.12/jaxb-api-2.2.12.jar" out=xmlbind; run; filename cp '$DATA/deen_hash.txt'; options set=classpath= "%sysfunc(pathname(cp,f))"; proc groovy classpath=cp; add classpath=groovy; add classpath=xmlbind; add sasjar="commons_codec" version="1.7.0.0_SAS_20121211183158"; *version is specific to SAS Installation and may differ from this; submit parseonly; import javax.xml.bind.DatatypeConverter import java.security.MessageDigest import java.security.NoSuchAlgorithmException import java.util.ArrayList import org.apache.commons.codec.binary.Base64 /** * DeenHash Requirements * * * 1. Hash an input String (ex. "abc123") using SHA-256 algorithm * 2. Concatenate input string + hexDump of step1 result * 3. Hash step2 result using SHA-256 algorithm * a. this marks a single-round * b. print raw step3 result in Base64 encoding * 4. Hash step3 result 999 additional times using SHA-256 algorithm */ public class DeenHash { private String input = "abc123"; private String algorithm = "SHA-256"; protected ArrayList<byte[]> results=new ArrayList(); public DeenHash() {} public DeenHash(String input) { setInput(input); } public DeenHash(String algorithm, String input) throws NoSuchAlgorithmException{ setAlgorithm(algorithm); } public String getInput() { return this.input; } public void setInput(String input) { this.input = input; } public String getAlgorithm() { return this.algorithm; } public void setAlgorithm(String algorithm) throws NoSuchAlgorithmException { MessageDigest.getInstance(algorithm); this.algorithm = algorithm; } private String toHexString(byte[] bytes) { return DatatypeConverter.printHexBinary(bytes); } private String toBase64(byte[] bytes) { Base64 base64 = new Base64(); return new String(base64.encode(bytes)); } private byte[] merryGoRound(byte[] bytes) throws NoSuchAlgorithmException { byte[] step4 = bytes; for (int i=0; i<999; i++) { step4 = doSingleHash(step4); } return step4; } public byte[] doSingleHash(byte[] bytes) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(this.algorithm); md.update(bytes); return md.digest(); } public void doDeenHash() throws NoSuchAlgorithmException { byte[] step1 = doSingleHash(this.input.getBytes()); String step2 = this.input + toHexString(step1).toLowerCase(); byte[] step3 = doSingleHash(step2.getBytes()); this.results.add(step3); byte[] step4 = merryGoRound(step3); this.results.add(step4); } public String getFinalHash() { return toBase64(this.results.get(1)); } public String getInitialHash() { return toBase64(this.results.get(0)); } public void main(String[] args) { if (args.length == 1) { setInput(args[0]); } else if (args.length == 2) { try { setAlgorithm(args[0]); setInput(args[1]); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } try { doDeenHash(); System.out.println("Single Round: " + toBase64(this.results.get(0))); System.out.println("Final Round: " + toBase64(this.results.get(1))); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } } endsubmit; submit; foo = new DeenHash() foo.main() endsubmit; quit; data foo; input foo $; cards; abc123 ; run; data _null_; dcl javaobj hash('DeenHash'); do until(done); set foo end=done; length one thousand $ 64; hash.callVoidMethod('setInput',strip(foo)); *strip is important; hash.callVoidMethod('doDeenHash'); hash.callStringMethod('getInitialHash',one); hash.callStringMethod('getFinalHash',thousand); put (one thousand) (=/); end; stop; run;

 

Deen
Obsidian | Level 7

Matt,

Its good to know that you got some solution (Yey!!!) Thanks for your support....

 but It seems there is some issue in our environment or in my code execution. I provided the code along with the log file (contains error).

and I use SAS 9.3 in IBM -AIX OS. Please let me know how to make it successful at my end..

FriedEgg
SAS Employee

@Deen

 

As I noted in the comment for the line that gave you the error:

 

add sasjar="commons_codec" version="1.7.0.0_SAS_20121211183158"; *version is specific to SAS Installation and may differ from this;

 

You need to find the correct version number for you installation.

 

You can find this by browsing your SAS installation

 

 

ls -d /path/to/SASHome/SASVersionedJarRepository/9.3/eclipse/plugins/commons_codec*

 

 

This should display something like

 

 

/path/to/SASHome/SASVersionedJarRepository/9.3/eclipse/plugins/commons_codec_1.3.0.0_SAS_20081023153014/

 

You want to then modify the proc groovy with the correct version

 

 

add sasjar="commons_codec" version="1.3.0.0_SAS_20081023153014";

 

Deen
Obsidian | Level 7

I found the right sasjar version and executed the code below is log file. though it shows couple of warnings but it produced the desired result.


NOTE: PROCEDURE HTTP used (Total process time):
      real time           9.42 seconds
      cpu time            0.21 seconds



NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.20 seconds
      cpu time            0.01 seconds


NOTE: The ADD CLASSPATH command completed.
NOTE: The ADD CLASSPATH command completed.
NOTE: The ADD CLASSPATH command completed.
WARNING: SAS jars do not have a source compatibility guarantee across versions of SAS. Future
         versions of these jars can change without notice.
NOTE: The ADD SASJAR command completed.
NOTE: The SUBMIT command completed.
Single Round: Pbb2/dJkywFxhuW2O33twGm+Gu67UfoEFupDMUeBnuo=

Final Round: aJDhkskZ9OwP1n1akIoOgReHjm+iFJ0ofPt3CNhvFy8=

NOTE: The SUBMIT command completed.

NOTE: PROCEDURE GROOVY used (Total process time):
      real time           0.64 seconds
      cpu time            0.00 seconds



NOTE: The data set WORK.FOO has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.00 seconds



WARNING: Could not initialize classpath.  Classpath variable is not set.

one=Pbb2/dJkywFxhuW2O33twGm+Gu67UfoEFupDMUeBnuo=

thousand=aJDhkskZ9OwP1n1akIoOgReHjm+iFJ0ofPt3CNhvFy8=

NOTE: There were 1 observations read from the data set WORK.FOO.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

 If any quick suggestions to resolve the warning it would be really helpful for me ..also meanwhile, I need to extend this functionality to apply this hashing on a big dataset column for final requirements.

FriedEgg
SAS Employee

I believe I had a typo in the code I posted before

filename cp '$DATA/deen_hash.txt';

proc groovy classpath=cp;
...
quit;

options set=classpath "%sysfunc(pathname(cp,f))"; * I had an equal sign between classpath and the value, which should not be there;

data _null_;
...
run;

 

 

The WARNING

WARNING: SAS jars do not have a source compatibility guarantee across versions of SAS. Future
         versions of these jars can change without notice.

Can be ignored, it is pointing out the issue you had before, which is that different versions of SAS will have different versions of this Jar file... 

Deen
Obsidian | Level 7

inspite of using the below statement, warning is still persisting..

options set = classpath "%sysfunc(pathname(cp,f))";

 



WARNING: Could not initialize classpath.  Classpath variable is not set.

one=Pbb2/dJkywFxhuW2O33twGm+Gu67UfoEFupDMUeBnuo=

thousand=aJDhkskZ9OwP1n1akIoOgReHjm+iFJ0ofPt3CNhvFy8=

NOTE: There were 1 observations read from the data set WORK.FOO.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.00 seconds

I think  I need to do some more research on this ...meanwhile any quick suggestions/modifications really helpful..

appreciate your help and prompt support Matt...this is a new learning curve for me!!

ChrisHemedinger
Community Manager

I think the feature you've referenced in SAS 9.3 was using SAS/SECURE, which encrypts data "on the wire".  SAS/SECURE is part of the Base package in SAS 9.4, but yes -- a separate license was needed in SAS 9.3.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 21 replies
  • 9433 views
  • 6 likes
  • 4 in conversation