2013-07-24 76 views
0
Hi i was trying to use solrj to query in https protocol but i am getting ssl exection error. 

here are the code same i tried 

import org.apache.solr.client.solrj.SolrServerException; 
import org.apache.solr.client.solrj.impl.HttpSolrServer; 
import org.apache.solr.client.solrj.SolrQuery; 
import org.apache.solr.client.solrj.response.QueryResponse; 
import org.apache.solr.common.SolrDocumentList; 

import java.net.MalformedURLException; 

public class SolrJSearcher { 
    public static void main(String[] args) throws MalformedURLException, SolrServerException { 
    HttpSolrServer solr = new HttpSolrServer("`https://abc:8080/solr`"); 

    SolrQuery query = new SolrQuery(); 
    query.setQuery("sony digital camera"); 
    query.addFilterQuery("cat:electronics","store:amazon.com"); 
    query.setFields("id","price","merchant","cat","store"); 
    query.setStart(0);  
    query.set("defType", "edismax"); 

    QueryResponse response = solr.query(query); 
    SolrDocumentList results = response.getResults(); 
    for (int i = 0; i < results.size(); ++i) { 
     System.out.println(results.get(i)); 
    } 
    } 
} 


and i got following expection 


Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: 

sun.security.provider.certpath.SunCertPathBuilderException:無法 找到com.sun.net.ssl.internal.ssl.Alerts有效的認證路徑請求的目標 。 getSSLException(Alerts.java:174) 在com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1762) 在com.sun.net.ssl.internal.ssl.Handshaker.fatalSE( Handshaker.java:241) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker。 Java的:1206) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:136) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529) 在com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:958) 在COM。 sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1203) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1230) at com.sun。 net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1214) at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:571) at org.apache.http.conn。 ssl.SSLSocketF actory.connectSocket(SSLSocketFactory.java:402) at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:494) at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor。的java:65) 在org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179) 在org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) 在org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:609) at org.apache.http。 impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:444) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:864) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) at org.apache.http .impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) at solrcheck.SolrJSearcher.main(SolrJSearcher.java:87 ) 引起:sun.security.validator.ValidatorException:PKIX路徑構建失敗: sun.security.provider.certpath.SunCertPathBuilderException:無法到 在sun.security.validator.PKIXValidator.doBuild找到請求目標 的有效證書路徑(PKIXValidator.java:323) 在sun.security。 validator.PKIXValidator.engineValidate(PKIXValidator.java:217) at sun.security.validator.Validator.validate(Validator.java:218) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl。 java:126) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java: 249) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1185) ... 21更多 引起:sun.security.provider.certpath.SunCertPathBuilderException:無法發現 查找在sun.security.provider有效的認證路徑請求的目標 。(SunCertPathBuilder.java:174) at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238) at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318) 。 .. 27多個Solrj查詢在https協議錯誤

any working example will be great help. thanks . 

回答