'PHP Java bridge exception - protocol error
I am running the PHP-Java bridge server (apache-tomcat). Sometimes I get an intermittent error. It's working when I restart the tomcat server from /opt/apache-tomcat-8.5.43/bin
directory by ./shutdown.sh
and startup.sh
.
25-Jul-2019 13:53:52.766 SEVERE [http-nio-8080-exec-8] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [PhpCGIServlet] in context with path [/JavaBridge] threw exception
php.java.fastcgi.ConnectionException
at php.java.fastcgi.FCGIInputStream.read(FCGIInputStream.java:31)
at php.java.fastcgi.FCGIHeaderParser.parseBody(FCGIHeaderParser.java:82)
at php.java.servlet.fastcgi.FastCGIServlet.doExecute(FastCGIServlet.java:442)
at php.java.servlet.fastcgi.FastCGIServlet.execute(FastCGIServlet.java:468)
at php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:479)
at php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Protocol error
at php.java.fastcgi.FCGIInputStream.doRead(FCGIInputStream.java:56)
at php.java.fastcgi.FCGIInputStream.read(FCGIInputStream.java:29)
Dockerfile:
FROM ubuntu:16.04
MAINTAINER Alexey Nurgaliev <[email protected]>
ENV DEBIAN_FRONTEND=noninteractive
ENV JAVA_BRIDGE_URL="https://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_7.1.3/php-java-bridge_7.1.3_documentation.zip/download"
ENV JAYBIRD_URL="https://github.com/FirebirdSQL/jaybird/releases/download/v2.2.13/Jaybird-2.2.13-JDK_1.8.zip"
ENV JAYBIRD_FILE_NAME="jaybird-full-2.2.13.jar"
ENV POSTGRESQL_URL="https://jdbc.postgresql.org/download/postgresql-9.4.1212.jar"
ENV POSTGRESQL_FILE_NAME="postgresql-9.4.1212.jar"
ENV TOMCAT_VERSION="8.5.43"
ENV TOMCAT_URL="http://apache-mirror.rbc.ru/pub/apache/tomcat/tomcat-8/v8.5.43/bin/apache-tomcat-8.5.43.tar.gz"
ENV TOMCAT_DIR="/opt/apache-tomcat-${TOMCAT_VERSION}"
ENV TOMCAT_LIB_DIR="${TOMCAT_DIR}/webapps/JavaBridge/WEB-INF/lib"
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y unzip wget php-cgi openjdk-8-jre-headless locales && \
apt-get install -y nano && \
apt-get install -y curl wget && \
locale-gen --lang ru_RU.UTF-8
RUN cd /opt &&\
wget -O "tomcat.tar.gz" "${TOMCAT_URL}" &&\
tar -xf "tomcat.tar.gz" &&\
rm "tomcat.tar.gz" &&\
wget -O "JavaBridge.zip" "${JAVA_BRIDGE_URL}" &&\
unzip "JavaBridge.zip" -d "JavaBridge" &&\
unzip -o "JavaBridge/JavaBridge.war" -d "${TOMCAT_DIR}/webapps/JavaBridge" &&\
rm -R JavaBridge &&\
rm JavaBridge.zip &&\
wget -O "jaybird.zip" "${JAYBIRD_URL}" &&\
unzip "jaybird.zip" -d "jaybird" &&\
cp "jaybird/${JAYBIRD_FILE_NAME}" "${TOMCAT_LIB_DIR}" &&\
rm -R "jaybird" &&\
wget "${POSTGRESQL_URL}" &&\
cp "${POSTGRESQL_FILE_NAME}" "${TOMCAT_LIB_DIR}" &&\
rm "${POSTGRESQL_FILE_NAME}"
EXPOSE 8080
CMD LANG=ru_RU.UTF-8 "${TOMCAT_DIR}/bin/catalina.sh" run
Solution 1:[1]
The error message says it had an exception on the connection because of a protocol error. This could happen for various reasons:
Server that needs to be contacted is unavailable at the time the request was made
the php-fcgi is still starting up at the time JAVA was trying to call the application
- you are requesting the data from php using the wrong protocol
If it is the first, you could edit the startup file so tomcat will wait for the other service to start depending on what service you use for this. If you are using systemd, look at this answer: https://unix.stackexchange.com/questions/43202/how-can-i-start-a-systemd-service-only-after-mysql-has-started
You could have a look at the php error-logs, access logs and see if you get errors there that could be of help. You should also look into the messages right above and below the stacktrace you posted. It could be of help for what is going wrong.
Solution 2:[2]
Some of the dependent module related to Protocol are not loaded and therefore resulting in java.io.IOException, it is unable to establish a connection with the target resource.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AltShiftZero |
Solution 2 | qw008 |