Remote JMX enabling in start scripts

2009-03-11 Thread David Knox

Hi,
I needed to do this for some testing I'm involved in. Thought it  
might be useful for others also.
I made the changes in the scripts on trunk and tested the build and  
server.


[1]
Index: catalina.sh
===
--- catalina.sh (revision 752728)
+++ catalina.sh (working copy)
@@ -60,6 +60,12 @@
 #   -agentlib:jdwp=transport=$JPDA_TRANSPORT,
 #   address=$JPDA_ADDRESS,server=y,suspend= 
$JPDA_SUSPEND

 #
+#  JMXREMOTE_OPTS  (Optional) Java runtime options used when  
"jmxremote start"

+# command is executed. This command turns on remote jmx
+# access. For JVM defaults, uncomment only the  
"com.sun.
+# management.jmxremote". The other jmxremote  
properties enable
+# finer control and security See: http:// 
java.sun.com/j2se/1.5.0/docs/guide/management/agent.html.

+#
 #   JSSE_HOME   (Optional) May point at your Java Secure  
Sockets Extension
 #   (JSSE) installation, whose JAR files will be  
added to the

 #   system class path used to start Tomcat.
@@ -234,6 +240,19 @@
   shift
 fi

+if [ "$1" = "jmxremote" ]; then
+   echo "Remote JMX enabled"
+   JMXREMOTE_OPTS="-Dcom.sun.management.jmxremote"
+   JMXREMOTE_OPTS="${JMXREMOTE_OPTS} - 
Dcom.sun.management.jmxremote.port=10005"

+   echo "WARNING - Remote JMX is not securely configured"
+# JMXREMOTE_OPTS="${JMXREMOTE_OPTS}  - 
Dcom.sun.management.jmxremote.access.file="
+# JMXREMOTE_OPTS="${JMXREMOTE_OPTS} - 
Dcom.sun.management.jmxremote.password.file="
+   JMXREMOTE_OPTS="${JMXREMOTE_OPTS} - 
Dcom.sun.management.jmxremote.ssl=false"
+   JMXREMOTE_OPTS="${JMXREMOTE_OPTS} - 
Dcom.sun.management.jmxremote.authenticate=false"

+   JAVA_OPTS="${JAVA_OPTS} ${JMXREMOTE_OPTS}"
+   shift
+fi
+
 if [ "$1" = "debug" ] ; then
   if $os400; then
 echo "Debug command not available on OS400"

[2]
Index: startup.sh
===
--- startup.sh  (revision 752728)
+++ startup.sh  (working copy)
@@ -61,4 +61,7 @@
   fi
 fi

+# Uncomment to enable remote jmx
+#exec "$PRGDIR"/"$EXECUTABLE" jmxremote start "$@"
+
 exec "$PRGDIR"/"$EXECUTABLE" start "$@"


cheers,
-- dave

David Knox
Information System Architect
+1 303-748-8906
http://pragmaticis.blogspot.com





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



Re: unique identification in access log

2009-01-08 Thread David Knox
Check the code in org.apache.catalina.valves.RequestDumperValve

-- knoxy
 
On Thursday, January 08, 2009, at 07:51AM, "Josh Pollara" 
 wrote:
>Hi,
>
> 
>
>I'm trying to mimic mod_unique functionality from apache into tomcat. I
>would like to have a unique string printed out in my access log for each
>request tomcat serves. I thought maybe I could do this with "%S User
>Session ID" from org.apache.catalina.valves.AccessLogValve but that
>comes up as null in the access log when enabled.
>
> 
>
>Any ideas?
>
> 
>
>-josh
>
>

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



Re: ?java.lang.NullPointerException? w ith JDBC connection from InitialContext

2008-12-30 Thread David Knox
Hi Robert,

Its not clear from your description if you've tried connecting to the database 
from the linux box using the mysql client. MySQL security is host sensitive and 
you will need to grant the user privileges to access the database from the 
linux host. Using the mysql client and trying to connect to the remote database 
from the linux host, use the same credentials as defined in your realm, will 
give you a clearer picture of what's going on. I suspect the NPE is a symptom 
and the stacktrace in the catalina log is the source of the problem. 
 
--knoxy

On Tuesday, December 30, 2008, at 07:15PM, "Robert Blackburn" 
 wrote:
>I am running Tomcat v6.0. I am developing and testing my app on my
>local Windows machine, then publishing it to a Linux on the server
>(not sure which distro). I have a real annoying issue, I've been
>struggling with it for days.
>
>I am using the same DB for my folder access control (JDBCRealm) as I
>am from within the app itself. My problem is the folder access works
>just fine, I am able to log in with credential from the DB. But I am
>not able to use the connection from within the Java code itself. Every
>connection attempt throws a "java.lang.NullPointerException". To make
>it even more annoying, it works fine when running from my local
>machine, its only on the Linux server that has trouble. So I know its
>not a problem with the DB (I can even point my local machines to the
>server's DB and it works just fine). The DB connection works, because
>the JDBCRealm folder access control works, and the code work off my
>machine.
>
>I have this in the /conf/server.xml
>  connectionName="username" connectionPassword="password"
>connectionURL="jdbc:mysql://localhost:3306/db_name?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"
>driverName="com.mysql.jdbc.Driver" roleNameCol="roleNameCol"
>userCredCol="userCredCol" userNameCol="userNameCol"
>userRoleTable="userRoleTable" userTable="userTable"/>
>
>And I put this in the /conf/Catalina/webapps/ROOT.xml ...
>type="javax.sql.DataSource"  username="username" password="password"
>driverClassName="com.mysql.jdbc.Driver"
>url="jdbc:mysql://localhost:3306/db_name?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"
>validationQuery="select 1"/>
>(I've tried puting this in my /conf/context.xml too, hoping that would
>help, but it didn't)
>
>And this in my web.xml...
>   
>   jdbc/tranzzle
>   javax.sql.DataSource
>   Container
>   
>
>Here is the code I use to get the DB connection:
>  // Obtain our environment naming context
>  Context initCtx = new InitialContext();
>  Context envCtx = (Context) initCtx.lookup("java:comp/env");
>
>  // Look up our data source
>  ds = (DataSource) envCtx.lookup("jdbc/tranzzle");
>   
>  Connection c = ds.getConnection();
>
>Here is what I find in the error logs after I get this error...
>java.lang.NullPointerException
>   
> com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:959)
>   
> com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:
>   
> com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3670)
>   
> com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:
>   com.mysql.jdbc.CallableStatement.(CallableStatement.java:513)
>   com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4422)
>   com.mysql.jdbc.Connection.prepareCall(Connection.java:4496)
>   com.mysql.jdbc.Connection.prepareCall(Connection.java:4470)
>   
> org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareCall(DelegatingConnection.java:275)
>   
> org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareCall(PoolingDataSource.java:292)
>I
>
>And I also see this in the catalina.2008-12-30.log file:
>   Dec 30, 2008 5:29:39 PM org.apache.catalina.realm.JDBCRealm getPassword
>   SEVERE: Exception performing authentication
>   com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:
>Communications link failure during commit(). Transaction resolution
>unknown.
>   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
>   at com.mysql.jdbc.Connection.commit(Connection.java:2259)
>   at org.apache.catalina.realm.JDBCRealm.getPassword(JDBCRealm.java:570)
>   at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:401)
>   at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:349)
>   at 
> org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:258)
>   at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:417)
>   at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>   at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>   at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVa

Re: can mod_jk detect web service unavailable

2008-12-03 Thread David Knox

Hi Zeke,
You didn't say which version of JBOSS you're using, I'm assuming its  
a recent 4.x version that includes buddy-clustering.  You're JBOSS  
cluster will need to be reconfigured to do what you want. The JBOSS  
community lists and wiki (www.jboss.org) is the best place for your  
question. The JBOSS community wiki has several articles on cluster  
configurations.


cheers,
--knoxy


David Knox
Information System Architect
+1 303-748-8906
http://pragmaticis.blogspot.com




On Dec 3, 2008, at 8:33 AM, Zeke wrote:


"Mark Thomas" <[EMAIL PROTECTED]> wrote:
Zeke wrote:

Hi:
I have a JBOSS cluster which use Apache with mod_jk as HTTP load
balancer. In my cluster, some nodes are deployed web service, but  
not all.
For example, node 1 contains web servicebook_service, I can call  
the web
service using URL "http://www.node1.com/book_service";, but node 2  
does not
contain it. I hope mod_jk can help me to detect whether the  
requested web

service exists. That is to say, if I call the web service using "
http://www.loadbalancer.com/book_service";, mod_jk can know only node 1
contains the web service and node 2 not, then the request will  
always be

dispatched to node 1. But with my current configuration on mod_jk and
Apache, I fount that the request can be dispatched to node 2. Then  
surely

exception will be thrown, since the web service not exists on node 2.

Can mod_jk support it? Do I need some specific configuration?
Any suggestion from you will be very appreciated!


Only map the web service url to the nodes where it exists.

Mark



Thanks for the reply, Mark!
But I need a more "dynamic" way. For example, node 1 has deployed  
the web
service war, but it is down for some reason and can not work any  
more. Then
the web service URL will be unavailable while the JBOSS are still  
running.
Mapping the web service url seems can not handle it, the load  
balancer will

still dispatch the request to node 1. I hope mod_jk can detect if the
requested web service is available at runtime.

Thanks!
Zeke



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]