Archive for December, 2007
Maven JBoss Plugin Won’t Deploy EAR
Posted by: | CommentsI’ve just spent a couple hours troubleshooting a problem that I should have realized sooner. I was trying to deploy a Flex/Java application to JBoss using a Maven script (with the JBoss 1.5 plugin) and I was getting an error like this:
Error opening connection java.io.IOException: Server returned HTTP response code: 505 for URL: http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=undeploy&argType=java.net.URL&arg0=file:C:\Documents and Settings\umptyscratch\deploy/target/umptyscratch-deployment-1.0.ear
I tried entering the URL manually as well as going to the JMX console to enter the parameters and invoke the operation manually. These solutions appeared to work (The browser displayed a message indicating “the operation succeeded with no return code”) but there was no output on the JBoss console indicating deployment had actually occurred.
I finally tracked down this error to the spaces in the file path. To be complete, I url-encoded the spaces and entered the URL manually, but it still failed. I should have known, Java has always had issues with spaces. Part of the difficulty in solving the problem was that I was confounding it with a similar (but different error):
Error opening connection java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=file:C:\umptyscratch\deploy/target/umptyscratch-deployment-1.0.ear
From the start I actually did suspect that the problem was caused by the spaces, the way I initially tested my theory was by copying my project to a different directory (one without spaces in the path) and try redeploying it. That’s when I started to get the second error message. It wasn’t until I noticed the exception stack on the JBoss console that I really started getting anywhere. Here’s the error message output by JBoss before outputting the stack trace:
ERROR [[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception javax.management.InstanceAlreadyExistsException: jboss.j2ee:service=EARDeployment,url='umptyscratch-deployment-1.0.ear' already registered.
It turns out that JBoss doesn’t allow you to deploy two applications with the same name from a different location. I don’t know how it works, there’s probably a signature that includes the file path or something. I had to go into the JBoss server directory and manually remove all references of the one I wasn’t using. This is probably documented in the JBoss documentation, but I haven’t had the priviledge of reading that cover-to-cover yet. And at any rate, the search engines weren’t really turning up anything useful. But there’s nothing like an undocumented solution to make you better at doing what you do.
Maven 1.0.2 – Can’t Handle HTTP 301:”Moved Permanently”
Posted by: | CommentsI’ve been using Maven 1.0.2 to develop a Flex/Java application at home. I recently started getting errors from Maven like this:
Error retrieving artifact from [http://www.ibiblio.org/maven/flash/jars/mysql-java-connector-5.0.1.jar]: java.io.IOException: Unknown error downloading; status code was: 301
This was in reference to a new dependency jar Maven was trying to download and install. It turns out that the Maven repository has been moved to a new location, and Maven v.1.0.* doesn’t appropriately handle HTTP 301 errors (moved permanently)… basically it doesn’t understand them at all.
Here’s the URL to the new repository: http://mirrors.ibiblio.org/pub/mirrors/maven (used to be http://www.ibiblio.org/maven. It will need to be added to the project.properties file as follows:
maven.repo.remote=http://mirrors.ibiblio.org/pub/mirrors/maven,
http://www.ibiblio.org/maven
Alternately (and simpler) if you’re using a build.properties file, you can add the new repository there.
If you’re using Maven 2, you will probably never read this post because you won’t have this problem.
Final Thoughts – The Labs
Posted by: | CommentsI’d just like to document some of the final thoughts I’ve had about these labs that we’ve done this semester. This is more for the benefit of those taking the class in the future, specifically those who are doing the Amazon EC2 labs.
One thing I did, which has saved me who-knows-how-much time was using a dynamic dns service for my servers. I had one for each of my three major servers (web server, listing server, submit server) which allowed me to hard code my calls during testing. Not only did I not have to refresh as much to get my server, but it also saved me when the submit service load balancer started having problems during the past two (or more?) weeks. Scott Chun has a good description of how to set up your server to register with dyndns.com’s dynamic hostname service. Read about it here.
One thing I would have done differently would be to store those URLs in a config file (elementary 240 stuff) so I’d only have to change it in one place to make the switch from hard-coded to load-balanced.
Something that was mentioned several times in class, and I would still love to see a tutorial on how to do this, was an alternative to frequent image persisting. Especially for minor script changes I didn’t realize I needed until having started the persist process, heaven knows I’ve had more of those than I needed. The solution is to have your server automatically check out the files it needs from a CVS/SVN repository on startup. I’m only an amateur shell scripter, but I assume there are two things the script would need to do. 1) check out the files. 2) make sure they have the correct permissions. Anyway, this would have been a real time saver.
It would have been fun to get a little experience with Pound in the labs. That’s the only thing in the entire process that I don’t feel I could go off and do right now. Sam says it’s pretty simple to figure out, I guess I’ll be finding out in a couple weeks when I’m off on my own to try it.
This class has really been an enjoyable experience. Earlier in the semester when I gave up on Python, I thought I’d feel some remorse at the end for not having stuck with it. Well, I don’t. The architectural concepts the labs have illustrated really do transcend the languages used, and I’m glad I didn’t get so bogged down in the language that I missed the point (that’s the reason for scrapping the EJB labs, right?). One thing I do regret is that Sam isn’t making us use a template for our demonstration for Jeff Barr. Speaking of that, Nathan, you’d have gotten my vote for best design. Did anyone else have a design for consideration?
Lab 5: Finishing Touches
Posted by: | CommentsAfter nearly a month (of scattered work) I’ve finally put the finishing touches on my approval client. If anyone wants to get more experience dealing with asynchonous web applications, I’d recommend Flex. You could experience asynchrony with Ajax, but as someone who’s used both considerably… I just find I have more time for fun when I’m programming in Flex.
Anyway, the link to the online version of my approval client is here: http://wishlist.dusbabek.net (same link as before).
I don’t have any final thoughts to share about this lab, per se. In the future I would like to explore the scalability of Flex applications in a little more depth. Flex apps compile into SWF files, which can get reasonably large depending on the application (several hundred K to a couple megabytes).
A couple thoughts I’ve had on this:
1. Decrease the file size: don’t embed. It’s a common practice to embed all resources necessary (including some images) some of which may not be required immediatly.
2. Decrease the file size: Break into smaller SWFs. Flex makes it possible to load other SWFs at run time. Rather than compile all functionality into a single SWF, it could be broken into smaller functional applications that could be loaded lazily.
3. Reduce bandwidth on data transfer. Flex has no means of accessing a relational database directly, all data comes from either static XML files or web services (using the broad sense of the word). The amount of bandwidth needed could be reduced by using a lighter data format like JSON for RESTful services; using a binary format (like AMF); or by serving data from static XML files where appropriate.
These were just the first couple of more obvious things to occur to me. It’ve got 2 medium to large scale Flex applications I’m working on at the moment, and it’ll be interesting to see what I can come up with.
Lab 5 : PHP and SOAP
Posted by: | CommentsThe only SOAP requests I’ve ever made were made on the .NET platform. They’re not that much of a beast on .NET, but it wasn’t exactly a cake walk either. So I had been bracing myself for the worst trying to implement it in PHP.
I should explain that my lab 5 client connects to a PHP service that in turn makes the SQS requests, etc. I initially wanted to implement an SQS library in Actionscript (and probably will in the future when I’m not pressed by deadlines) but I decided it was too ambitious for the amount of time I wanted to spend on this lab. So alas, a PHP service also handles my SOAP request to WHOIS.
Anyway, I was expecting SOAP on PHP to be a seriously complex affair. Here’s my code that makes the request:
$client = new SOAPClient("http://www.webservicex.net/whois.asmx?WSDL");
$params = array('HostName' => $_GET['url']);
$whois = $client->GetWhoIS($params);
Granted, it would have required about 2 more lines if there wasn’t a URL to the WSDL, but it doesn’t get much simpler than that. I should mention that this requires that PHP SOAP be enabled (uncomment a line in your php.ini if you’re running Windows; recompile from source using ‘enable-soap’ if you’re running Linux). I didn’t have to recompile, thanks once again to Remi Collet (the French guy who has yum rpms for all this stuff, see my previous post).
Well, the SQS library I’m using is pretty old and doesn’t have a means of querying the queue for the number of messages. So, I thought I’d try sending a SOAP message to Amazon to get it. Amazon’s WSDL is a little more complex, and I probably could have gotten it to work if I wanted to play around with the messages for another hour or so. It turned out to be a miserable failure, and I resorted to my old tricks: (file_get_contents()) which worked perfectly. Here’s the code I used, which shows the query string needed to get the number of messages:
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
$qs = "http://queue.amazonaws.com/A3N3IV5XJH079S/processing" .
"?Action=GetQueueAttributes" .
"&Attribute=ApproximateNumberOfMessages" .
"&AWSAccessKeyId=[AMAZON_ACCESS_KEY]" .
"&Version=2007-05-01" .
"&Timestamp=" . urlencode($timestamp) .
"&Signature=" . urlencode(constructSig('GetQueueAttributes' . $timestamp));
$response = file_get_contents($qs);
The constructSig is the same method I listed in a previous post.
Here are a few links that were helpful:
SQS Query and SOAP API
Getting SQS Attributes
SQS WSDL
Lab 5 : Web App to Desktop App using Flex 3
Posted by: | CommentsI’m almost finished with lab 5. On the whole it’s been pretty fun, aside from some of the frustration from minute details that take an hour apiece to hammer out. I had developed most of my application as a web app before the specs came out. Fortunately I was using Flex, so let me show you how easy it was to convert it from a web app to a desktop app.
As a web app, the main page was enclosed in elements like these:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#2C3552" xmlns:local="*">
.
.
.
<mx:Application>
To deploy it as a desktop app, I had to change it to:
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#2C3552" xmlns:local="*">
.
.
.
<mx:WindowedApplication>
and then recompile. And that’s it. And this may appeal to those of you with high design sensibilities– it looks the same on the desktop as it does on the Web. Incidentally, on the web it looks identical on every browser/platform combination (any platform that has a Flash player, that is).

