Redian新闻
>
tomcat7部署war,jar写权限无法获得
avatar
tomcat7部署war,jar写权限无法获得# Java - 爪哇娇娃
y*e
1
接手了一个别人的项目,目前功能部分已经调通了,现在前端部署遇到了一些问题。前
端才用zk,zk里面嵌入一些java code。
整个page,data打包成DCL.war,我把它拷贝到/var/lib/tomcat7/webapps/下面,chmod
to 755, chown to tomcat7:tomcat7.运行localhost:8080/DCL/解压,页面正常显示~
但是运行提交页面的时候出现java.io.FileNotFoundException: cache.csv (Permissi
on denied)
这个cache.csv.是从我的某个jar写出来的,我改了相应目录的权限好像还是不行,我在
‘/etc/tomcat7/policy.d/03catalina.policy’加入了写权限:
grant codeBase "file:${catalina.base}/webapps/DCL.war" {
permission java.security.AllPermission;
permission java.io.FilePermission "file:${catalina.base}/webapps/DCL/-", "
read, write";
}
grant {
permission java.io.FilePermission "file:${catalina.base}/webapps/DCL/WEB-I
NF/lib/-", "read, write";
}
好像还是,不知道问题出在哪里。
大家帮忙看看哈~~
谢谢!
avatar
g*g
2
Usually this is about the user that starts the tomcat. That user needs
to have write priviledge to that directory.

chmod
示~
Permissi
我在

【在 y****e 的大作中提到】
: 接手了一个别人的项目,目前功能部分已经调通了,现在前端部署遇到了一些问题。前
: 端才用zk,zk里面嵌入一些java code。
: 整个page,data打包成DCL.war,我把它拷贝到/var/lib/tomcat7/webapps/下面,chmod
: to 755, chown to tomcat7:tomcat7.运行localhost:8080/DCL/解压,页面正常显示~
: 但是运行提交页面的时候出现java.io.FileNotFoundException: cache.csv (Permissi
: on denied)
: 这个cache.csv.是从我的某个jar写出来的,我改了相应目录的权限好像还是不行,我在
: ‘/etc/tomcat7/policy.d/03catalina.policy’加入了写权限:
: grant codeBase "file:${catalina.base}/webapps/DCL.war" {
: permission java.security.AllPermission;

avatar
y*e
3
tomcat7 is started when first boot up. Is it root or my account or tomcat7
user. My account has admin priviledge that allows writes. I change owner of
the DCL.war to tomcat7. Is this right?
Many thanks.

【在 g*****g 的大作中提到】
: Usually this is about the user that starts the tomcat. That user needs
: to have write priviledge to that directory.
:
: chmod
: 示~
: Permissi
: 我在

avatar
e*t
4
先chmod 777,看看能不能解决问题

chmod
示~
Permissi
我在

【在 y****e 的大作中提到】
: 接手了一个别人的项目,目前功能部分已经调通了,现在前端部署遇到了一些问题。前
: 端才用zk,zk里面嵌入一些java code。
: 整个page,data打包成DCL.war,我把它拷贝到/var/lib/tomcat7/webapps/下面,chmod
: to 755, chown to tomcat7:tomcat7.运行localhost:8080/DCL/解压,页面正常显示~
: 但是运行提交页面的时候出现java.io.FileNotFoundException: cache.csv (Permissi
: on denied)
: 这个cache.csv.是从我的某个jar写出来的,我改了相应目录的权限好像还是不行,我在
: ‘/etc/tomcat7/policy.d/03catalina.policy’加入了写权限:
: grant codeBase "file:${catalina.base}/webapps/DCL.war" {
: permission java.security.AllPermission;

avatar
r*l
5
Tomcat should use “jsvc” to start itself as a service. "jsvc" has a
command line parameter "--user". Most probably that user is set to tomcat.
Check the init file, in /etc/init.d if you use RHEL.

of

【在 y****e 的大作中提到】
: tomcat7 is started when first boot up. Is it root or my account or tomcat7
: user. My account has admin priviledge that allows writes. I change owner of
: the DCL.war to tomcat7. Is this right?
: Many thanks.

avatar
y*e
6
I changed everything tomcat7 possibly can touch to 777. Looks like it's not
working.

【在 e*****t 的大作中提到】
: 先chmod 777,看看能不能解决问题
:
: chmod
: 示~
: Permissi
: 我在

avatar
y*e
7
I checked /etc/init.d/tomcat7. --user was followed by TOMCAT7_USER, TOMCAT7_
USER=tomcat7. What else I need to check? I can provide more information if
needed.

【在 r*****l 的大作中提到】
: Tomcat should use “jsvc” to start itself as a service. "jsvc" has a
: command line parameter "--user". Most probably that user is set to tomcat.
: Check the init file, in /etc/init.d if you use RHEL.
:
: of

avatar
r*l
8
That means user "tomcat7" is running tomcat. After it's running, you can run
this command to confirm:
ps -ef|grep tomcat
As goodbug said, just give tomcat7 the right permission to the file/dir.

TOMCAT7_

【在 y****e 的大作中提到】
: I checked /etc/init.d/tomcat7. --user was followed by TOMCAT7_USER, TOMCAT7_
: USER=tomcat7. What else I need to check? I can provide more information if
: needed.

avatar
g*g
9
You should show the full exception stack, maybe there's something
else. You should give the user the priviledge to the folder you want
to write, the war file doesn't count.
Sometimes you get permission denied in writing because the
folder doesn't exist.

TOMCAT7_

【在 y****e 的大作中提到】
: I checked /etc/init.d/tomcat7. --user was followed by TOMCAT7_USER, TOMCAT7_
: USER=tomcat7. What else I need to check? I can provide more information if
: needed.

avatar
y*e
10
ava.io.FileNotFoundException: cache.csv (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:212)
at java.io.FileWriter.(FileWriter.java:107)
at edu.uiuc.cs.datacenterplacement.location.DataCache.addValue(
DataCache.java:98)
at edu.uiuc.cs.datacenterplacement.location.CoordinatesManager.
searchLocationPostalCode(CoordinatesManager.java:73)
at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeStaticMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHVariableDeclarator.eval(Unknown Source)
at bsh.BSHTypedVariableDeclaration.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHForStatement.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BSHForStatement.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BshMethod.invokeImpl(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.Name.invokeLocalMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
I change the permission/owner of the folder and file, I can provide further
info if needed.
I don't know where did the code write to 'cache.csv'. Do you think a redo of
war file will help? BTW, how do I generate war file correctly(with
configuration, every setting right)?
Many thanks!

【在 g*****g 的大作中提到】
: You should show the full exception stack, maybe there's something
: else. You should give the user the priviledge to the folder you want
: to write, the war file doesn't count.
: Sometimes you get permission denied in writing because the
: folder doesn't exist.
:
: TOMCAT7_

avatar
y*e
11
tomcat7 2888 1 2 20:26 ? 00:00:19 /usr/lib/jvm/jdk1.7.0_03/bin
/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.
properties -Djava.library.path=/ssd_back/workspace/CDPlacement/
DCPlacementCore/lib -Djava.awt.headless=true -Xmx128m -XX:+
UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.
ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -
classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat
-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/
tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.
startup.Bootstrap start

run

【在 r*****l 的大作中提到】
: That means user "tomcat7" is running tomcat. After it's running, you can run
: this command to confirm:
: ps -ef|grep tomcat
: As goodbug said, just give tomcat7 the right permission to the file/dir.
:
: TOMCAT7_

avatar
T*U
12
edu.uiuc.cs.datacenterplacement.location.DataCache.addValue(
DataCache.java:98)
maybe the project was developed on windows platform and save the file to an
external location. check the above source and see if you can find the proble
m.

【在 y****e 的大作中提到】
: ava.io.FileNotFoundException: cache.csv (Permission denied)
: at java.io.FileOutputStream.open(Native Method)
: at java.io.FileOutputStream.(FileOutputStream.java:212)
: at java.io.FileWriter.(FileWriter.java:107)
: at edu.uiuc.cs.datacenterplacement.location.DataCache.addValue(
: DataCache.java:98)
: at edu.uiuc.cs.datacenterplacement.location.CoordinatesManager.
: searchLocationPostalCode(CoordinatesManager.java:73)
: at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
: at sun.reflect.DelegatingMethodAccessorImpl.invoke(

avatar
y*e
13
cache.csv was created in class DataCache.
public class DataCache {
private static final String FILENAME = "cache.csv";
private static final double TOLERANCE = 0.1;
private static List memCacheCoord = new ArrayList<
Coordinate>()
;
private static List memCacheConte = new ArrayList();
.....
public static void addValue(double lat, double lng, Object data) {
try {
DecimalFormat format = new DecimalFormat("####.##");
String line = format.format(lat)+";"+format.format(
lng)+";"+toString(data
)+"\n";
// Store in file
FileWriter writer = new FileWriter(new File(FILENAME
), true);
writer.write(line);
writer.flush();
writer.close();
// Store in memory
memCacheCoord.add(new Coordinate(lat, lng));
memCacheConte.add(line);
} catch (IOException e1) {
e1.printStackTrace();
}
}
.....
};
I am not sure where exactly cache.csv was written to.

an
proble

【在 T****U 的大作中提到】
: edu.uiuc.cs.datacenterplacement.location.DataCache.addValue(
: DataCache.java:98)
: maybe the project was developed on windows platform and save the file to an
: external location. check the above source and see if you can find the proble
: m.

avatar
g*g
14
You need to find out where this path is. Use
File.getAbsolutePath() to determine that. My guess is this
pointing to a shared tomcat directory that's not writtable, not
the app home directory.
Or you may append a temp directory before the hardcoded filename.
System.getProperty("java.io.tmpdir"));

);

【在 y****e 的大作中提到】
: cache.csv was created in class DataCache.
: public class DataCache {
: private static final String FILENAME = "cache.csv";
: private static final double TOLERANCE = 0.1;
: private static List memCacheCoord = new ArrayList<
: Coordinate>()
: ;
: private static List memCacheConte = new ArrayList();
: .....
: public static void addValue(double lat, double lng, Object data) {

avatar
T*U
15
check if you can create a file "cache.csv" at where the application is deplo
yed. chmod it to 777, and then try running your program again.

);

【在 y****e 的大作中提到】
: cache.csv was created in class DataCache.
: public class DataCache {
: private static final String FILENAME = "cache.csv";
: private static final double TOLERANCE = 0.1;
: private static List memCacheCoord = new ArrayList<
: Coordinate>()
: ;
: private static List memCacheConte = new ArrayList();
: .....
: public static void addValue(double lat, double lng, Object data) {

avatar
y*e
16
Looks like there is still problems when packing the war files. When I made
changes, the changes didn't reflected on the war files. Wierd. I will check
it out.

【在 g*****g 的大作中提到】
: You need to find out where this path is. Use
: File.getAbsolutePath() to determine that. My guess is this
: pointing to a shared tomcat directory that's not writtable, not
: the app home directory.
: Or you may append a temp directory before the hardcoded filename.
: System.getProperty("java.io.tmpdir"));
:
: );

avatar
y*e
17
I will try.

deplo

【在 T****U 的大作中提到】
: check if you can create a file "cache.csv" at where the application is deplo
: yed. chmod it to 777, and then try running your program again.
:
: );

avatar
y*e
18
I fixed it using some quick and dirty tricks. I hard-code from 'cache.csv' t
o '/tmp/cache.csv'. Now it works fine.
But I still have problems generating the war file, I just replace the jar fi
le inside the deployed directory. Is there any book on how to manage large s
cale java code? Debuging using Eclipse and packing using maven is really tri
cky to me.
Thanks all

【在 g*****g 的大作中提到】
: You need to find out where this path is. Use
: File.getAbsolutePath() to determine that. My guess is this
: pointing to a shared tomcat directory that's not writtable, not
: the app home directory.
: Or you may append a temp directory before the hardcoded filename.
: System.getProperty("java.io.tmpdir"));
:
: );

avatar
m*r
19
what i found to be the easiest way for me is to generate a stub war maven
project, and use the eclipse plug in to generate the project file for
eclipse.

t
fi
s
tri

【在 y****e 的大作中提到】
: I fixed it using some quick and dirty tricks. I hard-code from 'cache.csv' t
: o '/tmp/cache.csv'. Now it works fine.
: But I still have problems generating the war file, I just replace the jar fi
: le inside the deployed directory. Is there any book on how to manage large s
: cale java code? Debuging using Eclipse and packing using maven is really tri
: cky to me.
: Thanks all

avatar
s*e
20
It is tricky to package, debug, and deploy a large scale (many times, they
are modulized) web app in eclipse.
My experience is:
1. find one complete maven book
2. google some maven project samples.
3. pay attention to plugins.

t
fi
s
tri

【在 y****e 的大作中提到】
: I fixed it using some quick and dirty tricks. I hard-code from 'cache.csv' t
: o '/tmp/cache.csv'. Now it works fine.
: But I still have problems generating the war file, I just replace the jar fi
: le inside the deployed directory. Is there any book on how to manage large s
: cale java code? Debuging using Eclipse and packing using maven is really tri
: cky to me.
: Thanks all

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。