Pat Garner

Greenhorn
+ Follow
since Mar 05, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Pat Garner

@Brendan I didn't have the problem you described and you see my servlet mapping, above, it's pretty straightforward. My browser URLs look like this: https://localhost:8443/Patrac/screens/user.xhtml. I'm using Mojarra/ AS7.
9 years ago
JSF
Regarding Servlet 3.0 programmatic security, when a session times out there is no way to invoke HttpServletRequest#logout().

Does the user remain logged into JAAS?

If so, what is best practice to handle logging out of JAAS after session times out?

How does the container handle the user's subsequent request to login again and create a new session after session timeout?

As an aside, what are the pros and cons of using the following three approaches to handle session timeout when using Servlet 3.0 programmatic security:

HttpSessionListener#sessionDestroyed()
Make the @ManagedBean @SessionScoped LoginManager implement HttpSessionBindingListener and do something in valueUnbound.
Annotate a method in LoginManager with @PreDestroy.

Any other suggested approaches/ best practices advice would surely be appreciated.
9 years ago
In Tomcat 7 the roles have changed. The new roles are as follows:

* manager-gui: allows access to the HTML GUI and the status pages

* manager-script: allows access to the text interface and the status pages

* manager-jmx: allows access to the JMX proxy and the status pages

* manager-status: allows access to the status pages only

These roles are predefined, so you do NOT need to add them via role tags. So, to access the manager application via a web browser you must give the role "manager-gui" to whatever user you want to be able to login to the manager application i.e.



If you want to use a script to deploy automatically i.e. using Ant you need to set up a user for the "manager-script" role i.e.



The documentation at http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html leave a lot to be desired! I had to search the web to get decent instructions. One warning to heed in the Tomcat 7 documentation applies to a production scenario:

The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:

* Users with the manager-gui role should NOT be granted either the manager-script or manager-jmx roles.

* If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.

Hope this saves others from the frustration that I went through...
10 years ago
I've installed and set up Tomcat 7.0.21. I followed Tomcat 7.0 documentation on using the special tasks List, Reload, Install, and Remove. Here's the build.xml snippet:

<path id="compile.classpath">
<fileset dir="${catalina.home}/bin"><include name="*.jar"/></fileset>
<fileset dir="${catalina.home}/lib"><include name="*.jar"/></fileset>
</path>

<echo message="${toString:compile.classpath}"/>

<taskdef resource="org/apache/catalina/ant/catalina.tasks" classpathref="compile.classpath"/>

Here's what happens when I try to execute any of the special tasks i.e. List:

[pgarner@localhost Patrac]$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010

[pgarner@localhost Patrac]$ echo $CLASSPATH

[pgarner@localhost Patrac]$ ant list
Buildfile: /home/pgarner/workarea/Patrac/build.xml
[echo] /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/commons-daemon.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/tomcat/lib/annotations-api.jar:/usr/share/tomcat/lib/catalina-ant.jar:/usr/share/tomcat/lib/catalina-ha.jar:/usr/share/tomcat/lib/catalina-tribes.jar:/usr/share/tomcat/lib/catalina.jar:/usr/share/tomcat/lib/ecj-3.7.jar:/usr/share/tomcat/lib/el-api.jar:/usr/share/tomcat/lib/jasper-el.jar:/usr/share/tomcat/lib/jasper.jar:/usr/share/tomcat/lib/jsp-api.jar:/usr/share/tomcat/lib/postgresql-9.1-901.jdbc4.jar:/usr/share/tomcat/lib/servlet-api.jar:/usr/share/tomcat/lib/tomcat-api.jar:/usr/share/tomcat/lib/tomcat-coyote.jar:/usr/share/tomcat/lib/tomcat-dbcp.jar:/usr/share/tomcat/lib/tomcat-i18n-es.jar:/usr/share/tomcat/lib/tomcat-i18n-fr.jar:/usr/share/tomcat/lib/tomcat-i18n-ja.jar:/usr/share/tomcat/lib/tomcat-jdbc.jar:/usr/share/tomcat/lib/tomcat-util.jar
Trying to override old definition of datatype resources

list:

BUILD FAILED
/home/pgarner/workarea/Patrac/build.xml:481: java.lang.NoClassDefFoundError: org/apache/tomcat/util/buf/B2CConverter

As you can see, all three of $CATALINA_HOME/lib/catalina-ant.jar:$CATALINA_HOME/lib/tomcat-coyote.jar:$CATALINA_HOME/lib/tomcat-util.jar:$CATALINA_HOME/bin/tomcat-juli.jar appear in the class path, above, which I echoed from within Ant. Now, watch this:

[pgarner@localhost Patrac]$ export CLASSPATH=".:$CATALINA_HOME/lib/catalina-ant.jar:$CATALINA_HOME/lib/tomcat-coyote.jar:$CATALINA_HOME/lib/tomcat-util.jar:$CATALINA_HOME/bin/tomcat-juli.jar"
[pgarner@localhost Patrac]$ echo $CLASSPATH
.:/usr/share/tomcat/lib/catalina-ant.jar:/usr/share/tomcat/lib/tomcat-coyote.jar:/usr/share/tomcat/lib/tomcat-util.jar:/usr/share/tomcat/bin/tomcat-juli.jar
[pgarner@localhost Patrac]$ ant list
Buildfile: /home/pgarner/workarea/Patrac/build.xml
[echo] /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/commons-daemon.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/tomcat/lib/annotations-api.jar:/usr/share/tomcat/lib/catalina-ant.jar:/usr/share/tomcat/lib/catalina-ha.jar:/usr/share/tomcat/lib/catalina-tribes.jar:/usr/share/tomcat/lib/catalina.jar:/usr/share/tomcat/lib/ecj-3.7.jar:/usr/share/tomcat/lib/el-api.jar:/usr/share/tomcat/lib/jasper-el.jar:/usr/share/tomcat/lib/jasper.jar:/usr/share/tomcat/lib/jsp-api.jar:/usr/share/tomcat/lib/postgresql-9.1-901.jdbc4.jar:/usr/share/tomcat/lib/servlet-api.jar:/usr/share/tomcat/lib/tomcat-api.jar:/usr/share/tomcat/lib/tomcat-coyote.jar:/usr/share/tomcat/lib/tomcat-dbcp.jar:/usr/share/tomcat/lib/tomcat-i18n-es.jar:/usr/share/tomcat/lib/tomcat-i18n-fr.jar:/usr/share/tomcat/lib/tomcat-i18n-ja.jar:/usr/share/tomcat/lib/tomcat-jdbc.jar:/usr/share/tomcat/lib/tomcat-util.jar
Trying to override old definition of datatype resources

list:
[list] OK - Listed applications for virtual host localhost
[list] /manager:running:0:manager
[list] /:running:0:ROOT
[list] /docs:running:0:docs
[list] /examples:running:0:examples
[list] /host-manager:running:0:host-manager

BUILD SUCCESSFUL
Total time: 3 seconds

Why can the List target not see the needed JAR files on its class path unless I set it in my Linux user environment? I don't want to have to add an export CLASSPATH entry in .bash_profile. I should be able to set the class path for executing an Ant task inside of an Ant build script. What am I not understanding here?
10 years ago
Perhaps you could forward the following message to Guido, since his email listed at Sourceforge is being returned (reason: 550 unknown user) and I am therefore unable to send him a message:

1. The Cewolf taglib documentation at cewolf.sourceforge.net indicates that the attribute tooltipgeneratorid of <map> should refer to a com.jrefinery.chart.tooltips.ToolTipGenerator object, but in the example in the tutorial the tool tip generator implements de.laures.cewolf.tooltips.CategoryToolTipGenerator, which creates confusion. It appears to me that jrefinery.com seems to have a squatter sitting on it.

2. The Cewolf taglib documentation does not indicate that the attribute 'id' is allowed for a <map> node. The only two attributes listed are linkgeneratorid and tooltipgeneratorid. However, in the example in the tutorial the id attribute is used, i.e. <cewolf:map id="pageViews"/>, and this is also confusing.

I am having difficulty getting tool tips to work in Firefox (the tool tips work in IE just fine, but not in Firefox) and such is the reason that I began looking at the Cewolf tool tip generator documentation more closely.

Meanwhile, if you, Ulf, would be able to provide clarification of the above two issues and indicate how I might get tool tips to work in Firefox I would greatly appreciate it! Thanks!
12 years ago
Yessirree Wayne you surely were right! I was reusing the ps (PreparedStatement) and rs (ResultSet) variables multiple times without calling close() in between, and this is what caused the database cursor leak. Thanks for your help!

Originally posted by Pat Garner:
I've looked about the web for the answer to this problem but I haven't gotten a clear understanding of the problem. Neither have I discovered a practical way to fix it. I'm pasting pseudo code below, displayed in a tree-like structure so it's clear how the Connection object is being passed around. Hopefully it will be clear by looking at the pseudo code that no ResultSet nor PreparedStatement is being passed around. All ResultSets and PreparedStatements are created locally using the passed-around Connection and they are then closed locally in a finally block.
So let there be no mistake: I am closing all ResultSet and PreparedStatement objects locally. Each method that the Connection object instance gets passed into closes the ResultSet object instance and the PreparedStatement object instance within a finally block.
PopulateStudent
---------------
  |
  |--- Class.forName(oracleDriver);
  |
  |--- con = DriverManager.getConnection(oraDevURL,dbUser,dbPass);
  |
  |--- ps = con.prepareStatement(sb.toString());
  |
  |--- rs = ps.executeQuery();
  |
  |--- while(rs.hasNext())
  |    -----
  |      |
  |      |--- student = Student.getInstance(rs.getString(), rs.getDate(), con);
  |      |    -------
  |      |      |
  |      |      |----  Sequence.STUDENT.getNextId(con);
  |      |          --------
  |      |            |
  |      |            |----  ps = con.prepareStatement(SELECT);
  |      |            |
  |      |            |----  rs = ps.executeQuery();
  |      |            |
  |      |            |----  if(sequence not initialized)
  |      |            |      {
  |      |            |          ps = con.prepareStatement(INIT);
  |      |            |          ps.executeUpdate();
  |      |            |          ps = con.prepareStatement(SELECT);
  |      |            |          rs = ps.executeQuery();
  |      |            |      }
  |      |            |
  |      |            |
  |      |            |----  ps = con.prepareStatement(INCREMENT);
  |      |            |
  |      |            |----  ps.executeUpdate();
  |      |            |
  |      |            |----  rs.close();
  |      |            |
  |      |            |----  ps.close();
  |      |  
  |      |--- student.insert(con);
  |           -------
  |             |
  |             |----  ps = con.prepareStatement(insert.toString());
  |             |
  |             |----  for each field in the student object instance...
  |             |      {
  |             |          ps.setXXX(fieldIndex,fieldValue);
  |             |      }
  |             |
  |             |----  ps.executeUpdate();
  |             |
  |             |----  ps.close();
  |
  |----  rs.close();
  |
  |----  ps.close();
  |
  |----  con.close();

If it's not obvious from the above diagram how the code is written and executed I'll be happy to post the code itself.
Here's the problem:
1. I get an ORA-01000: maximum open cursors exceeded after only 296 rows of student data are inserted into the student table using the Student.insert() method.
2. The problem goes away if, after every couple hundred rows have been inserted, inside the while(rs.hasNext()) I set con=null and then reinitialize con.
So it appears that the problem is the Connection object. Although rs.close() and ps.close() are properly called the Connection object does not close the cursors. This is either a big nasty bug or I'm doing something _way_ wrong. If it's a bug, this is something that is huge and should be well documented. Where's the workaround and/or bug fix? I'm using the oracle thin driver. As an aside, does anybody know for sure whether this is a driver bug or an Oracle DBMS bug?
I absolutely cannot reset the connection every couple hundred rows because I lose the ability to rollback all previously inserted rows if an exception gets thrown.
So what can I do? Any ideas would be much appreciated.
Thanks,
Pat

PopulateStudent
---------------
  |
  |--- Class.forName(oracleDriver);
  |
  |--- con = DriverManager.getConnection(oraDevURL,dbUser,dbPass);
  |
  |--- ps = con.prepareStatement(sb.toString());
  |
  |--- rs = ps.executeQuery();
  |
  |--- while(rs.hasNext())
  |    -----
  |      |
  |      |--- student = Student.getInstance(rs.getString(), rs.getDate(), con);
  |      |    -------
  |      |      |
  |      |      |----  Sequence.STUDENT.getNextId(con);
  |      |          --------
  |      |            |
  |      |            |----  ps = con.prepareStatement(SELECT);
  |      |            |
  |      |            |----  rs = ps.executeQuery();
  |      |            |
  |      |            |----  if(sequence not initialized)
  |      |            |      {
  |      |            |          ps = con.prepareStatement(INIT);
  |      |            |          ps.executeUpdate();
  |      |            |          ps = con.prepareStatement(SELECT);
  |      |            |          rs = ps.executeQuery();
  |      |            |      }
  |      |            |
  |      |            |
  |      |            |----  ps = con.prepareStatement(INCREMENT);
  |      |            |
  |      |            |----  ps.executeUpdate();
  |      |            |
  |      |            |----  rs.close();
  |      |            |
  |      |            |----  ps.close();
  |      |  
  |      |--- student.insert(con);
  |           -------
  |             |
  |             |----  ps = con.prepareStatement(insert.toString());
  |             |
  |             |----  for each field in the student object instance...
  |             |      {
  |             |          ps.setXXX(fieldIndex,fieldValue);
  |             |      }
  |             |
  |             |----  ps.executeUpdate();
  |             |
  |             |----  ps.close();
  |
  |----  rs.close();
  |
  |----  ps.close();
  |
  |----  con.close();
I've looked about the web for the answer to this problem but I haven't gotten a clear understanding of the problem. Neither have I discovered a practical way to fix it. I'm pasting pseudo code below, displayed in a tree-like structure so it's clear how the Connection object is being passed around. Hopefully it will be clear by looking at the pseudo code that no ResultSet nor PreparedStatement is being passed around. All ResultSets and PreparedStatements are created locally using the passed-around Connection and they are then closed locally in a finally block.
So let there be no mistake: I am closing all ResultSet and PreparedStatement objects locally. Each method that the Connection object instance gets passed into closes the ResultSet object instance and the PreparedStatement object instance within a finally block.
PopulateStudent
---------------
|
|--- Class.forName(oracleDriver);
|
|--- con = DriverManager.getConnection(oraDevURL,dbUser,dbPass);
|
|--- ps = con.prepareStatement(sb.toString());
|
|--- rs = ps.executeQuery();
|
|--- while(rs.hasNext())
| -----
| |
| |--- stu = Student.getInstance(rs.getString(),rs.getDate(), con);
| | -------
| | |
| | |---- Sequence.STUDENT.getNextId(con);
| | --------
| | |
| | |---- ps = con.prepareStatement(SELECT);
| | |
| | |---- rs = ps.executeQuery();
| | |
| | |---- if(sequence not initialized)
| | | {
| | | ps = con.prepareStatement(INIT);
| | | ps.executeUpdate();
| | | ps = con.prepareStatement(SELECT);
| | | rs = ps.executeQuery();
| | | }
| | |
| | |
| | |---- ps = con.prepareStatement(INCREMENT);
| | |
| | |---- ps.executeUpdate();
| | |
| | |---- rs.close();
| | |
| | |---- ps.close();
| |
| |--- stu.insert(con);
| -------
| |
| |---- ps = con.prepareStatement(insert.toString());
| |
| |---- for each field in the student object instance...
| | {
| | ps.setXXX(fieldIndex,fieldValue);
| | }
| |
| |---- ps.executeUpdate();
| |
| |---- ps.close();
|
|---- rs.close();
|
|---- ps.close();
|
|---- con.close();

If it's not obvious from the above diagram how the code is written and executed I'll be happy to post the code itself.
Here's the problem:
1. I get an ORA-01000: maximum open cursors exceeded after only 296 rows of student data are inserted into the student table using the Student.insert() method.
2. The problem goes away if, after every couple hundred rows have been inserted, inside the while(rs.hasNext()) I set con=null and then reinitialize con.
So it appears that the problem is the Connection object. Although rs.close() and ps.close() are properly called the Connection object does not close the cursors. This is either a big nasty bug or I'm doing something _way_ wrong. If it's a bug, this is something that is huge and should be well documented. Where's the workaround and/or bug fix? I'm using the oracle thin driver. As an aside, does anybody know for sure whether this is a driver bug or an Oracle DBMS bug?
I absolutely cannot reset the connection every couple hundred rows because I lose the ability to rollback all previously inserted rows if an exception gets thrown.
So what can I do? Any ideas would be much appreciated.
Thanks,
Pat