Open GoogleCodeExporter opened 9 years ago
a quick source code investigation revealed many calls
toSystem.getenv(JWebSocketServerConstants.JWEBSOCKET_HOME) throughout whole
JWebSocket implementation and all of them used to retrieve the configuration
files
I believe that these calls need to be replaced with calls to
System.getProperty(JWebSocketServerConstants.JWEBSOCKET_HOME which is initially
being assigned at startup (JWebSocketFactory.start,
JWebSocketFactory.setProperties)
thus, initially overriding JWebSocketServerConstants.JWEBSOCKET_HOME in
JWebSocketFactory will force the alternative configuration location to whole
JWebSocket implementation
it is just an idea, I cannot be sure if this will work
please advise and provide a solution/workaround without using environment
variables
Original comment by eliasbal...@gmail.com
on 8 Jan 2012 at 1:15
this issue is a duplicate of issue #135 - "jwebsocket will not run on tomcat
without JWEBSOCKET_HOME defined (fix suggested)"
Original comment by eliasbal...@gmail.com
on 8 Jan 2012 at 1:18
it actually worked, application started successfully
I modified my local copy replacing all
"System.getenv(JWebSocketServerConstants.JWEBSOCKET_HOME)" calls with
"System.getProperty(JWebSocketServerConstants.JWEBSOCKET_HOME)"
and
explicitly setting JWebSocketServerConstants.JWEBSOCKET_HOME property using
"System.setProperty(JWebSocketServerConstants.JWEBSOCKET_HOME)" before calling
"JWebSocketfactory.start()" in ContextListener
Original comment by eliasbal...@gmail.com
on 8 Jan 2012 at 3:37
I forgot to mention,
I also modified implementation for JWebSocketfactory.setProperties
...
if (
System.getProperty(JWebSocketServerConstants.JWEBSOCKET_HOME)
==null
) {
System.setProperty(
JWebSocketServerConstants.JWEBSOCKET_HOME,
System.getenv(JWebSocketServerConstants.JWEBSOCKET_HOME)
);
}
...
please provide a more efficient workaround/solution and include in next release
Original comment by eliasbal...@gmail.com
on 8 Jan 2012 at 7:55
furthermore, I see many references to environment variable JWEBSOCKET_HOME in
configuration files
which are replaced in implementation with values of respective environment
variables in Tools.expandEnvVars
e.g. ${JWEBSOCKET_HOME} is replaced with value of environment variable
JWEBSOCKET_HOME
replacing implementation of Tools.expandEnvVars in local copy to use java
properties instead of environment variables
please provide a more efficient workaround/solution and include in next release
Original comment by eliasbal...@gmail.com
on 8 Jan 2012 at 10:06
replaced implementation of Tools.expandVars giving priority to Java properties
instead of environment variables
public static String expandEnvVars(String aString) {
Map<String, String> vars = new HashMap<String, String>();
Properties properties = System.getProperties();
String property;
for (Object key : properties.keySet()) {
if (key instanceof String) {
property = (String)key;
vars.put(
property,
properties.getProperty(
property
)
);
}
}
aString = expandVars(aString, vars, EXPAND_CASE_INSENSITIVE);
vars = System.getenv();
return expandVars(aString, vars, EXPAND_CASE_INSENSITIVE);
}
it worked,
however, I am not sure whether this is the best workaround
please provide a more efficient workaround/solution and include in next release
Original comment by eliasbal...@gmail.com
on 8 Jan 2012 at 10:41
Original issue reported on code.google.com by
eliasbal...@gmail.com
on 8 Jan 2012 at 1:00