java无法加载属性
您好,我打算用java(NetBeans)开发web服务,但是get Conconnect有问题,我遇到以下错误:
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.net.UnknownHostException: C
Caused by: java.net.UnknownHostException: C
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:957)
at sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:917)
at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1012)
at sun.net.ftp.impl.FtpClient.connect(FtpClient.java:998)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:294)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:393)
at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:103)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:179)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:158)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(Proper at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:68)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:334)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:76)
at com.rsa.ims.components.spring.SimpleApplicationLoader.loadBeanFactory(SimpleApplicationLoader.java:134)
at com.rsa.ims.components.spring.SimpleApplicationLoader.useBeanFactory(SimpleApplicationLoader.java:105)
at com.rsa.command.ConnectionFactory.getSpringBeanTarget(ConnectionFactory.java:183)
at com.rsa.command.ConnectionFactory.getTarget(ConnectionFactory.java:156)
at com.rsa.command.ConnectionFactory.getConnection(ConnectionFactory.java:238)
at com.rsa.command.ConnectionFactory.getConnection(ConnectionFactory.java:281)
at com.arame.rsa.cmdConnection.getConnection(cmdConnection.java:33)
at com.arame.rsa.ApiRsaTest.main(ApiRsaTest.java:49)
Exception in thread "main" java.lang.NullPointerException
at com.arame.rsa.cmdConnection.closeConnection(cmdConnection.java:59)
at com.arame.rsa.ApiRsaTest.main(ApiRsaTest.java:94)
我有配置文件。属性,其中是URL和上下文。xml支持从文件配置中检索属性的文件处理。属性也有log4j。xml/dtd将它们都放在我的类路径中
这是我的背景。xml
<beans default-lazy-init="true" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">
<bean name="PrimaryPropertyPlaceHolderPostProcessor" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="10"/>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="location" value="file://C:\\Users\\gerardo.granados\\Documents\\APITest\\build\\classes\\config.properties"/>
<property name="ignoreUnresolvablePlaceholders" value="false"/>
<property name="ignoreResourceNotFound" value="false"/>
</bean>
<bean name="ConnectionInfoProvider"
class="com.rsa.command.PropertiesConnectionInfoProvider"
lazy-init="false">
<property name="propertiesFile" value="config.properties"/>
</bean>
<alias alias="CommandAPIConnection" name="SOAPCommandTargetBasicAuth"/>
<bean name="ClusterTarget" lazy-init="true"
class="com.rsa.command.RemoteCommandTargetFactoryBean">
<property name="providerURL" value="t3s://node1-address,node2-address:7002"/>
<property name="connectionInfoProvider" ref="ConnectionInfoProvider"/>
<property name="targetClass" value="com.rsa.command.EJBRemoteTarget"/>
<property name="cacheable" value="true"/>
</bean>
<bean name="SpecificNodeTarget" lazy-init="true"
class="com.rsa.command.RemoteCommandTargetFactoryBean">
<property name="providerURL" value="t3s://node2-address:7002"/>
<property name="connectionInfoProvider" ref="ConnectionInfoProvider"/>
<property name="targetClass" value="com.rsa.command.EJBRemoteTarget"/>
<property name="cacheable" value="true"/>
<property name="properties">
<props>
<prop key="com.rsa.naming.pin.to.primary.server">true</prop>
</props>
</property>
</bean>
</beans>
有什么建议吗????谢谢
# 1 楼答案
在这一行:
删除
file:
之后的前两个斜杠。像这样:这在相关问题上对我起了作用