Karaf下通过HttpClient下载Maven资源,提示连接超时。

【日志】
****************************
org.osgi.jmx.framework.FrameworkMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@59530fe3 with name osgi.core:type=framework,version=1.7,framework=org.apache.felix.framework,uuid=f1ea2aaa-5ff1-4df3-8b5a-4aa2b7f85569
INFO  | JMX OSGi Agent   | core                             | 74 - org.apache.aries.jmx.core - 1.1.1 | Registering org.osgi.jmx.framework.ServiceStateMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@59530fe3 with name osgi.core:type=serviceState,version=1.7,framework=org.apache.felix.framework,uuid=f1ea2aaa-5ff1-4df3-8b5a-4aa2b7f85569
INFO  | Local user karaf | FeaturesServiceImpl              | 24 - org.apache.karaf.features.core - 3.0.1 | Installing feature webconsole 3.0.1
INFO  | Local user karaf | FeaturesServiceImpl              | 24 - org.apache.karaf.features.core - 3.0.1 | Installing feature http 3.0.1
INFO  | Local user karaf | FeaturesServiceImpl              | 24 - org.apache.karaf.features.core - 3.0.1 | Installing feature pax-http 3.1.0
INFO  | Local user karaf | FeaturesServiceImpl              | 24 - org.apache.karaf.features.core - 3.0.1 | Installing feature pax-jetty 8.1.14.v20131031
WARN  | Local user karaf | AetherBasedResolver              | 5 - org.ops4j.pax.url.mvn - 1.6.0 | Error resolving artifactorg.apache.servicemix.specs:org.apache.servicemix.specs.activation-api-1.1:jar:2.2.0:Could not transfer artifact org.apache.servicemix.specs:org.apache.servicemix.specs.activation-api-1.1:jar:2.2.0 from/to central (http://repo1.maven.org/maven2/): Error transferring file: 连接超时
org.sonatype.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.apache.servicemix.specs:org.apache.servicemix.specs.activation-api-1.1:jar:2.2.0 from/to central (http://repo1.maven.org/maven2/): Error transferring file: 连接超时
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:286)
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:250)
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolveFile(AetherBasedResolver.java:239)
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:223)
    at org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:122)
    at java.net.URL.openStream(URL.java:1037)[:1.7.0_45]
    at org.apache.karaf.features.internal.BundleManager.getInputStreamForBundle(BundleManager.java:173)
    at org.apache.karaf.features.internal.BundleManager.doInstallBundleIfNeeded(BundleManager.java:92)
    at org.apache.karaf.features.internal.BundleManager.installBundleIfNeeded(BundleManager.java:86)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.doInstallFeature(FeaturesServiceImpl.java:529)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatureDependency(FeaturesServiceImpl.java:585)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.doInstallFeature(FeaturesServiceImpl.java:520)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatureDependency(FeaturesServiceImpl.java:585)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.doInstallFeature(FeaturesServiceImpl.java:520)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatureDependency(FeaturesServiceImpl.java:585)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.doInstallFeature(FeaturesServiceImpl.java:520)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:393)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:373)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:362)
    at Proxy074d8ce6_e134_49ec_a9f4_db3e4e5c3697.installFeature(Unknown Source)
    at org.apache.karaf.features.command.InstallFeatureCommand.doExecute(InstallFeatureCommand.java:67)
    at org.apache.karaf.features.command.FeaturesCommandSupport.doExecute(FeaturesCommandSupport.java:38)
    at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)
    at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)
    at org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_45]
    at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_45]
    at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)
    at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)
    at org.apache.karaf.shell.console.commands.$BlueprintCommand1410716997.execute(Unknown Source)[37:org.apache.karaf.shell.console:3.0.1]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_45]
    at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_45]
    at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)
    at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)
    at org.apache.karaf.shell.console.commands.$BlueprintCommand1410716997.execute(Unknown Source)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
    at org.apache.karaf.shell.console.impl.jline.ConsoleImpl$DelegateSession.execute(ConsoleImpl.java:521)
    at org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:212)
    at java.lang.Thread.run(Thread.java:744)[:1.7.0_45]
    at org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService$3.doRun(ConsoleFactoryService.java:126)[37:org.apache.karaf.shell.console:3.0.1]
    at org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService$3$1.run(ConsoleFactoryService.java:117)
    at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_45]
    at org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:47)[38:org.apache.karaf.jaas.modules:3.0.1]
    at org.apache.karaf.shell.console.impl.jline.ConsoleFactoryService$3.run(ConsoleFactoryService.java:115)[37:org.apache.karaf.shell.console:3.0.1]
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.servicemix.specs:org.apache.servicemix.specs.activation-api-1.1:jar:2.2.0 from/to central (http://repo1.maven.org/maven2/): Error transferring file: 连接超时
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:951)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:669)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)[5:org.ops4j.pax.url.mvn:1.6.0]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_45]
    at java.lang.Thread.run(Thread.java:744)[:1.7.0_45]
Caused by: org.apache.maven.wagon.TransferFailedException: Error transferring file: 连接超时
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:143)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)[5:org.ops4j.pax.url.mvn:1.6.0]
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:601)[5:org.ops4j.pax.url.mvn:1.6.0]
    ... 4 more
Caused by: java.net.ConnectException: 连接超时
    at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.7.0_45]
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)[:1.7.0_45]
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)[:1.7.0_45]
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)[:1.7.0_45]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.7.0_45]
    at java.net.Socket.connect(Socket.java:579)[:1.7.0_45]
    at java.net.Socket.connect(Socket.java:528)[:1.7.0_45]
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)[:1.7.0_45]
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)[:1.7.0_45]
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)[:1.7.0_45]
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)[:1.7.0_45]
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)[:1.7.0_45]
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)[:1.7.0_45]
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)[:1.7.0_45]
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)[:1.7.0_45]
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)[:1.7.0_45]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)[:1.7.0_45]
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)[:1.7.0_45]
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:115)[5:org.ops4j.pax.url.mvn:1.6.0]
    ... 8 more
2014-07-29 15:01:29,514 | ERROR | Local user karaf | ShellUtil                        | 37 - org.apache.karaf.shell.console - 3.0.1 | Exception caught while executing command
**************************************
【分析】
从maven库下载资源文件时,提示连接被拒绝。
【解决】
实际是maven没有开启使用http代理的功能。开启该功能的配置步骤如下:
1/2.修改${karaf_home}/etc/org.ops4j.pax.url.mvn.cfg
【org.ops4j.pax.url.mvn.cfg】
(1).org.ops4j.pax.url.mvn.settings=/maven/conf/settings.xml
(2).org.ops4j.pax.url.mvn.proxySupport=true
2/2.创建文件【/maven/conf/settings.xml】,样例如下:
/////////begin//////
<settings>
<proxies>                                                                                                                                   
  <proxy>                                                                
    <id>optional</id>                                                    
    <active>true</active>                                                
    <protocol>http</protocol>                                            
    <host>xx.xx.xx.xx</host>                                       
    <port>8080</port>
    <nonProxyHosts>localhost|127.0.0.1|10.*.*.*|cnd</nonProxyHosts> 
    </proxy>                                                               
</proxies>
</settings>
/////////end////////

你可能感兴趣的:(maven,karaf)