JSP compilation fails with Java 9

2017-01-08 Thread Patil, Shital
We are assessing Java 9(early access) and JSP compilation is badly broken with 
Java 9. Even basic java objects(java.lang.Object) are not accessible while 
compilation. Appears to be because of jigsaw(modular)

Any solution or alternative to this problem ?





Re: 404 errors accessing webapp URLs using local IP address on fresh Tomcat 8.5.9 install

2017-01-08 Thread modjklist
I should mention that to configure hostB (e.g. 192.168.0.2) to listen to hostA 
(e.g. 192.168.0.1), I simply added 

Listen 192.168.0.2:80 
Listen 192.168.0.2:443 

to hostB httpd.conf file. I did not create a virtual host (is that OK?). I also 
didn't modify httpd.conf on hostA. 

- Original Message -

From: modjkl...@comcast.net 
To: "Tomcat Users List"  
Sent: Sunday, January 8, 2017 9:57:32 PM 
Subject: 404 errors accessing webapp URLs using local IP address on fresh 
Tomcat 8.5.9 install 

I have two Linux servers connected via a cross-connect cable with internal IP 
addresses 192.168.0.1 (hostA) and 192.168.0.2 (hostB). 

hostA runs CentOS 5, and hostB CentOS 7. 

hostB runs Apache 2.4.x, and Tomcat 8.5.9. All web traffic gets routed to port 
443 (e.g. HTTPS) of Apache web server hostB. All web application traffic (e.g. 
https://www.example.com/mywebapp/somepage) is then passed to Tomcat via mod_jk 
version 1.2.42 on port 8009. Additionally, hostB Apache web server is 
configured to listen on 192.168.0.2 port 8009 (hostA Apache web server is not 
configured as such). 

If hostA attempts to access a webpage on hostB (via hostB external IP address) 
from a browser or command line, such as: 
[root@hostA ~]# curl -I http://www.example.com/mywebapp/somepage 

it returns status 200 (good). 

Now, if I modify the hostA /etc/hosts file hostA accesses to my website 
(www.example.com) on hostB through the cross-connect cable (e.g. 192.168.0.2 
rather than the external IP address), the webpage returns error 404. 

What can I change to get status 200? 

My web addresses are xxx.xxx.xxx.xxx (e.g. IPv4). I know Tomcat configures IPv6 
by default. So, I modified the setenv.sh as follows: 

CATALINA_OPTS="-Xms512M -Xmx1024M -Djava.awt.headless=true 
-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true" 

This didn't change the result. 

As another clue, I observe that hostA always reports status 200 (good) when 
accessing any hostB webpage in www.example.com that is NOT part of /mywebapp, 
for both internal and external IP addresses. 

Any ideas what I can try to resolve this? I'm new to Tomcat and this is fresh 
install (previously used GlassFish) on a brand new server. Thanks in advance 
for any advice. 



404 errors accessing webapp URLs using local IP address on fresh Tomcat 8.5.9 install

2017-01-08 Thread modjklist
I have two Linux servers connected via a cross-connect cable with internal IP 
addresses 192.168.0.1 (hostA) and 192.168.0.2 (hostB). 

hostA runs CentOS 5, and hostB CentOS 7. 

hostB runs Apache 2.4.x, and Tomcat 8.5.9. All web traffic gets routed to port 
443 (e.g. HTTPS) of Apache web server hostB. All web application traffic (e.g. 
https://www.example.com/mywebapp/somepage) is then passed to Tomcat via mod_jk 
version 1.2.42 on port 8009. Additionally, hostB Apache web server is 
configured to listen on 192.168.0.2 port 8009 (hostA Apache web server is not 
configured as such). 

If hostA attempts to access a webpage on hostB (via hostB external IP address) 
from a browser or command line, such as: 
[root@hostA ~]# curl -I http://www.example.com/mywebapp/somepage 

it returns status 200 (good). 

Now, if I modify the hostA /etc/hosts file hostA accesses to my website 
(www.example.com) on hostB through the cross-connect cable (e.g. 192.168.0.2 
rather than the external IP address), the webpage returns error 404. 

What can I change to get status 200? 

My web addresses are xxx.xxx.xxx.xxx (e.g. IPv4). I know Tomcat configures IPv6 
by default. So, I modified the setenv.sh as follows: 

CATALINA_OPTS="-Xms512M -Xmx1024M -Djava.awt.headless=true 
-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true" 

This didn't change the result. 

As another clue, I observe that hostA always reports status 200 (good) when 
accessing any hostB webpage in www.example.com that is NOT part of /mywebapp, 
for both internal and external IP addresses. 

Any ideas what I can try to resolve this? I'm new to Tomcat and this is fresh 
install (previously used GlassFish) on a brand new server. Thanks in advance 
for any advice. 


Re: LogAbandoned Stack Trace?

2017-01-08 Thread Phil Steitz
On 1/6/17 3:44 PM, Jerry Malcolm wrote:
> On 1/6/2017 4:30 PM, Christopher Schultz wrote:
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA256
>>
>> Jerry,
>>
>> On 1/6/17 10:35 AM, Jerry Malcolm wrote:
>>> I'm getting "too many connections" errors.
>> Where?
>>
>> Can you provide an exact error message and, better yet, a stack
>> trace?
>>
>>> I'm pretty sure I am configured with enough connections that I
>>> shouldn't run out.  So I'm assuming I'm leaving some connections
>>> open.
>> That's a good assumption.
>>
>>> I have LogAbandoned="true" in my jdbc resource statements.  The
>>> doc says TC will log a stack trace of abandoned connections.  But I
>>> don't see any stack traces.  Would they be in stderr, stdout,
>>> catalina log? Or is it that I'm actually not getting any
>>> abandoned?
>> Which db connection pool are you using? Standard (DBCP-based) or
>> tomcat-pool? A full (sanitized)  configuration would help.
>>
>> - -chris
>>
> Chris,
> Stack trace follows.  It looks like it may be mySQL that's
> rejecting the connection.  But even if that's the case, it's
> probably because I'm not closing some connections, which should
> still generate a logAbandoned stack trace, correct?  I believe I'm
> using dbcp.  Not doing anything fancy... Just defining data source
> resources in the context file:
>
> name="jdbc/cis" auth="Container" type="javax.sql.DataSource"
> maxTotal="100" maxIdle="30" maxWaitMillis="1"
> removeAbandoned="true" removeAbandonedTimeout="60"
> logAbandoned="true" username="" password="xxx"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/xx" />
In dbcp 2, the "removeAbandoned" config option was replaced by
removedAbondonedOnBorrow and removeAbandonedOnMaintenance.  You need
to set one of these to true the get abandoned connection cleanup to
work.  See [1].

|Phil

[1] http://commons.apache.org/proper/commons-dbcp/configuration.html
|||
>
>
>
> java.sql.SQLException: Cannot create PoolableConnectionFactory
> (Data source rejected establishment of connection,  message from
> server: "Too many connections")
> at
> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2195)
> at
> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:1945)
> at
> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412)
> at
> jwm.servletdb.ServletDBData.getInstance(ServletDBData.java:139)
> at
> jwm.servletdb.ServletDBData.getInstance(ServletDBData.java:93)
> at
> jwm.servletdb.ServletDBData.getInstance(ServletDBData.java:62)
> at
> org.apache.jsp.jsp.login.login_005fv2_jsp._jspService(login_005fv2_jsp.java:450)
> at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
>
> at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721)
> at
> org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
> at
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
> at
> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
> at
> org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:411)
> at
> org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:256)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
> at
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
> at
> org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:291)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngin

Tomcat 8, 8.5 and 9 returning another apps environment with context.lookup() from a .parallelStream()

2017-01-08 Thread Christopher Zinn
Hello all,
   This is my first time posting to a mailing list so hopefully I'm doing
this correctly.

   We are running into an issue where we have multiple copies of the same
WAR loaded on a Tomcat instance each with its own context.xml.
The initial problem I was trying to diagnose was A JNDI lookup to a
Connection Pool in one of the WARs was returning the connection pool of one
of the others.
The problem only happens when the JNDI lookup is performed within a
parallelStream().

   I was able to produce a very simple WAR with a single servlet and a
context XML to reproduce the problem I'm having (See below).

   If you run the servlet from the first application, it works correctly.
You will see that it only ever looks up 'Test 1'.
When I run the servlet from the second application it will only return Test
1 in the first part (stream()) but a mix of 'Test 1' and 'Test 2' in the
parallelStream() part.

   Thanks in advance for any advice or comments to our issue.

---
My Environment:  (The problem happens to us on our CENTOS Linux
environments as well)
Server version: Apache Tomcat/8.5.9
Server built:   Dec 5 2016 20:18:12 UTC
Server number:  8.5.9.0
OS Name:Windows 10
OS Version: 10.0
Architecture:   amd64
JVM Version:1.8.0_111-b14
JVM Vendor: Oracle Corporation

Runtime.getRuntime().availableProcessors() returns 12 on my machine.
CPU: Intel i7-5820K


My Test Servlet:
@WebServlet(urlPatterns = "/test")
public final class MyServlet extends HttpServlet
{
private static List someNumbers = generateNonsense();

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
StringBuilder answerBuilder = new StringBuilder();

// This should be okay.
someNumbers.stream().forEach( number ->
{
answerBuilder.append(".stream() Looked up ")
.append(lookupEnvironmentValue())
.append("");
});

 // This is most likely bad
someNumbers.parallelStream().forEach( number ->
{
synchronized (MyServlet.class)
{
answerBuilder.append(".parallelStream() Looked up ")
.append(lookupEnvironmentValue())
.append("");
}
});

response.setContentType("text/html");
response.getWriter().write(answerBuilder.toString());
}

private String lookupEnvironmentValue()
{
try
{
Context context = new InitialContext();
return (String) context.lookup("java:comp/env/testName");
}
catch(NamingException e)
{
e.printStackTrace();
return e.getMessage();
}
}

private static List generateNonsense()
{
List nonsense = new ArrayList<>();
for(int n=0; n<1000; n++)
nonsense.add(n);

return nonsense;
}
}


My test context.xml





Preparing Tomcat:
Step 1: Download the core.zip of Tomcat 8, 8.5 or 9
Step 2: create a apache-tomcat-8.5.9/conf/Catalina/localhost directory
Step 3: create two files in this directory with the contents of my
context.xml: test1.xml and test2.xml and change the value and path in the
second one to '2'
Step 4: Create a WAR with just the sample servlet I have here. and then
drop them in apache-tomcat-8.5.9/webapps directory / call them test1.war
and test2.war
Step 5: Go into apache-tomcat-8.5.9/bin and catalina start to start it up.

The urls to test for me are:
http://localhost:8080/test1/test
http://localhost:8080/test2/test


Re: does Tomcat 8.5.9 have UTF-8 encoding throughout by default?

2017-01-08 Thread tomcat

On 07.01.2017 23:57, modjkl...@comcast.net wrote:

Anyone know if it has UTF-8 encoding throughout out-of-the-box, or do I need to 
configure it to be so?

I'm seeing some headers using iso-8859-1 and I'm not sure where they're being 
generated.


Hi.
You are not being very explicit as to what headers you are worrying about.
But in any case, the default character set for HTTP headers (and for the WWW in general) 
is still iso-8859-1 (unfortunately, one could say). That is not specific to Tomcat, it's 
the HTTP RFCs.


Tomcat itself is a Java program, and the character represntation inside Java is Unicode, 
but that's another matter.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org