cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco 3.2 as a Unix Daemon

garcimouche
Champ in-the-making
Champ in-the-making
Hi there,

I can't have Alfresco 3.2 CE running properly as a Unix Daemon under RHEL 5.
I followed the steps to build the jsvc tool as described here : http://tomcat.apache.org/tomcat-6.0-doc/setup.html#Unix%20daemon .
I've created the following script that I correctly register using chkconfig shell command.

#!/bin/sh
# alsfresco    Startup script for the Alfresco ECM
#
# chkconfig: - 99 15
# description: Alfresco CM Software (Embedded Tomcat) for FTNC
# pidfile: /var/run/jsvc.pid
##############################################################################
#
#   Copyright 2004 The Apache Software Foundation.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#    <!– Define a non-SSL HTTP/1.1 Connector on port 80 –>
#    <Connector className="org.apache.catalina.connector.http.HttpConnector"
#               port="80" minProcessors="5" maxProcessors="75"
#               enableLookups="true" redirectPort="8443"
#               acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration

ALF_HOME=/usr/alfresco

JAVA_HOME=/usr/java/jdk1.6.0_14
APPSERVER="${ALF_HOME}/tomcat"
CATALINA_HOME="${APPSERVER}"
DAEMON_HOME="${CATALINA_HOME}/bin"

# Set the default -Djava.endorsed.dirs argument
JAVA_ENDORSED_DIRS="$APPSERVER"/endorsed

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE="${APPSERVER}"

#CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"

# Set any default JVM values
export JAVA_OPTS='-Xms128m -Xmx512m -XX:MaxPermSize=128m'
export JAVA_OPTS="${JAVA_OPTS} -Dalfresco.home=${ALF_HOME} -Dcom.sun.management.jmxremote"
# Following only needed for Sun JVMs before to 1.5 update 8
export JAVA_OPTS="${JAVA_OPTS} -XX:CompileCommand=exclude,org/apache/lucene/index/IndexReader\$1,doBody -XX:CompileCommand=exclude,org/alfresco/repo/search/impl/lucene/index/IndexInfo\$Merger,mergeIndexes -XX:CompileCommand=exclude,org/alfresco/repo/search/impl/lucene/index/IndexInfo\$Merger,mergeDeletions"


CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
  start)
    #
    # Start Tomcat
    #
    $DAEMON_HOME/jsvc \
    -user root \
    -verbose \
    -home $JAVA_HOME \
    -jvm server \
    -nodetach \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.io.tmpdir=$TMP_DIR \
    -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
     $JAVA_OPTS \
    -wait 300 \
    -pidfile $PID_FILE \
    -outfile $CATALINA_HOME/logs/catalina.out \
    -errfile '&1' \
    -debug \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap "$@" start
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    exit $?
    ;;

  stop)
    #
    # Stop Tomcat
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap "$@" stop
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac
When I start my service, I've got the following errors in catalina.out:

…..
13:13:52,701  INFO  [alfresco.config.JndiPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/alfresco-shared.properties]
java.net.UnknownHostException: basename
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
   at java.net.Socket.connect(Socket.java:519)
   at java.net.Socket.connect(Socket.java:469)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
   at sun.net.NetworkClient.openServer(NetworkClient.java:118)
   at sun.net.ftp.FtpClient.openServer(FtpClient.java:488)
   at sun.net.ftp.FtpClient.openServer(FtpClient.java:475)
   at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:270)
   at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:352)
   at java.net.URL.openStream(URL.java:1009)
   at org.apache.xml.resolver.Catalog.parseCatalogFile(Unknown Source)
   at org.apache.xml.resolver.Catalog.parsePendingCatalogs(Unknown Source)
   at org.apache.xml.resolver.Catalog.parseCatalog(Unknown Source)
   at org.apache.xml.resolver.Catalog.loadSystemCatalogs(Unknown Source)
   at org.apache.xml.resolver.CatalogManager.getPrivateCatalog(Unknown Source)
   at org.apache.xml.resolver.CatalogManager.getCatalog(Unknown Source)
   at org.apache.xml.resolver.tools.CatalogResolver.initializeCatalogs(Unknown Source)
   at org.apache.xml.resolver.tools.CatalogResolver.<init>(Unknown Source)
   at org.apache.cxf.catalog.OASISCatalogManager.<init>(OASISCatalogManager.java:60)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
   at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:757)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:722)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:69)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:516)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
…..
…..
13:14:36,297  DEBUG [org.alfresco.fileserver] [SMB] Server error : org.alfresco.jlan.server.config.InvalidConfigurationException: Error initializing TCP-IP SMB session handler, Permission denied
13:14:36,301  DEBUG [org.alfresco.fileserver] org.alfresco.jlan.server.config.InvalidConfigurationException: Error initializing TCP-IP SMB session handler, Permission denied
13:14:36,301  DEBUG [org.alfresco.fileserver]    at org.alfresco.jlan.smb.server.nio.NIOCifsConnectionsHandler.initializeHandler(NIOCifsConnectionsHandler.java:256)
13:14:36,301  DEBUG [org.alfresco.fileserver]    at org.alfresco.jlan.smb.server.SMBServer.run(SMBServer.java:512)
13:14:36,301  DEBUG [org.alfresco.fileserver]    at java.lang.Thread.run(Thread.java:619)
…..

The Alfresco web applications got deployed and I can access them with my browser through port 8080. But I cannot access the CIFS server. If I run it manually using alfresco.sh script, everything is fine, I don't have any errors and I can access the CIFS server.

Any help is appreciated
8 REPLIES 8

ofrxnz
Champ in-the-making
Champ in-the-making
Cifs and FTP use ports below 1024.  in RHEL these are privileged ports and non-root users cant touch them.

however, you can configure your firewall for portforwarding

in the alfresco-global.properties file you will need something like this
cifs.enabled=true
cifs.Server.Name=server
cifs.domain=DOMAIN
cifs.hostanounce=true

cifs.broadcast=0.0.0.0
cifs.tcpipSMB.port=1445
cifs.ipv6.enabled=false
cifs.netBIOSSMB.namePort=1137
cifs.netBIOSSMB.datagramPort=1138
cifs.netBIOSSMB.sessionPort=1139

and to configure the firewall….

iptables -I INPUT -p tcp –dport 445 -j ACCEPT
iptables -I INPUT -p tcp –dport 139 -j ACCEPT
iptables -I INPUT -p udp –dport 137 -j ACCEPT
iptables -I INPUT -p udp –dport 138 -j ACCEPT
iptables -I INPUT -p tcp –dport 1445 -j ACCEPT
iptables -I INPUT -p tcp –dport 1139 -j ACCEPT
iptables -I INPUT -p udp –dport 1137 -j ACCEPT
iptables -I INPUT -p udp –dport 1138 -j ACCEPT

iptables -t nat -A PREROUTING -p tcp –dport 445 -j REDIRECT –to-ports 1445
iptables -t nat -A PREROUTING -p tcp –dport 139 -j REDIRECT –to-ports 1139
iptables -t nat -A PREROUTING -p udp –dport 137 -j REDIRECT –to-ports 1137
iptables -t nat -A PREROUTING -p udp –dport 138 -j REDIRECT –to-ports 1138

these changes will not persist a reboot….so when you have it working type "service iptables save"

garcimouche
Champ in-the-making
Champ in-the-making
Thank you for the response, it's working like this  Smiley Tongue . However I still don't understand why I cannot bind to privilege ports when I'm running the service as root (jsvc -user root)??? :?:

ofrxnz
Champ in-the-making
Champ in-the-making
When you start alfresco with the script, which user owns the "java" process with tons of ram? or if yours isnt called java, who owns it?

sorry if you know this but…
i usually find this with the "top" comand and use "shift" and ">" or "shift" and "<" to change the sort

Adam

garcimouche
Champ in-the-making
Champ in-the-making
root

ofrxnz
Champ in-the-making
Champ in-the-making
no idea why it wont let you touch ports <1024…..maybe there is some sort of SElinux or other security measure in place that recognizes its a daemon…..

Another thing could be some other service already has those ports….do you have some sort of file server running on the server?

echooooo
Champ in-the-making
Champ in-the-making
I notice that there hasn't really been any resolution to this problem.  I run into what appears to be the exact same issue on Alfresco Community Edition, ver 3.4 when attempting to run as a service under Red Hat (Fedora, actually), as root using the standard "# service alfresco start" command – even with SELinux disabled.  However, I do not receive this error (i.e. works OK) if I start the application via the old "# /opt/alfresco/aslfresco.sh start" command.

dward
Champ on-the-rise
Champ on-the-rise
Solution is in https://issues.alfresco.com/jira/browse/ALF-8316 . This is caused by https://issues.apache.org/jira/browse/XMLCOMMONS-28 . Your script must cd to a writeable directory other than / before running alfresco.

scottcarson
Champ in-the-making
Champ in-the-making
For those of us (i.e. me) who need it spelled out:

Edit the alfresco startup script (mine is /etc/init.d/alfresco ). Specifically, in the start() section, do something like this:

cd /opt/Alfresco
rm tomcat/temp/catalina.pid
./alfresco.sh start "$2"