Matt RaibleMatt Raible is a writer with a passion for software. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.
You searched this site for "java". 1,588 entries found.

You can also try this same search on Google.

Tomcat load-balancing or private instances?

Did you know you can (1) create load-balanced instances of Tomcat and (2) create multiple (private) instances of Tomcat? All you need is Apache HTTP Server and some know-how. I updated this article for Apache 2.x, Tomcat 4.x, and private JVMs and published it to http://raibledesigns.com/tomcat. With permission of the original author, Pascal Forget.

Posted in Java at Sep 26 2002, 02:02:44 AM MDT Add a Comment

Upgrading Rampage.

I went on an upgrading rampage yesterday and ended the day with the worst feeling. My Struts 1.1b2 application appeared to work fine on most things, however, I kept getting the following error when I tried to submit a form with indexed input values:

java.lang.reflect.InvocationTargetException
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 	at java.lang.reflect.Method.invoke(Method.java:324)
 	at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:475)
 	at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:410)
 	at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:749)
 	at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:780)
...
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
 	at java.util.ArrayList.RangeCheck(ArrayList.java:508)
 	at java.util.ArrayList.get(ArrayList.java:320)
 	at com.onpoint.webapp.form.QuestionForm.getAnswer(QuestionForm.java:321)

The items I attempted to upgrade were:

After hours of banging my head against the wall for hours and even trying versions of my code from a week ago, I decided to try the "classic" compiler in Ant. Which I soon learned should now be named "modern." Whalla - it fixed the above problem! My advice - DON'T USE JIKES 1.16 to compile your Struts-based web app! I also found that switching to modern from jikes reduced my build process from 1 min 20 seconds to 50 seconds - I'm sold. my face after fixing this bug

I ended up not upgrading to Tomcat 4.1.12 (rather to 4.0.5) because I found that my error-pages were not being recognized. I hope that a client using the application never sees an error page, but if they do - I'd rather them see my pretty page vs. a stacktrace.

Posted in Java at Sep 25 2002, 06:12:06 AM MDT Add a Comment

[ANNOUNCE] StrutsTestCase v1.9 Released

StrutsTestCase v1.9 improves support for Struts 1.1b2 (including support for testing Tiles and sub-applications), provides several requested enhancements, and fixes many reported defects.

 The project home page can be found here:

     http://strutstestcase.sourceforge.net

 Notes for this release can be found here:

     http://sourceforge.net/project/shownotes.php?release_id=112307

I upgraded my current project to use Cactus 1.4.1 and StrutsTestCase 1.9 this morning - and everything works great! I had to add :80 to a few URLs and add ServletRedirector?Cactus_Service=RUN_TEST to my testURL for runservertests, but that was it. I've posted a message to the Cactus User list asking why these changes were necessary. If I was really smart, I'd write a whole bunch of HttpUnit and Cactus tests for Roller before integrating Tiles. Probably save me a whole bunch of time in the end - if I could only get that through to my brain.

Posted in Java at Sep 24 2002, 05:08:21 AM MDT Add a Comment

Tomcat Security Updates.

If you're using Tomcat 4.0.4 or Tomcat 4.1.10 - you might want to upgrade to 4.0.5 or 4.1.12.

A security vulnerability has been confirmed to exist in all Apache Tomcat 4.x versions (including Tomcat 4.0.4 and Tomcat 4.1.10), which allows to use a specially crafted URL to return the unprocessed source of a JSP page, or under special circumstances a static resource which would otherwise have been protected by security constraint, without the need of being properly authenticated.

Posted in Java at Sep 24 2002, 01:01:29 AM MDT Add a Comment

Struts vs. Java Server Faces.

From www.theserverside.com:

Many have have wondered at what the future holds for Struts, now that an early access release of JavaServer Faces is available. Craig McClanahan, JSF Spec Lead and Lead Architect for Struts has recently commented on the subject. Craig is working on an integration library for JSF and Struts 1.1 that will allow migration to JSF without major code changes to existing struts apps. [ Craig's email on Struts + JSF integration ]

I'm smack dab in the middle of a major time crunch on my current project, or I'd review the above article and post my opinion. Maybe in the next few days.

Posted in Java at Sep 20 2002, 02:57:31 AM MDT Add a Comment

Upgrading to Struts 1.1?

My opinion is "of course!" But that's party due to the fact that I'm an upgrade-happy developer. I'll upgrade just to be on the bleeding edge and know that I'm not missing anything. However, I do end up "backing out" of some upgrades. It's fun though, how else are you going to learn? TheServerSide.com has a new article discussing if you should upgrade to Struts 1.1 - check it out. I'm on the nightly build.

Java Server Faces Public Draft and EA download is available. I saw this last night, but Rick Salsa beat me to the punch on weblogging it. I was hoping to download and play around with it today, and give my opinion, but alas, the release I'm doing is taking a bit longer than expected.

Web Builder Conference 2002. Is anyone else going? We're having a Annual Shareholders Meeting in Vegas the weekend before, and I'm going to attend the conference the following week (Sept. 9 - 11). It'll be my first "reporting" experience, so watch this site for updates/reviews. I was one of the first to register so I'll have wireless internet access throughout the conference. My 3 goals for the experience are (1) win, (2) have fun, and (3) get some roller development done. Of course, if I'm accomplishing #1, then #2 is taken care of and #3 might slip a little. Vegas Baby!

Update on Netscape 7. It sucks worse than I originally thought - it installed on my WinXP box, but won't run - similar to OS X 10.2. The one successfull install? On Red Hat 7.3.

Posted in Java at Aug 30 2002, 10:14:17 AM MDT Add a Comment

Invalid Reference to Login Page.

If you're using form-based authentication in your Tomcat Application - you might've seen this error before:

Apache Tomcat/4.0.4 - HTTP Status 400 - Invalid direct reference to form login page

type: Status report

message: Invalid direct reference to form login page

description: The request sent by the client was syntactically incorrect (Invalid direct reference to form login page).

Well, the good news is - I figured out how to get around this today. Basically, it's caused when someone tried to go directly to your <form-login-page> to login, rather than a protected resource.

I use my index.jsp (welcome-file-list) page to do a redirect to a projected resource:

index.jsp
--------
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<logic:redirect page="/do/mainMenu"/%gt;

So I merely added the error-page declaration below to my web.xml, and whalla - no more error message!

<error-page>
<!-- 400 code is from trying to go directly to login.jsp -->
    <error-code>400</error-code>
    <location>/index.jsp</location>
</error-page>

Posted in Java at Aug 28 2002, 06:07:51 AM MDT 5 Comments

XDoclet and Struts Validator

From the struts-dev list and Erik Hatcher:

My XDoclet Struts Validator validation.xml (for Struts 1.1) has been posted to the XDoclet tracker.
I'm hoping it will be added to the codebase and put into the upcoming new release of XDoclet (although I'm using XDoclet from CVS builds). Read the HTML file attachment on the issue page above for an example of how it works. If you're hand-coding validation.xml and using ValidatorForm extensions then this is for you!

I can't wait to use XDoclet in my next project! On my current project, I've already written most of the ValidationForms I need. I used the Generator package to do this, but I hope to either (1) refactor my current project to use Castor/XDoclet like Roller, or (2) use it on my next project.

I ordered an Ant book this evening in hopes of learning a lot more about Ant. I think I know a lot, but there's always room for more knowledge.

Posted in Java at Aug 25 2002, 03:47:45 PM MDT Add a Comment

Upgrading from Tyrex 0.9.7 to Commons DBCP.

I'm trying to upgrade from Tyrex 0.9.7 (ships with Tomcat 4.0.4 for connection pooling) to the Commons DBCP (ships with Tomcat 4.1.x for connection pooling). I've set it up according to these instructions. However, my connections don't seem to be getting closed, or it's closing the connection pool and I get a "connection is closed" error.

If I use this method to close connections, I get "connection is closed:"

    /** Closes a connection from the connection pool */
    public void closeConnection(Connection con) throws ServiceLocatorException
    {
        try {
            con.close();
        } catch (SQLException sqle) {
            logger.error("SQLException: " + sqle.getMessage());
            throw new ServiceLocatorException(sqle);
        } finally {
            if (con != null) {
                // try again
                try {
                    con.close();
                } catch (SQLException csqle) {
                    // ignore
                }
            }
        }
    }

I changed my closeConnection method (see below). It seems to work better (no closed connection error), but I am wondering about the open connections to mysql. When I monitor them (show status; watch Threads_connected), there are 3 at first (I'm guessing from my monitor connection, JDBCRealm and Connection pool). It gets up to 5, any tips on how I can tell if connection pooling is working?

    /** Closes a connection from the connection pool */
    public void closeConnection(Connection con) throws ServiceLocatorException
    {
        try {
            con.close();
        } catch (SQLException sqle) {
            logger.error("SQLException: " + sqle.getMessage());
            throw new ServiceLocatorException(sqle);
        } finally {
            // try again
            try {
                if (!con.isClosed()) {
                	con.close();
                }
            } catch (SQLException csqle) {
                // ignore
            }
        }
    }

I think the problem is that it's not creating a "pooled" connection. When you are using a connection pool, con.close() should just return it, not actually close it - right?

In my getPooledConnection method, I'm getting "Non-Pooled Connection" each time.

    /** 
     * Retrieves a connection from the connection pool
     */
    public Connection getPooledConnection() throws ServiceLocatorException
    {
        try {
            ds = (DataSource) getEnvContext().lookup(Constants.JNDI_DB);
        } catch (NamingException ex) {
            logger.error("NamingException: " + ex.getMessage());
            throw new ServiceLocatorException(ex);
        }
        
        try {
            if (ds instanceof ConnectionPoolDataSource) {
                ConnectionPoolDataSource poolDataSrc = (ConnectionPoolDataSource) ds;
                PooledConnection pc = poolDataSrc.getPooledConnection();
                con = pc.getConnection();
                if (logger.isDebugEnabled()) {
                    logger.debug("Pooled Connection");
                }
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("Non-Pooled Connection");
                }
                con = ds.getConnection();
            }
        } catch (SQLException ex) {
            logger.error("SQLException: " + ex.getMessage());
            throw new ServiceLocatorException(ex);
        }
        return con;
    }

If you have a WAG/suggestion, please enlighten me!

Posted in Java at Aug 24 2002, 04:12:15 AM MDT Add a Comment

Struts Code Generator for Eclipse.

Easy Struts 0.5.0 just released. This is a code generator that seems like a nice product - I've installed it, but never used. I think these types of tools are great for developers that love to use an IDE. If you're like me and you prefer a good ol' text editor - this tool won't help you.

Posted in Java at Aug 22 2002, 02:44:13 AM MDT Add a Comment