PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label tomcat. Show all posts
Showing posts with label tomcat. Show all posts

Monday, October 31, 2022

[FIXED] How to increase header size limit Tomcat Java

 October 31, 2022     header, http, java, tomcat     No comments   

Issue

Looking at https://tomcat.apache.org/tomcat-9.0-doc/config/http.html I see that 8KB is the default limit of Header Size in Tomcat Apache.

The log shows the following when I make a request with headers more than the default 8KB: Dec 30, 2019 1:59:26 PM org.apache.coyote.http11.Http11Processor service INFO: Error parsing HTTP request header Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Request header is too large at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:720) at org.apache.coyote.http11.Http11InputBuffer.parseHeader(Http11InputBuffer.java:867) at org.apache.coyote.http11.Http11InputBuffer.parseHeaders(Http11InputBuffer.java:563) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:311) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839) 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)

My Java Project does not have a server.xml inside /webapp/WEB-INF, just the web.xml. I tried to create a server.xml and add the following like said in this thread: <?xml version='1.0' encoding='utf-8'?> <Connector port="8080" protocol="HTTP/1.1" maxHttpHeaderSize="65536" maxPostSize="4194304" URIEncoding="UTF-8"/>//webapp/WEB-INF

How Can I increase the default size limit? I'd like to set 16KB.

Thanks in advance =)

PS: I am new in Tomcat/Java World, so sorry if I made a horrible mistake =p


Solution

Looking at API doc seems that this one

Tomcat t = new Tomcat();
t.getConnector().setAttribute("maxHttpHeaderSize",65536);

could be a valid solution.



Answered By - Renato
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, October 19, 2022

[FIXED] How to rotate the tomcat localhost log?

 October 19, 2022     admin, logging, tomcat     No comments   

Issue

I am using tomcat 6x in a Linux system. It prints a localhost log file like localhost.2011-06-07, localhost.2011-06-08 on a daily basis. I want to rotate the localhost when it reaches 1MB.

I can rotate log files in log4j for my web apps. But this localhost log file of tomcat, I couldn't get it to rotate. Has any got a solution other than using logrotate?


Solution

Do you not want to use logrotate, or does your sys admin not allow you to?

Given that restriction, I'm afraid (from what I have been able to learn from the documentation) that there is no automatic way to do what you want (rotate log files based on the size alone).

If you merely want to stop Tomcat's default behavior of creating a new log every day (which I find extremely annoying for a development environment or low-traffic site), you can certainly do this by changing the fileDateFormat property of the Access Log "Valve", which on Ubuntu Server is defined in /etc/tomcat7/server.xml. It's probably in a similar location for Tomcat 6.

Since you mention a restrictive sys admin, I gather that this server is not under your control, so that path is irrelevant. If you do have the ability to modify Tomcat's log configuration, hopefully you know where to find the appropriate file.

In that .xml file, look for the Valve entity with className set to "org.apache.catalina.valves.AccessLogValve" in the section which configures the "Catalina" Engine for the appropriate host for your site (localhost in my case). Although the Tomcat 6 documentation doesn't mention it, one can deduce that the default fileDateFormat is "yyyy-MM-dd". Including the day in the log filename tells Tomcat (by implication) that you also want the log rotated every day. If you wanted it to be rotated, say, only once a month, just change the fileDateFormat to "yyyy-MM".

On my server, the default Logging Valve definition was this:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

To change this to monthly log rotation, I would just add the appropriate fileDateFormat attribute:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           fileDateFormat="yyyy-MM" prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

Since I am able (and willing) to use logrotate, I have turned off Tomcat's built-in log rotation and date-based file naming completely, and simply use logrotate to rotate the logs whenever the log reaches 1MB.

Edit To answer dgrant's question, the changes were to /etc/tomcat7/server.xml, and the actual valve configuration I'm using is this:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       pattern="combined" rotatable="false"
       prefix="access_log" />

Note that the 'combined' pattern is equivalent (at least for Tomcat 7) to the explicit pattern definition in the original configuration. All this is well-covered in my original documentation link if you want to read more. Just look for the section on the rotatable attribute.



Answered By - Lambart
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, October 18, 2022

[FIXED] What is the difference between Tomcat containers and Docker containers?

 October 18, 2022     apache, containers, docker, tomcat     No comments   

Issue

Tomcat is a servlet container. Docker is also related to containers. Why are they both called "containers"?

What is the difference between Tomcat containers and Docker containers?


Solution

The term "container" here is only similar in the basic english definition of a "construct" that contains "something".

Apache Tomcat is a Java process that contains J2EE servlets and JavaServer Pages.

A Docker container is an operating system (OS) construct that contains a usable OS (as close as it can get) seperate from the host OS (as seperate as it can). Docker itself isn't really the container either, Docker manages the underlying OS to make it easier to run an image as a container.

So both the "construct" and the "something" are vastly different between Tomcat and Docker which makes the technical definitions vastly different too.



Answered By - Matt
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, September 30, 2022

[FIXED] Why should Tomcat's PersistentValve not be used where there may be concurrent requests per session?

 September 30, 2022     concurrency, java, session, tomcat     No comments   

Issue

In the class comments at the top of PersistentValve there is a usage constraint:

/**
...
 * <b>USAGE CONSTRAINT</b>: To work correctly it assumes only one request exists
 *                              per session at any one time.
...
 */

Why is this constraint here? Perusing the code I see three reasons:

  1. Concurrent requests for the same session on different Tomcat instances may be subject to "last write wins" and thus potential loss of session data.
  2. Concurrent requests for the same session on the same Tomcat instance may result in NPE due to session.recycle() setting the manager to null in the shared session object and another request dereferencing manager when attempting to save the session to the store.
  3. Performance inefficiencies (e.g., redundant persistence store access, etc.).

Are there other reasons?


Solution

Doing an SVN-Blame I found this comment was added in svn revision 652662 on May 1st 2008 while fixing bug 43343 using the commit comment: Fix bug 43343. Correctly handle the case where a request arrives for a session we are in the middle of persisting..

The context of the bug strongly points at your suggested reason (1) that it is about data loss. In the initial bug description the OP says:

... The only place I saw other issues was inside of: java/org/apache/catalina/valves/PersistentValve.java

where it incorrectly grabs the store from the PersistentManager and uses it directly instead of using the manager API. To me this is bad in that the manager is not able to be the manager and this other logic is accessing the store directly and should never happen...unless it is used only in test cases etc.

So here it is considered the Managers' sole task to use the session Store for storing, loading and deleting sessions. But the PersistentValve does the same too and might easily interfer with what the manager does.

During the bug fix commit beside modifying the PersistentManager, only the comment in question was added to PersistentValve.java plus an unused variable was removed:

- StandardHost host = (StandardHost) getContainer();

While I don't know the purpose of this line removal or past presence, I consider the committer Mark Thomas recognized during code review and patch that PersistentValve can only guarantee constistent session writes when there's only a maximum of one request active per session at any point in time. Else lost writes may occurre.

I won't judge how practical this is, but just thinking about plenty of ressources loaded in parallel per web page impression (main HTML, CSS, JS, Images).

I'm still unsure if this can even be a problem using a single Tomcat instance.



Answered By - Selaron
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, September 21, 2022

[FIXED] How to configure apache-vhost.conf file for getting Session value from Java

 September 21, 2022     java, mod-proxy, session, tomcat, virtualhost     No comments   

Issue

Existing Config File setting for VirtualHost in Tomcat Server:

`<VirtualHost *:96>
  ServerName example.in
  ServerAlias www.example.in
  ProxyPass / http://127.0.0.1:8080/example/
  ProxyPassReverse / http://127.0.0.1:8080/example/

  <IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JkMount /*.do ajp13
  JkMount /*.* ajp13
  JkMount /servlet/* ajp13
  JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>`

By using this configuration I am not able to get the Session Value, which is being set in Java file request.getSession().setAttribute("ActiveSession", output.getParameters().get("userDetailsList"));

I am trying to retrieve the value in jsp by standard jsp code as <%session.getAttribute("ActiveSession")%>

Problem: when I am using website link 'example.in' I'm not getting the session value in JSP.

But using http://127.0.0.1:8080/example/ I am getting the value.

Already Tried :

`<VirtualHost *:96>
  ServerName example.in
  ServerAlias www.example.in
  ProxyPass / http://127.0.0.1:8080/example/
  ProxyPassReverse / http://127.0.0.1:8080/example/
  Session On
  SessionEnv On
  SessionCookieName session path=/
  SessionHeader X-Replace-Session
  <IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JkMount /*.do ajp13
  JkMount /*.* ajp13
  JkMount /servlet/* ajp13
  JkMount /servlets/* ajp13
</IfModule>

`

Help will be appreciated as I have already wasted 5 good hrs on this.


Solution

If someone is still struggling to get this, here is the working configuration:

<VirtualHost *:96>
 ServerName example.in
 ServerAlias www.example.in
 ProxyPass / http://127.0.0.1:8080/example/
 ProxyPassReverse / http://127.0.0.1:8080/example/
 ProxyPassReverseCookiePath / http://127.0.0.1:8080/example/
 <IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JkMount /*.do ajp13
  JkMount /*.* ajp13
  JkMount /servlet/* ajp13
  JkMount /servlets/* ajp13
 </IfModule>
</VirtualHost>


Answered By - amarmishra
Answer Checked By - Marie Seifert (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] What is the best way to install Mod_jk on linux to run apache in front of tomcat

 September 21, 2022     apache, mod-jk, tomcat, virtual-hosts     No comments   

Issue

I am using Wordpress for my blog and my main project is in java using tomcat server so I want each request coming to my server to go through apache.

For exemple if my site uses www.sample.com I would like to send the request to tomcat and if it is www.sample.com/wordpress send it to apache

Thanks


Solution

Install modjk:

sudo apt-get install libapache2-mod-jk
sudo a2enmod jk

Create workers.properties file:

worker.list=tomcat,tstatus
worker.tomcat.type=ajp13
worker.tomcat.host=[TOMCAT-IP HERE]
worker.tomcat.port=[TOMCAT-AJP-PORT HERE]
#status information (optional)
worker.tstatus.type=status

Add this to httpd.conf:

JkWorkersFile   /PATH-TO-YOUR-FILE/workers.properties
JkLogFile       /var/log/apache2/mod_jk.log  
JkShmFile       /tmp/jk-runtime-status
JkLogLevel      info

JkMount /YourJavaAppName       tomcat
JkMount /YourJavaAppName/*     tomcat

JkMount /modjkstatus tstatus

Now you should be able to access:

http://YOUR-IP/wordpress
http://YOUR-IP/YourJavaAppName (redirected)
http://YOUR-IP/modjkstatus (redirected)


Answered By - Stefan
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, September 4, 2022

[FIXED] How the request.getRemoteUser() works and the remote username value is stored?

 September 04, 2022     authentication, httprequest, java, servlets, tomcat     No comments   

Issue

I have Tomcat authentication (form authentication) in my application. After successful authentication, I am able to get the username from the request.getRemoteUser() method in my servlet.

Where I can find request.getRemoteUser() code? How does this work? Where has the RemoteUser has been set and stored? Since HTTP requests are stateless and execute independently, how this giving the username in all subsequent requests?


Solution

In order to deal with authentication, every context in Tomcat has a Valve that extends AuthenticatorBase, that:

  1. tries to authenticate the user using the data in the HttpServletRequest,
  2. checks the authorization requirements for the URL,
  3. if authentication is required, but absent, sends an appropriate response to the browser, asking for authentication. This usually means a 401 response with a WWW-Authenticate header for most authentication methods or a 302 redirect to the login page for form authentication.
  4. if authentication is present, but the access is not authorized, it sends a 403 response.
  5. otherwise calls Request#setUserPrincipal and proceeds with the next valve.

For the details check the AuthenticatorBase#invoke method.

Most authentication methods are based on the Authorization header sent by the browser (the form authenticator uses request parameters).

If a session is present (e.g. you called HttpServletRequest#getSession), the authenticated user will be cached in the session and subsequent requests will not need to authenticate any more. You can force session creation using the alwaysUseSession attribute on the authenticator valves (cf. documentation). The server can recognize the presence of a previously established session through many methods:

  1. A JSESSIONID Cookie header in the request,
  2. A jsessionid path parameter in the URL,
  3. If you use TLS, the TLS session can be also be used to detect the appropriate HTTP session.


Answered By - Piotr P. Karwasz
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How the request.getRemoteUser() works and the remote username value is stored?

 September 04, 2022     authentication, httprequest, java, servlets, tomcat     No comments   

Issue

I have Tomcat authentication (form authentication) in my application. After successful authentication, I am able to get the username from the request.getRemoteUser() method in my servlet.

Where I can find request.getRemoteUser() code? How does this work? Where has the RemoteUser has been set and stored? Since HTTP requests are stateless and execute independently, how this giving the username in all subsequent requests?


Solution

In order to deal with authentication, every context in Tomcat has a Valve that extends AuthenticatorBase, that:

  1. tries to authenticate the user using the data in the HttpServletRequest,
  2. checks the authorization requirements for the URL,
  3. if authentication is required, but absent, sends an appropriate response to the browser, asking for authentication. This usually means a 401 response with a WWW-Authenticate header for most authentication methods or a 302 redirect to the login page for form authentication.
  4. if authentication is present, but the access is not authorized, it sends a 403 response.
  5. otherwise calls Request#setUserPrincipal and proceeds with the next valve.

For the details check the AuthenticatorBase#invoke method.

Most authentication methods are based on the Authorization header sent by the browser (the form authenticator uses request parameters).

If a session is present (e.g. you called HttpServletRequest#getSession), the authenticated user will be cached in the session and subsequent requests will not need to authenticate any more. You can force session creation using the alwaysUseSession attribute on the authenticator valves (cf. documentation). The server can recognize the presence of a previously established session through many methods:

  1. A JSESSIONID Cookie header in the request,
  2. A jsessionid path parameter in the URL,
  3. If you use TLS, the TLS session can be also be used to detect the appropriate HTTP session.


Answered By - Piotr P. Karwasz
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, September 2, 2022

[FIXED] How can I remove the need for two docker containers which work together to use bridged networking?

 September 02, 2022     docker, nginx, nginx-reverse-proxy, postgresql, tomcat     No comments   

Issue

I have three docker containers:

1: nginx container accessible on port 8080 and not using bridged networking

2: xwiki container running tomcat accessible on port 8080 using bridged networking

3: Postgres container hosting the xwiki database and accessible on port 5432 using same bridged network as the xwiki container

I want to be able to set nginx to reverse proxy and load the xwiki site on a url such as http://site-root/xwiki but its not able to do this as its not on the same bridged network and I get a no route to host error...

All the hosts are accessible from a remote host using the docker hosts ip and the respective container port...

I have created xwiki and postgres containers that dont use bridged networking to test this but the xwiki tomcat server fails as xwiki cant find the postgres server and I get the below error as a tomcat exception:

java.net.UnknownHostException: postgres-db-server

Is there away to remove the need for using bridged networking for the xwiki and postgres containers and have them communicate using the docker hosts IP and their respective port numbers?

I'm thinking that I may need to edit the tomcat config in the xwiki container so that it points to the postgres server using the docker hosts IP and the postgres default port...

Can any one give me an idea of if this sounds like to right solution or if I am missing something with regard to the need for bridged networking?

I realise that a possible solution is to set the nginx container to use the same bridged networking but i also want the nginx service to be able to reverse proxy a node.js server running on the docker host... (not via docker)

Should I just containerise node and run all the containers using the same bridged network as this, logically should remove the problem, but I am concerned that it may cause other problems down the line...

The docker host is running on Centos 7

The commands used to manually run the containers as shown below:

Nginx

docker run -dti --name nginx-dev --hostname nginx-dev -p 80:80 -v /nginx/www:/usr/share/nginx/html:ro -v /nginx/conf:/etc/nginx -P -d nginx

Postgres

docker run --net=xwiki-nw --name postgres-db-server -p 5432:5432 -v /postgres/data:/var/lib/postgresql/data -e POSTGRES_ROOT_PASSWORD=xwiki -e POSTGRES_USER=xwiki -e POSTGRES_PASSWORD=xwiki -e POSTGRES_DB=xwiki -e POSTGRES_INITDB_ARGS="--encoding=UTF8" -d postgres:9.5

Xwiki

docker run --net=xwiki-nw --name xwiki -p 8080:8080 -v /xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=postgres-db-server xwiki:postgres-tomcat

Solution

Run

docker network connect xwiki nginx-dev 

And then you nginx container will be able to find the route to other two containers.



Answered By - Tarun Lalwani
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, August 22, 2022

[FIXED] How to use environment variables in a .properties or a xml file?

 August 22, 2022     environment-variables, properties, tomcat, unix, xml     No comments   

Issue

I am trying to configure my tomcat server.xml and I need to set value to something from an environment variable. I can't seem to find a way around from that.

I know how to use values stored in a properties file but I can't set a variable to use my environment variable in a property file as well. is there a work around? I tried the following:

1 - 
.xml file
<Resource
user="${VAR}"
.../> 
2 - 
<Resource
user="${env.VAR}"
.../> 
3 -
.properties file
myVar=${VAR} and then 
<Resource
user="${myVar}"
.../> 

Solution

in my setenv.sh file

export JAVA_OPTS="$JAVA_OPTS -Dmyvar=${VAR}"

now I can use myvar inside a properties file or better, directly within a xml file since the variable is now available with tomcat context

<Resource
user="${myvar}"
.../>


Answered By - Peyush Goel
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, August 19, 2022

[FIXED] how to start stop tomcat server using CMD?

 August 19, 2022     apache, batch-file, environment-variables, java, tomcat     No comments   

Issue

I set the path for the tomcat and set all variables like

  1. JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_22
  2. CATALINA_HOME=G:\springwork\server\apache-tomcat-6.0.29
  3. CLASSPATH=G:\springwork\server\apache-tomcat-6.0.29\lib\servlet-api.jar;G:\springwork\server\apache-tomcat-6.0.29\lib\jsp-api.jar;.;

When I go to bin folder and double click on startup.bat then my tomcat starts and when I double click on shutdown.bat tomcat stops.

But I want using CMD start and stop the tomcat. And in any folder I write command startup.bat the server will start and when I write shutdown.bat the server will stop.


Solution

Add %CATALINA_HOME%/bin to path system variable.

Go to Environment Variables screen under System Variables there will be a Path variable edit the variable and add ;%CATALINA_HOME%\bin to the variable then click OK to save the changes. Close all opened command prompts then open a new command prompt and try to use the command startup.bat.



Answered By - Arun P Johny
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, August 1, 2022

[FIXED] How uninstall apache server from cpanel?

 August 01, 2022     apache, cpanel, tomcat, uninstallation, vps     No comments   

Issue

I would like to know how can I completely uninstall the apache server from my vps which is configured with cpanel. Are there there any other dependencies to apache server on a regular cpanel installation?

PS. I am using on my vps server this particular services: tomcat, bind and courier mail server


Solution

You can do it from whm. Login to http://yoururl/whm, there you will have options for each package(control panel).



Answered By - shikhar
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, July 16, 2022

[FIXED] How to deploy IntelliJ IDEA project in Apache Tomcat server?

 July 16, 2022     apache, grails, intellij-idea, tomcat, web-deployment     No comments   

Issue

I am new to IntelliJ IDEA Ultimate edition . I have developed a Grails project in it . Can anyone tell me the steps to deploy this project in a remote Apache Tomcat server ?


Solution

you have to build a .war file of your project. grails war

(The .war file is in your Project path.)

Now you can deploy the .war file on your remote tomcat server. You copy the File in the webapps folder, then you can access on it: http://localhost:8080/nameofyourwarfile

If you have a problem you can check the log file: logs/catalina.out

http://docs.grails.org/3.0.17/guide/deployment.html



Answered By - Stefan Greil
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] What I'm doing wrong while generating and deploying WAR to tomcat from terminal?

 July 16, 2022     java, tomcat, war, web-content, web-deployment     No comments   

Issue

When I deploy and run the application from eclipse everything works fine, but when I try to generate manually WAR file I have problems.

I entered application root folder. Open terminal and wrote:

jar -cvf forum.war *

It generates war file with this log:

added manifest
adding: build/(in = 0) (out= 0)(stored 0%)
adding: build/classes/(in = 0) (out= 0)(stored 0%)
adding: build/classes/controller/(in = 0) (out= 0)(stored 0%)
adding: build/classes/controller/SInitialize.class(in = 1382) (out= 686)(deflated 50%)
adding: build/classes/controller/Utils.class(in = 2638) (out= 1274)(deflated 51%)
adding: build/classes/controller/DataManager.class(in = 25910) (out= 8912)(deflated 65%)
adding: build/classes/model/(in = 0) (out= 0)(stored 0%)
adding: build/classes/model/enums/(in = 0) (out= 0)(stored 0%)
adding: build/classes/model/enums/Role.class(in = 979) (out= 547)(deflated 44%)
adding: build/classes/model/enums/TopicType.class(in = 1009) (out= 551)(deflated 45%)
adding: build/classes/model/enums/MessageType.class(in = 979) (out= 530)(deflated 45%)
adding: build/classes/beans/(in = 0) (out= 0)(stored 0%)
adding: build/classes/beans/Comments.class(in = 4523) (out= 2126)(deflated 52%)
adding: build/classes/beans/TopicRatings$Key.class(in = 1525) (out= 767)(deflated 49%)
adding: build/classes/beans/Content.class(in = 258) (out= 192)(deflated 25%)
adding: build/classes/beans/TopicRatings.class(in = 2853) (out= 1250)(deflated 56%)
adding: build/classes/beans/Comment.class(in = 4993) (out= 1941)(deflated 61%)
adding: build/classes/beans/UserChangeRoleBean.class(in = 786) (out= 431)(deflated 45%)
adding: build/classes/beans/SignUpBean.class(in = 1611) (out= 614)(deflated 61%)
adding: build/classes/beans/CommentRatings.class(in = 2897) (out= 1255)(deflated 56%)
adding: build/classes/beans/Messages.class(in = 2589) (out= 1139)(deflated 56%)
adding: build/classes/beans/TopicBean.class(in = 3877) (out= 1482)(deflated 61%)
adding: build/classes/beans/Users.class(in = 2689) (out= 1076)(deflated 59%)
adding: build/classes/beans/CommentRatings$Key.class(in = 1543) (out= 770)(deflated 50%)
adding: build/classes/beans/UserPublicBean.class(in = 2200) (out= 902)(deflated 59%)
adding: build/classes/beans/AvatarBean.class(in = 548) (out= 315)(deflated 42%)
adding: build/classes/beans/TopicRating.class(in = 1027) (out= 529)(deflated 48%)
adding: build/classes/beans/CommentDeleteBean.class(in = 530) (out= 317)(deflated 40%)
adding: build/classes/beans/Subforum.class(in = 3261) (out= 1241)(deflated 61%)
adding: build/classes/beans/EditProfileBean.class(in = 1148) (out= 477)(deflated 58%)
adding: build/classes/beans/User.class(in = 5952) (out= 2255)(deflated 62%)
adding: build/classes/beans/TopicNewBean.class(in = 1461) (out= 621)(deflated 57%)
adding: build/classes/beans/CommentSubmitBean.class(in = 1028) (out= 499)(deflated 51%)
adding: build/classes/beans/Message.class(in = 2345) (out= 995)(deflated 57%)
adding: build/classes/beans/LoginBean.class(in = 870) (out= 409)(deflated 52%)
adding: build/classes/beans/Topics.class(in = 2150) (out= 920)(deflated 57%)
adding: build/classes/beans/SearchBean.class(in = 1338) (out= 616)(deflated 53%)
adding: build/classes/beans/SubforumNewBean.class(in = 1282) (out= 569)(deflated 55%)
adding: build/classes/beans/CommentRating.class(in = 1180) (out= 595)(deflated 49%)
adding: build/classes/beans/Subforums.class(in = 4741) (out= 2333)(deflated 50%)
adding: build/classes/beans/services/(in = 0) (out= 0)(stored 0%)
adding: build/classes/beans/Topic.class(in = 4183) (out= 1595)(deflated 61%)
adding: build/classes/beans/MessageBean.class(in = 845) (out= 427)(deflated 49%)
adding: build/classes/beans/CommentLikeBean.class(in = 716) (out= 379)(deflated 47%)
adding: build/classes/beans/TopicRatingBean.class(in = 710) (out= 376)(deflated 47%)
adding: build/classes/beans/CommentEditBean.class(in = 1025) (out= 497)(deflated 51%)
adding: build/classes/services/(in = 0) (out= 0)(stored 0%)
adding: build/classes/services/HomePageService.class(in = 29395) (out= 12215)(deflated 58%)
adding: build/classes/services/LoginService.class(in = 6099) (out= 2895)(deflated 52%)
adding: Projektni Zadatak WEB.pdf(in = 534171) (out= 515168)(deflated 3%)
adding: src/(in = 0) (out= 0)(stored 0%)
adding: src/controller/(in = 0) (out= 0)(stored 0%)
adding: src/controller/SInitialize.java(in = 2274) (out= 699)(deflated 69%)
adding: src/controller/Utils.java(in = 1238) (out= 412)(deflated 66%)
adding: src/controller/DataManager.java(in = 23435) (out= 2352)(deflated 89%)
adding: src/model/(in = 0) (out= 0)(stored 0%)
adding: src/model/enums/(in = 0) (out= 0)(stored 0%)
adding: src/model/enums/TopicType.java(in = 67) (out= 66)(deflated 1%)
adding: src/model/enums/MessageType.java(in = 66) (out= 64)(deflated 3%)
adding: src/model/enums/Role.java(in = 67) (out= 66)(deflated 1%)
adding: src/beans/(in = 0) (out= 0)(stored 0%)
adding: src/beans/SubforumNewBean.java(in = 841) (out= 284)(deflated 66%)
adding: src/beans/UserPublicBean.java(in = 1623) (out= 450)(deflated 72%)
adding: src/beans/Messages.java(in = 1484) (out= 452)(deflated 69%)
adding: src/beans/UserChangeRoleBean.java(in = 420) (out= 214)(deflated 49%)
adding: src/beans/Subforum.java(in = 2515) (out= 571)(deflated 77%)
adding: src/beans/Users.java(in = 1706) (out= 525)(deflated 69%)
adding: src/beans/TopicNewBean.java(in = 974) (out= 306)(deflated 68%)
adding: src/beans/SignUpBean.java(in = 1090) (out= 341)(deflated 68%)
adding: src/beans/SearchBean.java(in = 674) (out= 270)(deflated 59%)
adding: src/beans/CommentDeleteBean.java(in = 269) (out= 154)(deflated 42%)
adding: src/beans/Message.java(in = 1623) (out= 476)(deflated 70%)
adding: src/beans/EditProfileBean.java(in = 712) (out= 246)(deflated 65%)
adding: src/beans/TopicRatings.java(in = 2193) (out= 651)(deflated 70%)
adding: src/beans/User.java(in = 4974) (out= 1104)(deflated 77%)
adding: src/beans/LoginBean.java(in = 505) (out= 180)(deflated 64%)
adding: src/beans/Content.java(in = 42) (out= 44)(deflated -4%)
adding: src/beans/TopicRating.java(in = 711) (out= 275)(deflated 61%)
adding: src/beans/CommentEditBean.java(in = 582) (out= 242)(deflated 58%)
adding: src/beans/AvatarBean.java(in = 240) (out= 147)(deflated 38%)
adding: src/beans/CommentLikeBean.java(in = 378) (out= 162)(deflated 57%)
adding: src/beans/Topics.java(in = 1244) (out= 432)(deflated 65%)
adding: src/beans/MessageBean.java(in = 531) (out= 225)(deflated 57%)
adding: src/beans/CommentRatings.java(in = 2421) (out= 694)(deflated 71%)
adding: src/beans/Topic.java(in = 3199) (out= 858)(deflated 73%)
adding: src/beans/CommentRating.java(in = 735) (out= 272)(deflated 62%)
adding: src/beans/Subforums.java(in = 2796) (out= 969)(deflated 65%)
adding: src/beans/services/(in = 0) (out= 0)(stored 0%)
adding: src/beans/Comments.java(in = 3507) (out= 1004)(deflated 71%)
adding: src/beans/TopicRatingBean.java(in = 366) (out= 161)(deflated 56%)
adding: src/beans/TopicBean.java(in = 2920) (out= 769)(deflated 73%)
adding: src/beans/CommentSubmitBean.java(in = 589) (out= 256)(deflated 56%)
adding: src/beans/Comment.java(in = 3914) (out= 901)(deflated 76%)
adding: src/services/(in = 0) (out= 0)(stored 0%)
adding: src/services/HomePageService.java(in = 34676) (out= 5734)(deflated 83%)
adding: src/services/LoginService.java(in = 6275) (out= 1668)(deflated 73%)
adding: WebContent/(in = 0) (out= 0)(stored 0%)
adding: WebContent/profile_messages.html(in = 915) (out= 368)(deflated 59%)
adding: WebContent/WEB-INF/(in = 0) (out= 0)(stored 0%)
adding: WebContent/WEB-INF/lib/(in = 0) (out= 0)(stored 0%)
adding: WebContent/WEB-INF/lib/osgi-resource-locator-1.0.1.jar(in = 20235) (out= 17146)(deflated 15%)
adding: WebContent/WEB-INF/lib/jersey-server-2.25.jar(in = 940762) (out= 812861)(deflated 13%)
adding: WebContent/WEB-INF/lib/validation-api-1.1.0.Final.jar(in = 63777) (out= 47579)(deflated 25%)
adding: WebContent/WEB-INF/lib/persistence-api-1.0.jar(in = 52150) (out= 40983)(deflated 21%)
adding: WebContent/WEB-INF/lib/jstl.jar(in = 20682) (out= 17453)(deflated 15%)
adding: WebContent/WEB-INF/lib/asm-all-repackaged-2.2.0.jar(in = 401855) (out= 379036)(deflated 5%)
adding: WebContent/WEB-INF/lib/el-api.jar(in = 46158) (out= 42497)(deflated 7%)
adding: WebContent/WEB-INF/lib/mimepull-1.9.3.jar(in = 62135) (out= 56687)(deflated 8%)
adding: WebContent/WEB-INF/lib/jersey-container-servlet-core-2.25.jar(in = 66121) (out= 55570)(deflated 15%)
adding: WebContent/WEB-INF/lib/jackson-xc-1.9.13.jar(in = 27084) (out= 24875)(deflated 8%)
adding: WebContent/WEB-INF/lib/jersey-container-servlet-2.25.jar(in = 18101) (out= 14346)(deflated 20%)
adding: WebContent/WEB-INF/lib/standard.jar(in = 393259) (out= 351113)(deflated 10%)
adding: WebContent/WEB-INF/lib/javax.inject-2.2.0.jar(in = 5968) (out= 4533)(deflated 24%)
adding: WebContent/WEB-INF/lib/jersey-guava-2.8.jar(in = 962807) (out= 817752)(deflated 15%)
adding: WebContent/WEB-INF/lib/jersey-media-json-jackson-2.0-m07.jar(in = 5808) (out= 4190)(deflated 27%)
adding: WebContent/WEB-INF/lib/javax.servlet-api-3.0.1.jar(in = 85353) (out= 75030)(deflated 12%)
adding: WebContent/WEB-INF/lib/javassist-3.18.1-GA.jar(in = 714194) (out= 664822)(deflated 6%)
adding: WebContent/WEB-INF/lib/jaxb-api-2.2.7.jar(in = 100146) (out= 85972)(deflated 14%)
adding: WebContent/WEB-INF/lib/aopalliance-repackaged-2.2.0.jar(in = 14867) (out= 9865)(deflated 33%)
adding: WebContent/WEB-INF/lib/org.osgi.core-4.2.0.jar(in = 246924) (out= 222018)(deflated 10%)
adding: WebContent/WEB-INF/lib/jersey-client-2.25.jar(in = 168990) (out= 149270)(deflated 11%)
adding: WebContent/WEB-INF/lib/hk2-locator-2.5.0-b42.jar(in = 189454) (out= 176297)(deflated 6%)
adding: WebContent/WEB-INF/lib/jsp-api.jar(in = 88689) (out= 79782)(deflated 10%)
adding: WebContent/WEB-INF/lib/jackson-core-asl-1.9.13.jar(in = 232248) (out= 215037)(deflated 7%)
adding: WebContent/WEB-INF/lib/jackson-mapper-asl-1.9.13.jar(in = 780664) (out= 697674)(deflated 10%)
adding: WebContent/WEB-INF/lib/jersey-common-2.25.jar(in = 715934) (out= 631918)(deflated 11%)
adding: WebContent/WEB-INF/lib/jackson-jaxrs-1.9.13.jar(in = 18336) (out= 16451)(deflated 10%)
adding: WebContent/WEB-INF/lib/javax.ws.rs-api-2.0.jar(in = 112758) (out= 96456)(deflated 14%)
adding: WebContent/WEB-INF/lib/javax.annotation-api-1.2.jar(in = 26366) (out= 23303)(deflated 11%)
adding: WebContent/WEB-INF/lib/hk2-utils-2.5.0-b42.jar(in = 135317) (out= 119260)(deflated 11%)
adding: WebContent/WEB-INF/lib/hk2-api-2.5.0-b42.jar(in = 186763) (out= 162978)(deflated 12%)
adding: WebContent/WEB-INF/lib/jersey-media-multipart-2.25.jar(in = 67855) (out= 57758)(deflated 14%)
adding: WebContent/WEB-INF/web.xml(in = 1350) (out= 494)(deflated 63%)
adding: WebContent/login_dialog.html(in = 4109) (out= 732)(deflated 82%)
adding: WebContent/profile_manage_users.html(in = 516) (out= 202)(deflated 60%)
adding: WebContent/subforum.html(in = 2233) (out= 906)(deflated 59%)
adding: WebContent/topic_new.html(in = 2712) (out= 743)(deflated 72%)
adding: WebContent/subforum_new.html(in = 1854) (out= 571)(deflated 69%)
adding: WebContent/profile_menu.html(in = 547) (out= 199)(deflated 63%)
adding: WebContent/js/(in = 0) (out= 0)(stored 0%)
adding: WebContent/js/jquery.js(in = 282765) (out= 84245)(deflated 70%)
adding: WebContent/js/controller.js(in = 29245) (out= 4858)(deflated 83%)
adding: WebContent/js/upload_file.js(in = 4782) (out= 1567)(deflated 67%)
adding: WebContent/js/jquery.min.js(in = 84345) (out= 29551)(deflated 64%)
adding: WebContent/js/homepage.js(in = 42324) (out= 7178)(deflated 83%)
adding: WebContent/js/bootstrap-select.js(in = 68137) (out= 15285)(deflated 77%)
adding: WebContent/js/authenticate.js(in = 3818) (out= 1080)(deflated 71%)
adding: WebContent/search.html(in = 2060) (out= 876)(deflated 57%)
adding: WebContent/homepage.html(in = 2114) (out= 888)(deflated 57%)
adding: WebContent/data/(in = 0) (out= 0)(stored 0%)
adding: WebContent/META-INF/(in = 0) (out= 0)(stored 0%)
adding: WebContent/META-INF/MANIFEST.MF(in = 39) (out= 41)(deflated -5%)
adding: WebContent/profile.html(in = 2299) (out= 899)(deflated 60%)
adding: WebContent/profile_logged_user.html(in = 2808) (out= 665)(deflated 76%)
adding: WebContent/topic.html(in = 2090) (out= 862)(deflated 58%)
adding: WebContent/profile_not_logged_user.html(in = 279) (out= 137)(deflated 50%)
adding: WebContent/css/(in = 0) (out= 0)(stored 0%)
adding: WebContent/css/bootstrap-select.css(in = 7768) (out= 1694)(deflated 78%)
adding: WebContent/css/homepage.css(in = 6084) (out= 1911)(deflated 68%)
adding: WebContent/menu.html(in = 3385) (out= 1216)(deflated 64%)
adding: WebContent/resources/(in = 0) (out= 0)(stored 0%)
adding: WebContent/resources/forum.png(in = 1103) (out= 1108)(deflated 0%)
adding: WebContent/resources/cars.jpg(in = 2944) (out= 2793)(deflated 5%)
adding: WebContent/resources/slon.jpg(in = 3501) (out= 3368)(deflated 3%)
adding: WebContent/resources/lav.jpg(in = 2321) (out= 2310)(deflated 0%)
adding: WebContent/resources/sport.png(in = 17511) (out= 17514)(deflated 0%)
adding: WebContent/resources/drvo.jpg(in = 2831) (out= 2693)(deflated 4%)
adding: WebContent/resources/cvet.jpg(in = 3697) (out= 3556)(deflated 3%)

I copied it to tomcat's webapps folder and started the server. I couldn't find the application on: localhost:8080/forum/homepage.html. Still I found it on: localhost:8080/forum/WebContent/homepage.html but I have problems with rest service since I target localhost:8080/forum/WebContent/rest/authenticate.

This is content of my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>RESTApp</display-name>
    <welcome-file-list>
        <welcome-file>homepage.html</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Jersey REST Service</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

        <init-param>
            <param-name>jersey.config.server.provider.classnames</param-name>
            <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
        </init-param>

        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>services,org.codehaus.jackson.jaxrs</param-value>
        </init-param>


        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>

How to generate WAR properly so I don't have WebContent in my url?

UPDATE:

Loggs from access.log:

0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:15 +0100] "GET /forum/ HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:15 +0100] "GET /forum/ HTTP/1.1" 404 963
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:22 +0100] "GET /forum/homepage.html HTTP/1.1" 404 989
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/homepage.html HTTP/1.1" 200 2114
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/css/bootstrap-select.css HTTP/1.1" 200 7768
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/js/bootstrap-select.js HTTP/1.1" 200 68137
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/js/jquery.js HTTP/1.1" 200 282765
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/css/homepage.css HTTP/1.1" 200 6084
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/js/authenticate.js HTTP/1.1" 200 3818
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/js/homepage.js HTTP/1.1" 200 42324
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/js/controller.js HTTP/1.1" 200 29245
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/rest/authenticate/get_logged_user HTTP/1.1" 404 1051
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:31 +0100] "GET /forum/WebContent/login_dialog.html HTTP/1.1" 200 4109
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:32 +0100] "GET /forum/WebContent/css/bootstrap-select.css.map HTTP/1.1" 404 1041
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:40 +0100] "GET /forum/WebContent/menu.html HTTP/1.1" 200 3385
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:40 +0100] "GET /forum/WebContent/rest/homepage/subforums HTTP/1.1" 404 1031
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:03:40 +0100] "GET /forum/WebContent/resources/forum.png HTTP/1.1" 200 1103
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:38 +0100] "GET /forum/homepage.html HTTP/1.1" 404 989
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/css/bootstrap-select.css HTTP/1.1" 200 7768
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/css/homepage.css HTTP/1.1" 200 6084
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/js/jquery.js HTTP/1.1" 200 282765
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/js/authenticate.js HTTP/1.1" 200 3818
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/js/homepage.js HTTP/1.1" 200 42324
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/js/controller.js HTTP/1.1" 200 29245
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:42 +0100] "GET /forum/WebContent/js/bootstrap-select.js HTTP/1.1" 200 68137
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:43 +0100] "GET /forum/WebContent/rest/authenticate/get_logged_user HTTP/1.1" 404 1051
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:43 +0100] "GET /forum/WebContent/login_dialog.html HTTP/1.1" 200 4109
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:43 +0100] "GET /forum/WebContent/css/bootstrap-select.css.map HTTP/1.1" 404 1041
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:51 +0100] "GET /forum/WebContent/menu.html HTTP/1.1" 200 3385
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:51 +0100] "GET /forum/WebContent/rest/homepage/subforums HTTP/1.1" 404 1031
0:0:0:0:0:0:0:1 - - [06/Feb/2018:19:35:51 +0100] "GET /forum/WebContent/resources/forum.png HTTP/1.1" 200 1103

Solution

The structure of the WAR you get is incorrect. It must contain WEB-INF directory in its root 'directory' (and not in WebContent directory). Also, classes must go to WEB-INF/classes and not to build/classes. src is usually not included, although it should not harm.

I'd suggest to use some build tool. That could be Maven 3, for instance. An example can be found here: https://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/ For maven project, you just do mvn package and it builds your project for you: compiles, builds jars, then war.

If you prefer ant, take a look at https://ant.apache.org/manual/Tasks/war.html



Answered By - Roman Puchkovskiy
Answer Checked By - Mary Flores (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, July 15, 2022

[FIXED] How to tell Apache Tomcat who must handle received data?

 July 15, 2022     catalina, server, tomcat, war, web-deployment     No comments   

Issue

I'm using the newest Apache Tomcat (9.0.16), with newest Java / OpenSSL. I got a WAR file with a server application from NEXUSe2e.org.

I'm able to send a secure message to a service. After a while someone sends a secure reply message as a new https message.

In the logging, I can see that this message is decrypted by TomCat. It is detected that this is a new SOAP action: ebXML.

This is done, using the following connectors in file %catalina_home%\conf\server.xml

<Connector
  port="443"
  protocol="org.apache.coyote.http11.Http11AprProtocol"
  redirectPort="8443"/>

<Connector
  port="8443"
  protocol="org.apache.coyote.http11.Http11AprProtocol"

  SSLEnabled="true"
  secure="true"
  scheme="https"

  defaultSSLHostConfigName="_default_">
  <SSLHostConfig 
    hostName="_default_"
    certificateVerification="required"

    <Certificate
      certificateChainFile="conf\Certificates\TrustedCertificates.pem"
      certificateFile="conf\Certificates\... .crt"
      certificateKeyFile="conf\Certificates\... .private.key"/>
  </SSLHostConfig>
</Connector>

When the data has been correctly decrypted, it has to go to my server code (NEXUSe2e). How does TomCat know who must handle the data?

  • Does TomCat actively send the received data to the server. Is it somewhere in the configuration file who is expecting the data?
  • Is the server regularly polling to see if data has been received?

Solution

Tomcat knows which application will handle your request by looking at the URL you have requested, and check if there is any context matching. There is no waiting or polling, things are chained automatically.

In your case you are just copying a war file in the webapps directory, this is called Automatic Application Deployment. There are other ways to configure a context but it's nice to keep things simple while it is sufficient.

Things are a little bit more complicated if you are using Virtual Hosts, as Tomcat would start by checking what domain name you requested, and then check which context is concerned.



Answered By - Eugène Adell
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, July 14, 2022

[FIXED] When i am deploying my angular app in tomcat it creates two foldername in the url leads to 404 error

 July 14, 2022     angular, deployment, tomcat, web, web-deployment     No comments   

Issue

When i am deploying my angular app in tomcat it creates two filename in the url leads to 404 error.I have used the command ng build --base-href=usersfront. Please help me with the issue.enter image description here


Solution

Follow bellow steps

  1. ng build --base-href=/userfront/
  2. After successfully build the project
  3. Create userfront folder inside tomcat web-apps and copy all files(html, css and js) from dist folder to userfront folder.
  4. And Try with this url http://localhost:8080/userfront/index.html


Answered By - Santosh Shinde
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, July 13, 2022

[FIXED] How do deploy just my static content in Tomcat / Eclipse?

 July 13, 2022     eclipse, java, tomcat, web-deployment     No comments   

Issue

I am doing development of a web app with Java. My current process is to export the project as a WAR to the Tomcat folder, where it picks it up and reloads the WAR. I wait for it to run through its startup process and away it goes.

I would like to make it not need to do an entire reload when it isn't necessary. If I'm making a small change to a single class, perhaps it could reload just that class. If I'm changing static content, perhaps it could just send that HTML file or JS file.

How can I achieve this? My only real dealbreakers is that I need a solution that works with Eclipse. I'd even consider a different container than Tomcat, although it's where I'm familiar.


Solution

You can hot reload/deploy your application inside Eclipse , but for seperate Tomcat server , I don't think hot reload is possible .

For Eclipse

For eclipse , you can follow the instructions in this link https://mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/

This will speed up your development , but it has it's limitations

Hot deploy will support the code changes in the method implementation only. If you add a new class or a new method, restart is still required.

For Tomcat

I haven't tried it , but all the class files of war will be loaded/rendered from binary memory of Tomcat . So try changing the class files in that location(Not sure about the path of binary class folder ) .

But if you want to render static HTML,js and css from tomcat server , it can be easily done adding another folder inside "webapps" folder (eg : /webappps/static)



Answered By - Umeshwaran
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] Why doesn`t url change when running servlet that presents in welcome-file-list

 July 13, 2022     java, servlets, tomcat, web-deployment, welcome-file     No comments   

Issue

I have simple servlet that prints something to response

@WebServlet(name = "helloServlet", value = "/hello-servlet" , s )
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}

that what web.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <welcome-file-list>
        <welcome-file>hello-servlet</welcome-file>
    </welcome-file-list>
</web-app>

and the problem is that url isn`t changed when it redirect to servlet in welcome-file list
my url : http://localhost:8080/testsss_war_exploded/
but should be : http://localhost:8080/testsss_war_exploded/hello-servlet


Solution

That is the way welcome resources are supposed to work:

The container may send the request to the welcome resource with a forward, a redirect, or a container specific mechanism that is indistinguishable from a direct request.

(Servlet 5.0 Specification)

Tomcat redirects the request internally. If you want to send a HTTP redirect, you need to do it yourself. You can check the original URI to see if the request was forwarded by the welcome files mechanism:

@WebServlet(name = "helloServlet", urlPatterns = {"/hello-servlet"})
public class HelloServlet extends HttpServlet {

   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      if (req.getRequestURI().endsWith("/")) {
         resp.sendRedirect("hello-servlet");
         return;
      }
}

Another solution would be to renounce the the welcome files mechanism and explicitly bind your servlet to the applications root:

@WebServlet(name = "helloServlet", urlPatterns = {"", "/hello-servlet"})
public class HelloServlet extends HttpServlet {

   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      if (req.getServletPath().isEmpty()) {
         resp.sendRedirect("hello-servlet");
         return;
      }
}


Answered By - Piotr P. Karwasz
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, July 3, 2022

[FIXED] How To Upgrade Tomcat In XAMPP

 July 03, 2022     tomcat, tomcat7, tomcat9, xampp     No comments   

Issue

I couldn't find any definitive and organized resources on upgrading Tomcat in XAMPP but found many people are asking, so I thought it best to share the steps I took. For this guide, I will be using XAMPP 7.4.8 on Windows 10, which comes packaged with Tomcat 7.0.105, and upgrading to Tomcat 9.0.37. While I have not tested the following with other versions of XAMPP and Tomcat, this guide should cover most (if not all) versions. This guide assumes you have already downloaded and installed XAMPP on your OS of choice.


Solution

Step 1 - Scrap Old Tomcat

  1. Navigate to your XAMPP base directory (I'll call it %XAMPP_DIR%). E.g., C:\xampp.
  1. Delete the folder named tomcat.

Step 2 - Install New Tomcat

  1. Download Tomcat. You can choose your version here.
  2. Extract the contents of apache-tomcat-[VERSION] to %XAMPP_DIR%\tomcat (the folder you deleted).

Step 3 - Configure XAMPP

By default, XAMPP will point towards the Tomcat version it was bundled with. You need to configure it so it will search for the new version you've install.

  1. Open %XAMPP_DIR%\xampp-control.ini.
  2. Change [BinaryNames]->Tomcat to match the version you are using. E.g., tomcat9.exe (just the major version number).
  3. You should also change [ServiceNames]->Tomcat to match the version you are using, but it is not required. E.g., Tomcat9.
  1. Check if XAMPP recognizes your new Tomcat. You can do this by opening the XAMPP Control Panel. If the log says Problem detected: Tomcat Not Found! then review the steps to ensure you correctly set up Tomcat.
  2. You are good to go! Try starting Tomcat via the XAMPP Control Panel.

Extra

If you plan on running Tomcat as a standalone service, edit %XAMPP_DIR%\catalina_service.bat. Just search for the term tomcat and replace values as needed.

Do not forget to enable JMX if you need it. I just add the following line near the top of %XAMPP_DIR%\tomcat\bin\catalina.bat:

set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8008 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false


Answered By - Oliver
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, June 25, 2022

[FIXED] Why do I get error when compiling java servlet?

 June 25, 2022     compiler-errors, java, servlets, tomcat     No comments   

Issue

I have created a java servlet named TestingServlet and get error when I try to compile file. I have set the classpath for servlet-api.jar and also tried including classpath when compiling:

javac -cp "C:\Program Files\Apache Software Foundation\Tomcat 10.0\lib\servlet-api.jar" TestingServlet.java

Code is :

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class TestingServlet extends HttpServlet {

 public void doGet(HttpServletRequest request, 
  HttpServletResponse response) 
  throws ServletException, IOException {
  
  PrintWriter out = response.getWriter();
  out.println("<HTML>");
  out.println("<HEAD>");
  out.println("<TITLE>Servlet Testing</TITLE>");
  out.println("</HEAD>");
  out.println("<BODY>");
  out.println("Welcome to the Servlet Testing Center");
  out.println("</BODY>");
  out.println("</HTML>");
 }
}

Error is:

TestingServlet.java:6: error: cannot find symbol
public class TestingServlet extends HttpServlet {
                                    ^
  symbol: class HttpServlet
TestingServlet.java:8: error: cannot find symbol
 public void doGet(HttpServletRequest request,
                   ^
  symbol:   class HttpServletRequest
  location: class TestingServlet
TestingServlet.java:9: error: cannot find symbol
  HttpServletResponse response)
  ^
  symbol:   class HttpServletResponse
  location: class TestingServlet
TestingServlet.java:10: error: cannot find symbol
  throws ServletException, IOException {
         ^
  symbol:   class ServletException
  location: class TestingServlet
TestingServlet.java:1: error: package javax.servlet does not exist
import javax.servlet.*;
^
TestingServlet.java:2: error: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
6 errors

Solution

Tomcat 10 Servlet API uses the new jakarta namespace, so the package names changed, as explained in the Tomcat 10 page:

Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*.

So in your case

import jakarta.servlet.*
import jakarta.servlet.http.*


Answered By - Federico klez Culloca
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing