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.

PlugIns and Struts Nightly Build

I had a nice frustrating evening tonight trying to get the nightly build of Struts to work with Tiles, Modules and the Struts Menu. Actually, it wasn't a Struts problem so much as a Struts Menu problem. I was getting a java.lang.AbstractMethodError error when hitting the first action class, and couldn't figure out why. I started by bitching to the struts-dev list, and then filed a bug. Eddie Bush was kind enough to suggest that there was something wrong with my PlugIns. I thought - how could there be - I'm using Tiles and Validator? So I looked at my struts-plugins.xml file and there was the culprit - struts-menu. It turns out that I needed to add the following variable and method to MenuPlugIn.java:

/** The plugin config object provided by the ActionServlet initializing
 *  this plugin.
 */
protected PlugInConfig currentPlugInConfigObject;

/**
 * Method used by the ActionServlet initializing this plugin.
 * Set the plugin config object read from module config.
 * @param currentPlugInConfigObject
 */
public void setCurrentPlugInConfigObject(PlugInConfig currentPlugInConfigObject) {
    this.currentPlugInConfigObject = currentPlugInConfigObject;
}

This post was written in hopes of alleviating someone else's troubles with this same problem.

Posted in Java at Dec 28 2002, 02:00:47 AM MST Add a Comment

Java Development with Ant, The Application

Ant Book If you've been fortunate enough to read Erik Hatcher's Java Development with Ant, you know that there's tons of good tips in it. I read it and I've been recommending it every since. Erik has been continuing development of the sample app for the book ever since it was released. I got many tips from Erik in developing AppFuse and I have to say, it really is a nice example. Maybe I'll get some more stuff now that it appears to have jumped from version 0.4 to 0.9! Here's a message Erik sent about the latest release.

All -

I'm proud (and worried about the support e-mails! :) to announce the 
near-final release of a project demonstrating Ant, XDoclet, Struts, 
JUnit, Cactus, and Lucene.  Its called JavaDevWithAnt as it was written 
for the book Steve and I co-authored and has been refined during 
several presentations I've been giving on Ant, XDoclet and Struts.

The documentation is in draft stage, and my primary goal is to collect 
feedback on polishing the documentation (and the application if there 
are any bugs that surface).  The site where I'm hosting the 
distribution and documentation is:

	http://www.ehatchersolutions.com/JavaDevWithAnt/

Please let me know if you try it out and have suggestions for 
improvement, or just to let me know you tried it and hate it or love 
it, etc.  Feedback more than welcome!  Direct feedback to me at 
[email protected]

	Erik

p.s. Since this e-mail is directed to the XDoclet, Lucene, and Cactus 
lists, here is a brief teaser for you:

XDoclet - its used extensively, even using a custom tag handler to 
generate starter JSP's from Struts form beans.

Lucene - my <index> Ant task is used to index text and HTML files, and 
Lucene's API is used at run-time to query the index.

Cactus - StrutsTestCase is used, although no direct Cactus tests.

Happy information-overload! There's a lot there, but if I could figure it out - I'm sure you can. Erik - finally on Jaguar eh? What took you so long ;-)

Posted in Java at Dec 27 2002, 07:25:45 PM MST 1 Comment

Copying Properties: The Good, the Bad and the Ugly

I realize that having an ActionForm and a POJO with the same getters/setters is ridiculous, but please bear with me for this example. I have a Form and a POJO with Strings, Longs and Dates. The Longs and the Dates get converted into Strings when I get the data from the database using BeanUtils.copyProperties. This works great.

BeanUtils.copyProperties(userForm, user);

However, when going back, it's a different story - here's the ugly way:

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

Date dateChanged = format.parse(userForm.getDateChanged());
Date dateCreated = format.parse(userForm.getDateCreated());

user = new User(userForm.getUserId(), userForm.getPassword(), 
                Long.valueOf(userForm.getDesktopId()),
                Long.valueOf(userForm.getCubeId()), 
                userForm.getCreatedBy(), dateCreated,
		userForm.getChangedBy(), dateChanged);

While this works, it's ugly and a pain. I want something like the ActionForm-Value Object mapper. This mapper allows you to easily copy properties between VOs (or Hibernate Objects) and Forms, and vise-versa.

vo = FormToVOMapper.map(form, new ExampleVO());

So I could do something as simple as user = FormToVOMapper.map(userForm, new User()); I like this mapper and I used it on my last project, where it works great. However, I get the feeling that developers in the Struts Community are using something better - and I want to use it. So please, tell me what it is and lets figure out the best way to do this. Another method I've used in the past is to set the VO (or object) on the form itself, allowing for setting of Strings without copying - and setting dates on the form, to be manipulated by the setter. This framework worked great, and I was actually the happiest with it out of any of the above. Chime in and give me your opinions!

Posted in Java at Dec 27 2002, 03:14:29 PM MST 6 Comments

ChainedExceptions and BeanUtils.copyProperties

I am wondering about a few things, so thought I'd try and get some help from the best source I know - the java.blogs community. First, an update on last night. I experienced some difficulty with Hibernate (persisting child objects) and Struts (nightly build doesn't quite work right with Tiles and Modules) and gave up at 2:00 a.m. Luckily, my head cleared up this morning after a deep 4 hours of sleep and I figured out Hibernate and it appears that a fix for the Tiles/Modules problem was checked into CVS by Cedric.

Now I'm wondering if it's possible to use declared exceptions in Struts to grab all your Exceptions from the bottom up. I can do this in an Action (or even a filter) using the following:

// caught exception e
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
           new ActionError("errors.general"));

while (e != null) {
    errors.add(ActionErrors.GLOBAL_ERROR,
               new ActionError("errors.detail", e.getMessage()));
    e = (Exception) e.getCause();
}

request.setAttribute(Globals.ERROR_KEY, errors);

Can I do this with declared exceptions? Man that would be sweet if I could - I wouldn't have to have any exception handling in my Actions. Maybe that's the easy way out, but it also makes for rapid development - and you can always add them in when you really want them. Two other things I need to do.

  • I have a java.util.Set on my User (Hibernate) object. This refers to a collection of Resume objects. When I generate my StrutsForms, I need to do something in my XDoclet template to turn a java.util.Set into a java.util.ArrayList. I don't know that I have to do this, but I've always used ArrayLists or Vectors on ActionForms for child objects.
  • I am using BeanUtils.copyProperties in a Business Delegate to transfer properties from my User object to a UserForm object. When I do this, the child objects come through as Resume objects - where I really want them to come through as ResumeForms. Is this possible using BeanUtils, or do I have to do this manually?

I should probably do some research now to try and figure this stuff out on my own - but hopefully an answer will come through while I'm doing that ;-). I'll post to the proper mailing lists if I can't figure it out by COB. BTW, if you're using Hibernate, the FAQ is awesome. I wish more OSS (or closed-source software) had documentation this good.

Posted in Java at Dec 27 2002, 11:40:40 AM MST 9 Comments

Ant won't delete a file - any ideas?

I've been experiencing this problem for the last couple of days. Basically, when I run "ant clean" on my project, I get the following error:

file:d:/source/appfuse/build.xml:746: 
  Unable to delete file D:\source\appfuse\dist\appfuse-common.jar

I can delete the "dist" directory in Explorer, and also using "rm -r dist" in Cygwin. Any ideas why Ant is choking on this all of a sudden?

Posted in Java at Dec 26 2002, 05:05:32 PM MST 18 Comments

Will this be an all-nighter?

I'm making a big push to finish the Struts Chapter tonight. Moreover - to finish the sample application. Things are going well so far. I hope it's not an all nighter, but as soon as I'm satisfied with the application, I'll have to deal with proof-reading the chapter, which could be a real headache. On the last chapter, the proof-reading took me an entire day. Ugh.

I just wanna get this darn thing done so I can spend some time with my family again, so I don't have to work weekends, and I can quit (pretty much) working for free. I think the time spent on the sample app will pay off in the long run, as it's already making it easier to develop the application at my new job. I was able to install, compile, deploy and start authenticating/pulling information from Oracle in a matter of hours. That's taken weeks in previous gigs. Of course, if you count the slow machine I had, the meetings and the installation of new software (trying to get the machine setup), then it probably took a week.

I took my home-built machine into work this morning - and all was peachy until I asked the help desk to add my computer to the domain. Politics came into play and I was told that the technicians have to build the machines, not some dev-head. No biggie, just get me a faster machine I said. I argued with the guy for a bit as I tried to explain that a 700 Mhz, 128 MB RAM machine was too slow for Java Development. When he said that was one of the fastest machines they had, I almost choked. Luckily, they found a 2 Ghz machine that I get to start using tomorrow - this'll be the 3rd machine I've built since I started last week. Damn. Sure is nice working from home when you have everything setup already. Do you think that tele-commuting will be the wave of the future? The clients that've paid me to work from home are getting a heckuva better deal than the ones that require an on-site consultant.

Posted in Java at Dec 26 2002, 05:01:44 PM MST Add a Comment

[XDoclet] Generating StrutsForms from a POJO

I was successfully able to complete my mission last night and this morning. I guess you could say that it took me more than 2 hours as I just finished it about an hour ago. I was up until 3 and worked on it a couple of hours this morning too. It's definitely a hack as it still depends on running the <strutsform> task inside the <ejbdoclet> task. But, it doesn't require EJBs anymore, which I think is a good thing. I'll be using it in my chapter's sample app, as well as on my current project - so I think it was time well spent. Now I just have a POJO marked up with Hibernate and StrutsForm/Validator Tags, and walla - life is good. I've opened an enhancement request in XDoclet's JIRA, so you can check out what changed if you're that interested. If you want to use it, you can download the patched xdoclet-apache (43K) module.

Posted in Java at Dec 24 2002, 05:18:19 AM MST Add a Comment

Ant's jspc task - doesn't work on Tomcat 4.1.18

I'm trying to use Ant's JSPC task to pre-compile my JSPs. I've used Erik Hatcher's example from Java Development with Ant. It works great when using a 4.0.x version of Tomcat, and the following jasper.classpath:

<path id="jasper.classpath">
    <fileset dir="${tomcat.home}/lib">
        <include name="jasper-*.jar"/>
    </fileset>
    <fileset dir="${tomcat.home}/common/lib">
        <include name="servlet.jar"/>
    </fileset>
</path>

However, it doesn't work on Tomcat 4.1.17. I had to change the jasper.classpath to find the appropriate jars (they're in different directories now), plus I had to include ant.jar or I got java.lang.NoClassDefFoundError: org/apache/tools/ant/AntClassLoader. Where everything works on the older Tomcat version, now it fails - what gives?

compile-jsp:
     [jspc] Compiling 8 source filesD:\source\appfuse\build\jspc\java
  [jasperc] 2002-12-21 11:15:51 - uriRoot implicitly set to 
            "D:\Tools\tomcat-4.1.17\webapps\appfuse"
  [jasperc] error:/common/footer.jsp(0,0) null
  [jasperc] 2002-12-21 11:15:53 - ERROR-the file '\common\footer.jsp' 
            generated the following general exception: org.apache.jasper.JasperException: 
            /common/footer.jsp(0,0) null

Posted in Java at Dec 21 2002, 05:23:49 PM MST 3 Comments

Will Maven jive with XDoclet?

I'm starting to wonder if Maven will even work for my project. I've been able to setup a lot of dependencies lately and the Maven team has been doing an awesome job of getting my requested jars into their repository. Thanks dIon! The real reason I want to use Maven is to produce a project website. As far as building and running tests, I'd actually prefer to use my Ant script - who I got courtesy of Erik Hatcher.

The problem I'm seeing is that Maven must compile my source to generate the website, and it also seems to be part of the maven java:jar task. And because several of my classes don't exist yet, the compilation fails. Is there any way to tell maven that it must run an Ant task (i.e. ejbdoclet) before it runs its compilation? I'd love to simply tell it to hook into my "package-web" task, rather than trying to compile classes that haven't been generated.

Better yet, is it possible to use Maven simply for downloading jars and generating the website? At this point, it almost seems easier to checkin my 15MB worth of JARs into CVS and use a README file. Maven might be overkill...

Later: Hmmm, maybe XDoclet and Maven can work together. I just found a "maven plugin" in the XDoclet CVS tree. It's description is A Maven plugin to run XDoclet from within Maven. This is very interesting... -- now I need to figure out how to use the damn thing ;-)

Posted in Java at Dec 20 2002, 05:07:17 PM MST 1 Comment

Hibernate Reverse Engineering Tool

Thanks for all the tips for setting my proxy/port for Java apps. Now I just have to try to figure out what the proxy server/port is. I tried to get it yesterday, but everyone only seemed to know the automatic configuration URL. I'm hoping that's a text file with some information in it that I can use.

Jon Lipsky also hooked me up (via e-mail) with the Reverse Engineering Tool for Hibernate. If I get a chance to use it today - I'll report on it's ease of use, etc. I wonder if I can generate my classes, mark them up with XDoclet and then produce my Struts ActionForms. Or possibly, I can generate the classes with Hibernate and create my ValidatorForms by hand. It'd be cool if the Reverse Engineering Tool supported generating an XDoclet-ready class, and also allowed for regeneration. I probably shouldn't be hoping for too much - it might just work as is.

Posted in Java at Dec 20 2002, 12:23:52 AM MST 3 Comments