java - Could not load encryptKeyFile -


i trying encrypt password in data-config.xml dih. here dih configuration:

 <datasource type="jdbcdatasource"                driver="com.microsoft.sqlserver.jdbc.sqlserverdriver"                url="jdbc:sqlserver://xxxxx;databasename=yyyyy"               user="zzzzz"                password="u2fsdgvkx18ghgoofuz6bl7o23l7ypu+qof3cxidjgw="               encryptkeyfile="encryption.txt"/> 

i kept encryption.txt @ same path data-config.xml when starting dih, getting following error:

full import failed:java.lang.runtimeexception: java.lang.runtimeexception: org.apache.solr.handler.dataimport.dataimporthandlerexception: not load encryptkeyfile  encryption.txt processing document # 1     @ org.apache.solr.handler.dataimport.docbuilder.execute(docbuilder.java:270)     @ org.apache.solr.handler.dataimport.dataimporter.dofullimport(dataimporter.java:416)     @ org.apache.solr.handler.dataimport.dataimporter.runcmd(dataimporter.java:475)     @ org.apache.solr.handler.dataimport.dataimporter.lambda$runasync$0(dataimporter.java:458)     @ java.lang.thread.run(unknown source) caused by: java.lang.runtimeexception: org.apache.solr.handler.dataimport.dataimporthandlerexception: not load encryptkeyfile  encryption.txt processing document # 1     @ org.apache.solr.handler.dataimport.docbuilder.builddocument(docbuilder.java:416)     @ org.apache.solr.handler.dataimport.docbuilder.dofulldump(docbuilder.java:329)     @ org.apache.solr.handler.dataimport.docbuilder.execute(docbuilder.java:232)     ... 4 more caused by: org.apache.solr.handler.dataimport.dataimporthandlerexception: not load encryptkeyfile  encryption.txt processing document # 1     @ org.apache.solr.handler.dataimport.jdbcdatasource.decryptpwd(jdbcdatasource.java:138)     @ org.apache.solr.handler.dataimport.jdbcdatasource.init(jdbcdatasource.java:75)     @ org.apache.solr.handler.dataimport.dataimporter.getdatasourceinstance(dataimporter.java:389)     @ org.apache.solr.handler.dataimport.contextimpl.getdatasource(contextimpl.java:100)     @ org.apache.solr.handler.dataimport.sqlentityprocessor.init(sqlentityprocessor.java:53)     @ org.apache.solr.handler.dataimport.entityprocessorwrapper.init(entityprocessorwrapper.java:75)     @ org.apache.solr.handler.dataimport.docbuilder.builddocument(docbuilder.java:433)     @ org.apache.solr.handler.dataimport.docbuilder.builddocument(docbuilder.java:414)     ... 6 more 

any clue?

update: solution looked source code , found piece ...

116   private properties decryptpwd(context context, properties initprops) {   117     string encryptionkey = initprops.getproperty("encryptkeyfile");   118     if (initprops.getproperty("password") != null && encryptionkey != null) {   119       // means password encrypted , use file decode   120       try {   121         try (reader fr = new inputstreamreader(new fileinputstream(encryptionkey), utf_8)) {   122           char[] chars = new char[100];//max 100 char password   123           int len = fr.read(chars);   124           if (len < 6)   125             throw new dataimporthandlerexception(severe, "there should password of length 6 atleast " + encryptionkey);   126           properties props = new properties();   127           props.putall(initprops);   128           string password = null;   129           try {   130             password = cryptokeys.decodeaes(initprops.getproperty("password"), new string(chars, 0, len)).trim();   131           } catch (solrexception se) {   132             throw new dataimporthandlerexception(severe, "error decoding password", se.getcause());   133           }   134           props.put("password", password);   135           initprops = props;   136         }   137       } catch (ioexception e) {   138         throw new dataimporthandlerexception(severe, "could not load encryptkeyfile  " + encryptionkey);   139       }   140     }   141     return initprops;   142   } 

so has absolute path, relative path encryption file not work. changing encryptkeyfile absolute path resolved issue. ...

<datasource type="jdbcdatasource"                driver="com.microsoft.sqlserver.jdbc.sqlserverdriver"                url="jdbc:sqlserver://xxxxx;databasename=yyyyy"               user="zzzzz"                password="u2fsdgvkx18ghgoofuz6bl7o23l7ypu+qof3cxidjgw="               encryptkeyfile="c:\solr-6.4.2\server\solr\accounts\conf\encryption.txt"/> 


Comments