"Today, President-elect Obama will record the weekly Democratic address not just on radio but also on video -- a first. The address, typically four minutes long, will be turned into a YouTube video and posted on Obama's transition site, Change.gov, once the radio address is made public on Saturday morning."
Friday, November 14, 2008
iObama
"Today, President-elect Obama will record the weekly Democratic address not just on radio but also on video -- a first. The address, typically four minutes long, will be turned into a YouTube video and posted on Obama's transition site, Change.gov, once the radio address is made public on Saturday morning."
Worries
"Stocks adds to losses on economic worries"
Are financial news outlets just reusing the same headlines over and over and over and over and over for months at a time?
Thursday, November 13, 2008
Spider
Dear Jane,
Are you sure this drawing of a spider is the one I sent you? The spider has only seven legs and I do not feel I would have made such an elementary mistake when I drew it.
Regards, David
Hmmm, Bacon...
"Baconnaise"
...Making the world just a little more bacony.
Wednesday, November 12, 2008
Calling a BPEL WSDL From an Object Outside an SA
Next up, calling an existing OpenESB BPEL from a plain Java class that has been included in a Netbeans "Web Application" project and deployed to Glassfish in an "Enterprise Application" project. Firstly, the web service client can be added to the Web Application project by file only, not by URL. Adding the service client by URL fails to retrieve the imported XSDs for some reason. Adding the client by local file works fine and the required service and port classes are generated in the build directory, as normally. So far so good. I can add the call of the web service to any Java class as usual, by dragging the port reference into the editor. However, at runtime, the call fails:
javax.xml.ws.WebServiceException: Unsupported endpoint address:
at com.sun.xml.ws.api.pipe.TransportTubeFactory.create(TransportTubeFactory.java:144)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:112)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
...A quick aside about adding the web service call... One should be able to do this by right-clicking in the editor and selecting "Web Service Client Resources" and "Call Web Service Operation". However this only lists WSDLs in EJB projects. You can cannot select a WSDL that leads to a BPEL in this way, for some reason.
Back to the unsupport endpoint problem, the issue has something to do with the port I'm guessing. I resolved this by editing the generated service class and replacing the file URI for the WSDL with a full URL, port and all. Now more needs to be done - the service class is in the build directory. It is recreated each time, and the edits are lost. So to do all this, you must create a new service class. This is easy.
1) Create a new Java package in the source folder.
2) Create a new (plain) Java class in there, with the same name as your service class.
3) Paste the source of the generated service class into the new class file.
The resulting new service class will not be rebiult with the project and can be edited, to change the WSDL location.
I had to make two other edits in this new class. The last "get port" method, at the bottom, in the generated class is somehow invalid in the newly created class. How it could be valid in one place and not the other is beyond me. It is not used, so I removed it. Secondly, the new service class will need imports for the other generated classes.
The Java class can then use this new service class, with the WSDL as an HTTP URL, to invoke the BPEL.
More Glassfish and Netbeans Fun
{Netbeans Projects}\Project_EA\dist\gfdeploy\Project_SERVLET_war\WEB-INF\lib
Shutting down Glassfish (completely, you may have to use O/S tools to do this) will allow the jar to be deleted and rebuilt.
This is a big problem because it seems that if you do an ordinary build, rather than a clean build, on the EA project the jar file may not be updated. In one case this lead me to get a very strange runtime error claiming that a general Java class used in the EJB project belonging to the given EA assembly, had no constructor of a given form when clearly it did.
com.iwsinc.cms.jobs.PSStatusCheckJob.<init>(I)V
java.lang.NoSuchMethodError: com.iwsinc.cms.jobs.PSStatusCheckJob.<init>(I)V
at com.iwsinc.cms.ejb.CMSTimerEJB.cmsWatchEJBOperation(CMSTimerEJB.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
...What was happening was that the build process was quietly failing to update the EJB part of the EA project - the jar in other words, because it was held open and could be be deleted.This problem, I would guess, only happens on Windows.
Product Version: NetBeans IDE 6.1 (Build 200805300101)
Java: 1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: E:\openesb\.netbeans\openesb
Tuesday, November 11, 2008
Creating a Timer EJB for OpenESB/Glassfish
Here's the tools:
Product Version: NetBeans IDE 6.1 (Build 200805300101)
Java: 1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: E:\openesb\.netbeans\openesb
glassfish-v2-ur2-b04-patch-20080729 1) Create an EJB with a local interface in an EJB project. Call the EJB EJBTimer.2) Create a servlet in a web application project. Call it Watch.
3) create an enterprise application project and add both of the above
4) In the servlet code, right-click and use the wizard to add a reference to the EJB. It will generate this:
@EJB
private EJBTimerBean eJBTimerBean;5) Add to the servlet code an init() lifecycle method, and include there a call to the EJB to start ticking (see the source below).6) Modify the servlet's deployment descriptor to create the servlet on deploy. In Glassfish, it's web.xml editor calls this "Startup Order". Fill in a one. Examine the "load-on-startup" tag in the web.xml, to see what this does.
7) Deploy the enterprise application. The servlet will be created and will start the timer.
Here is the timer EJB:
package com.me.ebj;
import java.util.Date;
import javax.annotation.Resource;
import javax.ejb.Timer;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.TimedObject;
import javax.ejb.TimerHandle;
import javax.ejb.TimerService;
@Stateless
public class EJBTimerBean implements EJBTimerLocal, TimedObject {
private SessionContext sc;
private TimerHandle timerHandle = null;
public void ejbTimeout(javax.ejb.Timer arg0) {
java.util.logging.Logger.getLogger(getClass().getName()).log(
java.util.logging.Level.INFO,
"CMS0000: EJBTimerBean: Tick");
}
public void ejbPostCreate() {
// This does not work:
Date now = new Date();
initializeTimer(now, 30000, "CMS_TIMER");
}
public void initializeTimer(Date firstDate, long timeout, String timerName) {
try {
TimerService ts = sc.getTimerService();
Timer timer = ts.createTimer(firstDate, timeout, timerName);
timerHandle = timer.getHandle();
java.util.logging.Logger.getLogger(getClass().getName()).log(
java.util.logging.Level.INFO,
"Timer started.");
} catch (Exception e) {
e.printStackTrace();
}
}
@Resource
public void setSessionContext(SessionContext ctx) {
sc = ctx;
}
}Be sure the timer includes the setSessionContext() methods, with the @Resource annotation. Also, initializeTimer() must be declared in the bean's interface.Here is the servlet, whose only purpose in life is to start the timer (note that some basic servlet code has been left out, it's not important for the example at hand).
package com.me.servlets;It took me awhile to figure out that to do this (this way), the EJB and the servlet must end up in the same ear file, that the annotation in the servlet for the EJB needs to be the interface, not the bean itself, and that the EJB needs to get its SessionContext using a @Resource annotated method, just as shown above.
import com.iwsinc.cms.ebj.EJBTimerBean;
import com.iwsinc.cms.ebj.EJBTimerLocal;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.ejb.EJB;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Watch extends HttpServlet {
@EJB
private EJBTimerLocal eJBTimerBean;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
// Start the timer
// to-do: MAKE SURE only one timer is started!!
try {
eJBTimerBean.initializeTimer(new Date(), 30000, "CMS_TIMER");
}
catch (Exception e) {
java.util.logging.Logger.getLogger(getClass().getName()).log(
java.util.logging.Level.SEVERE,
"Exception", e);
e.printStackTrace();
}
}
public void contextInitialized(ServletContextEvent sce) {
}
public void contextDestroyed(ServletContextEvent sce) {
try {
// to-do: Stop the timer
} catch (Exception e) {
e.printStackTrace();
}
}
}
On deployment of the web application, an exception is thrown by the EJB. The cause is not known at this time. i found a handful of questions on the various forums asking about this. This exception does not seem to impact the timer in anyway, as far as I can tell.
java.lang.IllegalArgumentException: "timers"
com.sun.enterprise.management.support.OldTypesBase.oldObjectNameToJ2EEType(OldTypesBase.java:153)
com.sun.enterprise.management.support.oldconfig.OldProps.(OldProps.java:187)
com.sun.enterprise.management.support.LoaderOfOldMonitor.oldToNewObjectName(LoaderOfOldMonitor.java:265)
com.sun.enterprise.management.support.LoaderOfOld.syncWithOld(LoaderOfOld.java:415)
com.sun.enterprise.management.support.Loader._sync(Loader.java:548)
com.sun.enterprise.management.support.Loader.sync(Loader.java:522)
com.sun.enterprise.management.support.Loader.handleMBeanRegistered(Loader.java:209)
com.sun.enterprise.management.support.LoaderRegThread.processRegistration(LoaderRegThread.java:204)
com.sun.enterprise.management.support.LoaderRegThread.process(LoaderRegThread.java:253)
com.sun.enterprise.management.support.LoaderRegThread.run(LoaderRegThread.java:154) Monday, November 10, 2008
Tuesday, November 04, 2008
Joe
"In the written report, Officer Bailey cited an ongoing investigation of a Toledo police clerk's alleged improper check of Mr. Wurzelbacher's records in a state database as the reason a warning was issued.
"This unit gave warning because of ongoing investigation of the Toledo Police Department involving Mr. Wurzelbacher and felt issuing a citation could have negative repercussions to the department and the city as a whole," the officer wrote."
FX
"...when CNN’s Wolf Blitzer talks with Candy Crowley from the Obama headquarters in Chicago on Tuesday evening, the correspondent could simultaneously appear in the New York studio—at least as a 3-D hologram. Really.
Although CNN's takes the prize for most extravagant election-night bells and whistles, each network will pack studios with their entire stable of anchors, pundits, analyst and correspondents, while bringing out every gizmo in their arsenals to break down the results—including such primary night favorites as CNN’s “Magic Wall and Fox’s “Bill-board.”
I'll have a map with some push pins! Nah, maybe I'll just skip it...
Jeff Sexton
