0

在 jeety 中,部署项目时 Glassfish 服务器然后在 webapp 中创建一个文件夹,但在 jboss 7 服务器中没有 webapp 文件夹。

jboss 7中的项目部署(文件夹名称)在哪里?

所以有一些问题,比如读取属性文件和图片上传。b'caz 我使用类路径和服务器路径。

对于 jboss 7 中的 ex:获取文件路径:“E:/jboss-as-7.1.1.Final/bin/content/mwp.war/WEB-INF/classes/analytics.properties”

Properties pro = new Properties();
String fileName = this.getClass().getClassLoader().getResource("analytics.properties").getFile();
pro.store(new FileOutputStream(fileName),null);

然后得到错误:

16:21:52,004 ERROR [stderr] (MSC service thread 1-3)    at java.io.FileOutputStream.open(Native Method)
16:21:52,006 ERROR [stderr] (MSC service thread 1-3)    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
16:21:52,007 ERROR [stderr] (MSC service thread 1-3)    at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
16:21:52,008 ERROR [stderr] (MSC service thread 1-3)    at mwp.slktechlabs.model.analytics.AnalyticsDBData.updateAnalyticsPropertiesData(AnalyticsDBData.ja
va:95)
16:21:52,010 ERROR [stderr] (MSC service thread 1-3)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:21:52,011 ERROR [stderr] (MSC service thread 1-3)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
16:21:52,013 ERROR [stderr] (MSC service thread 1-3)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:21:52,015 ERROR [stderr] (MSC service thread 1-3)    at java.lang.reflect.Method.invoke(Method.java:601)
16:21:52,016 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleEle
ment.invoke(InitDestroyAnnotationBeanPostProcessor.java:340)
16:21:52,018 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMet
adata.invokeDestroyMethods(InitDestroyAnnotationBeanPostProcessor.java:305)
16:21:52,020 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessB
eforeDestruction(InitDestroyAnnotationBeanPostProcessor.java:148)
16:21:52,023 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.ja
va:166)
16:21:52,025 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingle
tonBeanRegistry.java:487)
16:21:52,027 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultS
ingletonBeanRegistry.java:463)
16:21:52,029 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(Default
SingletonBeanRegistry.java:431)
16:21:52,031 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationC
ontext.java:1053)
16:21:52,033 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContex
t.java:463)
16:21:52,035 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:294
)
16:21:52,036 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:215)
16:21:52,038 ERROR [stderr] (MSC service thread 1-3)    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.j
ava:47)
16:21:52,040 ERROR [stderr] (MSC service thread 1-3)    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392)
16:21:52,041 ERROR [stderr] (MSC service thread 1-3)    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850)
16:21:52,043 ERROR [stderr] (MSC service thread 1-3)    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
16:21:52,045 ERROR [stderr] (MSC service thread 1-3)    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:18
11)
16:21:52,046 ERROR [stderr] (MSC service thread 1-3)    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
16:21:52,048 ERROR [stderr] (MSC service thread 1-3)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
16:21:52,050 ERROR [stderr] (MSC service thread 1-3)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
16:21:52,051 ERROR [stderr] (MSC service thread 1-3)    at java.lang.Thread.run(Thread.java:722)

那么如何消除这个错误呢?

谢谢,卡姆莱什

4

1 回答 1

1

尝试这个:

Properties prop = new Properties();
InputStream is = this.getClass().getClassLoader().getResourceAsStream( "path" );
BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf8"));
prop.load(br); 

例如在我的战争中,我有属性 ingo resources/config/myprop.properties,我的“路径”是 config/myprop.properties

如果您使用 hot deeploy(仅在独立模式下运行),jboss as 7 的部署文件夹很少你的项目

但是如果你使用mavej jboss插件并使用命令jboss-as:deploy所以jboss将你的项目部署到/usr/local/jboss7/standalone/data/content

于 2012-08-24T19:39:01.090 回答