CGI script error java RMI - java

Im trying to set up a cgi script for my RMI webserver, but it is giving me an HTTP 500 all the time.
My CGI script look like this.
# This class will support a QUERY_STRING of the form "forward=<port>"
# with a REQUEST_METHOD "POST". The body of the request will be
# forwarded (as another POST request) to the server listening on the
# specified port (must be >= 1024). The response from this forwarded
# request will be the response to the original request.
#
# CONFIGURATION:
#
# Fill in correct absolute path to Java interpreter below. For example,
# the "PATH=" line might be changed to the follow if the JDK is installed
# at the path "/home/peter/java":
#
# PATH=/home/peter/java/bin:$PATH
#
PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
exec java \
-DAUTH_TYPE="$AUTH_TYPE" \
-DCONTENT_LENGTH="$CONTENT_LENGTH" \
-DCONTENT_TYPE="$CONTENT_TYPE" \
-DGATEWAY_INTERFACE="$GATEWAY_INTERFACE" \
-DHTTP_ACCEPT="$HTTP_ACCEPT" \
-DPATH_INFO="$PATH_INFO" \
-DPATH_TRANSLATED="$PATH_TRANSLATED" \
-DQUERY_STRING="$QUERY_STRING" \
-DREMOTE_ADDR="$REMOTE_ADDR" \
-DREMOTE_HOST="$REMOTE_HOST" \
-DREMOTE_IDENT="$REMOTE_IDENT" \
-DREMOTE_USER="$REMOTE_USER" \
-DREQUEST_METHOD="$REQUEST_METHOD" \
-DSCRIPT_NAME="$SCRIPT_NAME" \
-DSERVER_NAME="$SERVER_NAME" \
-DSERVER_PORT="$SERVER_PORT" \
-DSERVER_PROTOCOL="$SERVER_PROTOCOL" \
-DSERVER_SOFTWARE="$SERVER_SOFTWARE" \
sun.rmi.transport.proxy.CGIHandler
In my access.log it says:
"POST /cgi-bin/java-rmi.cgi?forward=1099 HTTP/1.1" 500 415 "-" "Java/1.7.0"
In my error.log it says:
(104)Connection reset by peer: ap_content_length_filter: apr_bucket_read() failed
I am using RMISocketFactory.setSocketFactory(new sun.rmi.transport.proxy.RMIHttpToCGISocketFactory()); to force Http-to-cgi.
I can't figure out what i'm doing wrong..
I have put my java-rmi.cgi file in /usr/lib/cgi-bin/
Am i suppose to add something else to the script?
The java error i get is:
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.IOException: HTTP request failed
EDIT: Visiting my cgi script as a website it give me(maybe you can't do that):
Java RMI Client Error
invalid command.
I traced this into the CGICommandHandler.java and it returns invalid command when the handler is null.
This is the debug output when i run bash -x:
+ PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ exec java -DAUTH_TYPE= -DCONTENT_LENGTH= -DCONTENT_TYPE= -DGATEWAY_INTERFACE= -DHTTP_ACCEPT= -DPATH_INFO= -DPATH_TRANSLATED= -DQUERY_STRING= -DREM OTE_ADDR= -DREMOTE_HOST= -DREMOTE_IDENT= -DREMOTE_USER= -DREQUEST_METHOD= -DSCRIPT_NAME= -DSERVER_NAME= -DSERVER_PORT= -DSERVER_PROTOCOL= -DSERVER_S OFTWARE= sun.rmi.transport.proxy.CGIHandler
Status: 400 Bad Request: invalid command.
Content-type: text/html
<HTML><HEAD><TITLE>Java RMI Client Error</TITLE></HEAD><BODY>
<H1>Java RMI Client Error</H1>
invalid command.
</BODY></HTML>
And if i echo out my cgi i file i get this:
AUTH_TYPE=
CONTENT_LENGTH=
CONTENT_TYPE=
GATEWAY_INTERFACE=CGI/1.1 HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 PATH_INFO=
PATH_TRANSLATED=
QUERY_STRING=
REMOTE_ADDR=xx.xxx.x.xx
REMOTE_HOST=
REMOTE_IDENT=
REMOTE_IDENT REMOTE_USER=
REQUEST_METHOD=GET SCRIPT_NAME=/cgi-bin/java-rmi.cgi.sh
SERVER_NAME=xx.xxx.xxx.xxx
SERVER_PORT=80 SERVER_PROTOCOL=HTTP/1.1
SERVER_SOFTWARE=Apache/2.2.22 (Ubuntu) Status: 400 Bad Request: invalid command. Content-type: text/html
As you can see my many strings are empty...
EDIT 2: Now my acess log brings me this:
"POST http://xx.xxx.xxx.xxx/cgi-bin/java-rmi.cgi?forward=1099 HTTP/1.1" 500 415 "-" "Java/1.7.0"
Still HTTP 500, my error log gives my the same as before..
EDIT 3:
I now tried to implement the servlet of java-rmi.cgi and it's giving me errors.
My http.conf lookes like this:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
<Location /cgi-bin/java-rmi.cgi>
ProxyPass ajp://localhost:8009/rmi/ServletHandler
</Location>
What should be the port and adress? In the guide it says localhost:8009(https://forums.oracle.com/message/4804030).
This is where i've placed ServletHandler.class:
/var/lib/tomcat7/webapps/rmi/WEB_INF/classes
My web.xml(inside WEB_INF) looks like this:
<servlet>
<servlet-name>ServletHandler</servlet-name>
<servlet-class>ServletHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletHandler</servlet-name>
<url-pattern>/ServletHandler</url-pattern>
</servlet-mapping>
I've installed tomcat 7 properly.
My access log gives me the same but my error log now gives me(with localhost:8009 set in httpd.conf):
[Fri Nov 15 08:16:26 2013] [error] [client 127.0.0.1] Invalid method in request \x124\x01\xb2\x02\x02
[Fri Nov 15 08:16:26 2013] [error] ajp_check_msg_header() got bad signature 3c21
[Fri Nov 15 08:16:26 2013] [error] ajp_ilink_receive() received bad header
[Fri Nov 15 08:16:26 2013] [error] ajp_read_header: ajp_ilink_receive failed
[Fri Nov 15 08:16:26 2013] [error] (120007)APR does not understand this error code: proxy: read response failed from (null) (localhost)
Error log when setting my global ip and port 80 in http.conf:
[Fri Nov 15 08:13:26 2013] [error] [client xx.xxx.xxx.xxx] Invalid method in request \x124\x01\xb2\x02\x02
[Fri Nov 15 08:13:26 2013] [error] ajp_check_msg_header() got bad signature 3c21
[Fri Nov 15 08:13:26 2013] [error] ajp_ilink_receive() received bad header
[Fri Nov 15 08:13:26 2013] [error] ajp_read_header: ajp_ilink_receive failed
[Fri Nov 15 08:13:26 2013] [error] (120007)APR does not understand this error code: proxy: read response failed from (null) (xx.xxx.xxx.xxx)
EDIT 4:
Now it lookes like this:
web.xml:
<servlet>
<servlet-name>ServletHandler</servlet-name>
<servlet-class>rmiservlethandler.ServletHandler</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletHandler</servlet-name>
<url-pattern>/ServletHandler</url-pattern>
</servlet-mapping>
httpd.conf:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
<Location /cgi-bin/java-rmi.cgi>
ProxyPass ajp://xx.xxx.xxx.xxx:8009/rmi/ServletHandler
</Location>
I tried localhost:8009 but that gives me error, entering my servers global adress makes my webserver to halt, HTTP 503. Stop responding.
My error log for localhost:
[Fri Nov 15 12:20:53 2013] [error] (111)Connection refused: proxy: AJP: attempt to connect to 127.0.0.1:8009 (localhost) failed
[Fri Nov 15 12:20:53 2013] [error] ap_proxy_connect_backend disabling worker for (localhost)
[Fri Nov 15 12:20:53 2013] [error] proxy: AJP: failed to make connection to backend: localhost
error log for global ip:
[Fri Nov 15 12:37:23 2013] [error] (110)Connection timed out: proxy: AJP: attempt to connect to xx.xxx.xxx.xxx:8009 (xx.xxx.xxx.xxx) failed
[Fri Nov 15 12:37:23 2013] [error] ap_proxy_connect_backend disabling worker for (xx.xxx.xxx.xxx)
[Fri Nov 15 12:37:23 2013] [error] proxy: AJP: failed to make connection to backend: xx.xxx.xxx.xxx
Tomcatlog gives me this:
My tomcatlog gives me this:
xx.xxx.x.xx - - [15/Nov/2013:13:32:14 +0000] "POST /rmi/ServletHandler?forward=1099 HTTP/1.1" 404 987
EDIT 5.
Didn't work, i get 404 for /rmi/ServletHandler.
Here is my httpd.conf(taking away .cgi):
<Location /cgi-bin/java-rmi> ProxyPass ajp://localhost:8009/rmi/ServletHandler </Location>
This is web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app> <servlet>
<servlet-name>ServletHandler</servlet-name>
<servlet-class>rmiservlethandler.ServletHandler</servlet-class>
<load-on-startup>1</load-on-startup> </servlet>
<servlet-mapping> <servlet-name>ServletHandler</servlet-name>
<url-pattern>/ServletHandler</url-pattern>
</servlet-mapping>
</web-app>
The folder setup is now:
/var/lib/tomcat7/webapps/rmi/WEB_INF.
WEB_INF contains web.xml and classes/rmiservlethandler/ where rmiservlethandler is where all my class files are(package structure).
Why isn't this working?
My /usr/lib/cgi-bin/ is empty that is should be right?
My servlet dosen't run...
Thanks!

Solved it!
My folder setup were correct(except WEB-INF instead of WEB_INF), the problem was that my localhost adress in ServletHandler wasn't resolved properly(my localhost name wasn't localhost..).
Other things like WEB_INF should be WEB-INF...
Following this gave my exceptions in tomcat catalina.out and local host log files.
So if you think your servlet is running properly, look there for exceptions. I modified my ServletHandler with logs so i could se everything that was going on.
This is what my POST from the client looks now inside tomcat logs:
xx.xxx.x.xx - - [18/Nov/2013:13:17:23 +0000] "POST /rmi/ServletHandler?forward=1099 HTTP/1.1" 200 1
My http.conf:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
<Location /cgi-bin/java-rmi.cgi>
ProxyPass ajp://localhost:8009/rmi/ServletHandler
</Location>
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>ServletHandler</servlet-name>
<servlet-class>com.foo.bl.server.ServletHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletHandler</servlet-name>
<url-pattern>/ServletHandler</url-pattern>
</servlet-mapping>
</web-app>
Folder structure:
/var/lib/tomcat7/webapps/rmi/WEB-INF/classes/
Inside classes you put the same folder structure you have in your java IDE.
Web.xml should be placed inside WEB-INF.
Any lib files needed should be placed in WEB-INF/lib.
Hope it helps someone out there!
Regards Gustav

Related

Error 503 in GWT with the servlet and paths (Java)

I work with IntelliJ and when I run it in a web browser, it returns 503 error :
Problem accessing / MySampleApplication.html. Reason:
Service Unavailable"*
The bug should be somewhere in the XML file and it seems to be something wrong with the servlet path.
XML:
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.0//EN"
"http://gwtproject.org/doctype/2.8.0/gwt-module.dtd">
<module rename-to="MySampleApplication">
<inherits name='com.google.gwt.user.User'/>
<entry-point class='com.mySampleApplication.client.MySampleApplication'/>
<servlet path='/MySampleApplicationService' class='com.mySampleApplication.server.ServiceImpl'/>>
/>
</module>
Console:
Code server started in 12.55 s ms
2019-03-06 13:09:20.410:INFO:oejs.Server:main: Started #13836ms
Loading modules
com.mySampleApplication.MySampleApplication
Validating <servlet> tags for module 'MySampleApplication'
For additional info see: file:/Users/simonemettesorensen/Downloads/gwt-2.8.2/doc/helpInfo/servletMappings.html
[WARN] Module declares a servlet class 'com.mySampleApplication.server.ServiceImpl' with a mapping to '/MySampleApplication/MySampleApplicationService', but the web.xml has no corresponding mapping; please add the following lines to your web.xml:
<servlet-mapping>
<servlet-name>com.mySampleApplication.MySampleApplication Service</servlet-name>
<url-pattern>/MySampleApplication/MySampleApplicationService</url-pattern>
</servlet-mapping>
2019-03-06 13:09:20.549:INFO:oejs.Server:main: jetty-9.2.z-SNAPSHOT
Starting Jetty on port 8888
[WARN] Failed startup of context c.g.g.d.s.j.WebAppContextWithReload#41aa7994{/,file:/Users/simonemettesorensen/Library/Caches/IntelliJIdea2018.2/gwt/%C3%B8velsemedrpc.9e5e27b2/oevelseMedRPC.6c3e6f2f/run/www/,STARTING}{/Users/simonemettesorensen/Library/Caches/IntelliJIdea2018.2/gwt/øvelsemedrpc.9e5e27b2/oevelseMedRPC.6c3e6f2f/run/www}
java.lang.NullPointerException
at java.lang.String.compareTo(String.java:1155)
at org.eclipse.jetty.servlet.ServletHolder.compareTo(ServletHolder.java:209)
at org.eclipse.jetty.servlet.ServletHolder.compareTo(ServletHolder.java:70)
at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:321)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:188)
at java.util.Arrays.sort(Arrays.java:1246)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:865)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:550)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:140)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:387)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:760)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:636)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:923)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:706)
at com.google.gwt.dev.DevMode.main(DevMode.java:432)
2019-03-06 13:09:22.470:INFO:oejs.ServerConnector:main: Started ServerConnector#1006dd06{HTTP/1.1}{127.0.0.1:8888}
2019-03-06 13:09:22.470:INFO:oejs.Server:main: Started #15896ms
Dev Mode initialized. Startup URL:
http://127.0.0.1:8888/MySampleApplication.html
[ERROR] 503 - GET /MySampleApplication.html (127.0.0.1) 312 bytes
Request Headers
Host: 127.0.0.1:8888
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: da-DK,da;q=0.9,en-US;q=0.8,en;q=0.7
Response headers
Date: Wed, 06 Mar 2019 12:09:22 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html; charset=ISO-8859-1
Content-Length: 312
And if I add this, it won't run because of an unexpected error: "servlet mapping :
<servlet-mapping>
<servlet-name>com.mySampleApplication.MySampleApplication Service</servlet-name>
<url-pattern>/MySampleApplication/MySampleApplicationService</url-pattern>
</servlet-mapping>
I would really appreciate any help.
Simone, welcome to the GWT world!
If that servlet uses GWT-RPC I would strongly suggest you to look into creating a JSON endpoint. Moving forward the RPC part will be dropped, JSON is standard and future-proof.
It's also waaaaaaay easier to debug and mock up, makes working with GWT significantly easier.
You need to replace the <servlet> from your *.gwt.xml file with a <servlet-mapping> (and <servlet>) in your WEB-INF/web.xml (a standard servlet mapping, not GWT-specific, like in any other, non-GWT, servlet development)

keycloak: "Failed to read artifact descriptor" error

I'm using the Java-based Keycloak server and attempting to run the demo examples. I'm a bit of a Java hack, so please pardon my naiveté.
I'm getting the error shown below -- any help debugging and solving would be appreciated.
ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-7) Uncaught server error: java.lang.RuntimeException: org.eclipse.aether.collection.DependencyCollectionException: Failed to read artifact descriptor for org.keycloak:photoz-authz-policy:jar:3.4.3.Final
I had some trouble getting M2_HOME set so that keycloak could locate artifacts. I seem to be past that problem and now, but I'm not sure where to go with the above error. I've included some system info below. And if someone's really eager, the dockerfile is available.
I'm running v3.5.3 of maven:
$ mvn --version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.60-linuxkit-aufs", arch: "amd64", family: "unix"
I ran mvn -U clean install in the project directory, and the artifacts appear to be built correctly:
[jboss#09fea4c663e0 ~]$ ll .m2/repository/org/keycloak/photoz-authz-policy/3.4.3.Final/
total 44
-rw-r--r-- 1 jboss jboss 5169 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.jar
-rw-r--r-- 1 jboss jboss 32 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.jar.md5
-rw-r--r-- 1 jboss jboss 40 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.jar.sha1
-rw-r--r-- 1 jboss jboss 773 Jan 4 09:24 photoz-authz-policy-3.4.3.Final.pom
-rw-r--r-- 1 jboss jboss 32 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.pom.md5
-rw-r--r-- 1 jboss jboss 40 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.pom.sha1
-rw-r--r-- 1 jboss jboss 3859 Mar 28 17:16 photoz-authz-policy-3.4.3.Final-sources.jar
-rw-r--r-- 1 jboss jboss 32 Mar 28 17:16 photoz-authz-policy-3.4.3.Final-sources.jar.md5
-rw-r--r-- 1 jboss jboss 40 Mar 28 17:16 photoz-authz-policy-3.4.3.Final-sources.jar.sha1
-rw-r--r-- 1 jboss jboss 262 Mar 28 17:16 _remote.repositories
And finally, here's the metadata associated with the artifact:
[jboss#09fea4c663e0 ~]$ cat .m2/repository/org/keycloak/photoz-authz-policy/maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.keycloak</groupId>
<artifactId>photoz-authz-policy</artifactId>
<versioning>
<release>3.4.3.Final</release>
<versions>
<version>3.4.3.Final</version>
</versions>
<lastUpdated>20180328171633</lastUpdated>
</versioning>
</metadata>
Any insight?
I was able to get the examples to run by copying the project files to the server and compiling on the server. That seems strange to me -- a fat WAR seems like it would make more sense. That is, I wouldn't expect to have to have supporting libraries compiled on a the server, but that strategy allowed me to move on. Here are the commands I ran on my wildfly server (Dockerfile commands):
# Build and install keycloak example libraries
WORKDIR /opt/jboss
USER jboss
COPY --chown=jboss:jboss _srv/keycloak-demo-3.4.3.Final ./_srv/keycloak-demo-3.4.3.Final
WORKDIR _srv/keycloak-demo-3.4.3.Final/examples
RUN mvn -U clean install
WORKDIR /opt/jboss

java.lang.NoClassDefFoundError: org/hibernate/boot/MetadataBuilder

I have this strange error when deploying my application , but the jar needed is in my POM file !!!
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.4.Final</version>
</dependency>
Here the error:
Error creating bean with name 'entityManagerFactory' defined in class path resource [fr/telecom/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/boot/MetadataBuilder
I even check the war and the jar is inside the war
Searching Ctrl + Shift + T I found:
org.hibernate.validator.internal.metadata.aggregated.MetaDataBuilder
and
org.hibernate.boot.MetadataBuilder
You are using the wrong version. org.hibernate.boot.MetadataBuilder is available in version 5:
$ jar tvf ~/.m2/repository/org/hibernate/hibernate-core/5.0.4.Final/hibernate-core-5.0.4.Final.jar | grep MetadataBuilder
3931 Wed Nov 18 12:22:14 CET 2015 org/hibernate/boot/MetadataBuilder.class
In version 4.3.6.Final, it's defined in another package:
$ jar tvf ~/.m2/repository/org/hibernate/hibernate-core/4.3.6.Final/hibernate-core-4.3.6.Final.jar | grep MetadataBuilder
672 Wed Jul 16 16:28:14 CEST 2014 org/hibernate/metamodel/MetadataBuilder.class
1) The head of you DTD in hibernate.config.xml must be the following:
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"classpath:/org/hibernate/hibernate-configuration-3.0.dtd">
`
2) if you have you hibernate.config.xml in /WEB-INF remove it and place in /src/main/resources;
3) Finally, you will have to ovewrite some lines in web.xml file where you invoke the hibernate to be as the following:
`<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:hibernate.cfg.xml
</param-value>
</context-param>`
I Hope it halps. Herman, Mozambique

Tomcat / Maven plugin - Unauthorized error

I have the following config in my /users//settings.xml.
Under PluginsGroup:
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
Under servers:
<server>
<id>localhost</id>
<username>tom</username>
<password>cat</password>
</server>
Under profiles:
<plugin>
<configuration>
<server>localhost</server>
<url>http://localhost:8080/manager/text</url>
<path>/</path>
</configuration>
</plugin>
I ran the maven command with -X options, and I see the following:
[DEBUG] Reading global settings from C:\Tools\apache-maven-3.1.1\bin\..\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\<user>\.m2\settings.xml
I have the manager-script role in tomcat users xml file.
When I manually verify the access through browser, it works fine. But when I run mvn tomcat7:deploy I get the following:
Receiving response: HTTP/1.1 401 Unauthorized
User name and password are correct. I verified it manually. What else could be wrong?
Googling did not help much.
Edit: More details from Log.
HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Wed, 31 Dec 1969 18:00:00 CST
WWW-Authenticate: Basic realm="Tomcat Manager Application"
Set-Cookie: JSESSIONID=7320C7326C51E8F7FF9F4D23A39E6971; Path=/manager/; HttpOnly
Content-Type: text/html;charset=ISO-8859-1
Transfer-Encoding: chunked
Date: Thu, 24 Apr 2014 02:56:27 GMT
Cookie accepted: "[version: 0][name: JSESSIONID][value: 7320C7326C51E8F7FF9F4D23A39E6971]
[domain: localhost][path: /manager/][expiry: null]".
Connection can be kept alive indefinitely
Authentication required
localhost:8080 requested authentication
Authorization challenge processed
Authentication failed
Clearing cached auth scheme for http://localhost:8080
Edit:
Well, this is what I found out. When I pass username and password from mvn command, its working fine. But its not picking up from settings.xml.
Does it ring any bell? I tried moving the config stuff to MAVEN_HOME/config/settings.xml as well. (Deleted the user settings.xml). But still the same.
Any settings cache?
Edit:
I turned on the debugger with -X. Even though I deleted /user/.m2/settings.xml, it says its reading that file.
[DEBUG] Reading global settings from C:\Tools\apache-maven-3.1.1\bin\..\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\<user>\.m2\settings.xml
How to flush?
The pluging configuration should be like that:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<server>text</server>
<url>http://localhost:8080/manager/text</url>
</configuration>
</plugin>
This should work
I am guessing that the application you want to deploy is named text. If it is not replace text with your web application name.
Also I would try removing the last <path>/</path> element to see if this helps or not...

How big a war file should be?

Tomcat 7 manager limit the war file size to 50 Mo.
Why this limitation of 50 Mo ?
What should be the maximum war file size ? (in practice)
I'm working with Grails 2.2 which generate a minimal WAR of 28 Mo.
So, the limit of 50 Min is very easy to reach.
This is only a limit set for you to upload and deploy via the Tomcat 7 manager. There really is not a limit on the size of the war file you can deploy to a tomcat server.
Here is a link that can help you increase this upload size.
Quoted from link --
Go to the web.xml of the manager application (for instance it could be
under /tomcat7/webapps/manager/WEB-INF/web.xml. Increase the
max-file-size and max-request-size:
<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
If you're using Tomcat 8, the max-file-size is not in web.xml anymore. Instead, open conf/server.xml and find the tag entry for the HTTP connector. Then add the
maxPostSize="0"
attribute and value to this tag. When you have completed editing the conf/server.xml file, save it and restart Apache Tomcat.
The 50 MB default file size limit is not hard-coded, you can change it in the web.xml file of the Manager application of your webapp folder. You'll have to increase the max-file-size and max-request-size:
<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
Replace the current values with the appropriate values for your needs.
Go to the web.xml of the manager application (for instance it could be under /tomcat7/webapps/manager/WEB-INF/web.xml.
Increase the max-file-size and max-request-size to for example 100Mb
In tomcat7, update the tomcat7/server.xml. I installed tomcat7 in ubuntu so the directory is like below
ll /etc/tomcat7/
total 220
drwxr-xr-x 4 root root 4096 Oct 6 18:14 ./
drwxr-xr-x 136 root root 12288 Oct 6 16:12 ../
drwxrwxr-x 3 root tomcat7 4096 Sep 23 15:44 Catalina/
-rw-r--r-- 1 root tomcat7 6506 Jun 27 12:48 catalina.properties
-rw-r--r-- 1 root tomcat7 1394 Jan 25 2014 context.xml
-rw-r--r-- 1 root tomcat7 2370 Feb 18 2016 logging.properties
drwxr-xr-x 2 root tomcat7 4096 Sep 23 16:06 policy.d/
-rw-r--r-- 1 root tomcat7 6716 Oct 6 18:14 server.xml
-rw-r----- 1 root tomcat7 1607 Sep 23 15:50 tomcat-users.xml
-rw-r--r-- 1 root tomcat7 168099 Nov 25 2015 web.xml
You would see the connector section in the conf file etc/tomcat7/server.xml,
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443"/>
Stop the tomcat and just add the maxPostSize at the end,
sudo service tomcat7 stop
Update the connector in the server.xml,
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443"
maxPostSize="57000000"/>
Then restart the tomcat.
sudo service tomcat7 start

Categories