Marco's Corner

Just another Software Developer's musings

Browsing Posts published by mw46d

My Adventure in Component Land

9 comments

I found a post on the Creator forum asking how to integrate a embedded Windows Media Player into a Creator project.

So I thought, that would be a good time to try and write some custom components.

You could add some elements as static HTML but then the JSF framework would not know anything about it and you would not be able to to change the parameter programmatically from the application. So that’s not a good idea.

Edwin has kind of a tutorial on how to write a component library at his wiki page.  So I took some time and played with it.

That’s a screen shot of the result;-)

I would not try to put both, an embedded Windows Media Player and a Real Player onto the same page;-) That might get a bit noisy.

Here is a link to my components. They are not fully tested and might not be complete, but I hope they can work as a starting point for somebody;-)  The download contains all the sources and a prebuild complib in the dist directory.  Just import that complib into a Creator 2 EA with the Component Library Manager and you should be ready to play with it.

I’m normally working more on the backend of Creator, so maybe on Monday our component guys will tell me what I did wrong;-)  But I think the results are not that bad for five hours play time;-) Especially given that I normally don’t even work on Windows;-)

Have fun & a good turkey ;-)
— Marco

I'm still here;-)

No comments

but I was bussy with a couple of bug fixes for our upcoming release.

I hope I’ll find a bit more time now that most of the issues are resolved.

BTW: Did you see that we released an EA2?

Thanks,
— Marco

Catch the Sun When You Can

2 comments

And this time I don’t mean Sun Microsystems. Our photovoltaic system was finally completed today! It was a long wait.

While browsing the news stands at our local book store in March, I came across a magazine called Home Power. It looked interesting and since I try to think about our environment once in a while, I took the magazine home.

We didn’t use that much electricity to begin with, about 5500 kWh/year. We were in the baseline price band for eight month of the year. Between April 2004 and March 2005, we paid about $ 645 on electricity. But California has currently some good incentives for home owners interested in renewable energy systems. There is a $ 2.80/installed Watt rebate and a 7.5% tax credit (after rebate).

I looked at a couple of different formulas and decided that a 2.5 kW PV system might make sense. I found an installer in Acro Electric out of Oakdale, CA. They agreed that a 2.7 kW system would make sense and would also fit on the roof.

In mid April Acro filed the application for the rebate with the California Energy Commission. And that’s when the long wait started:-(

In mid June I got a letter from the CEC that my rebate is approved. So I talked to Acro again and we schedule the installation for mid July. (They needed to get the panels etc.)

On July, the 15th, I got another letter from the CEC telling me that the rebate is denied this time because there is a form missing. This was two days before our scheduled installation date. I don’t know why the CEC first approved and then denied this application, but somehow this looks strange. Why did they need two month to count and check the application and then an extra month to realize that a form is missing? So I stopped the installation and Arco filed the application again.

At the beginning of September, we got the next letter from the CEC, again an approval notice.

The installation started last week, and today, the system was up and running. The three people from Arco did a very good job here;-)

Once we get the rebate and the tax credit, our system will cost us around $ 15,500. It will produce an estimated 3700 kWh/year. That should save us at least $ 440, or after the switch to time-of-use metering around $ 590 on the electricity bill. Those are todays prices with the next PG&E rate increase already decided. So our ROI will be somewhere between 2.8 and 3.7 percent from year one. Some people try to throw the increase in house value into the mix and that would boost the ROI a lot (like double), but we don’t currently think about selling our home;-) But even so, it’s better than some stocks and it will only get better over time.

And the green fact at last: Our system should help to avoid an estimated 6400 pounds of CO2 per year. That’s the equivalent of 20,000 miles with a 20 mpg car.

Sorry, today wasn’t Creator related.

We found out that the Sun Java Enterprise System WebServer 6.1 has a upload limit of 10 MByte for web applications. Apparently we were very close to that limit for some time without knowing about it. But when you add a WebService or EJB client to a Creator application, all the support jar files will bring the size over that limit.

The solution is to reconfigure the WebServer’s admin application to allow bigger uploads. Simply do the following when you see the problem:

  • Stop the WebServer admin server.

  • Back the <WS_HOME>/bin/https/webapps/admin-app/WEB-INF/web.xml up!

  • Add the following init-param to the webappdeploy servlet.

    $ diff -uwb web.xml.orig web.xml
    --- web.xml.orig        2003-08-05 01:47:00.000000000 -0700
    +++ web.xml     2005-09-14 11:40:46.000000000 -0700
    @@ -151,6 +151,10 @@
    <servlet>
    <servlet-name> webappdeploy </servlet-name>
    <servlet-class> com.sun.web.admin.servlets.DeployServlet </servlet-class>
    +    <init-param>
    +      <param-name>maxUploadSize</param-name>
    +      <param-value>20000000</param-value>
    +    </init-param>
    </servlet>
    <servlet>
    
  • Start the WebServer admin server and all the target servers.

Thanks to M. Kapur for this information.

I hope this helps a couple of people.

Not too much;-) At least not much the average user will see.

We added Remote Deployment support for the Sun Java System Portal Server 6.3 on top of the Application Server 8.1. If you happen to want to play with that on Solaris or Linux. Remote deployment is not really a good description, because the Portal Server and Creator have to be on the same machine.

We tested it with the Java Enterprise System 3 and the upcomming JES 4. The newer version has a couple of problems fixed so I would suggest to wait for that if you can.

But there is one big problem. The Portal Server was not designed to interact well with tools like Creator. The only way we found to deploy to it, is to run a script as the user under which the Portal Server was originally installed (usually root).

There are two ways to handle that problem:

  • Use the sudo command to run the deploy-script. That’s the solution I would prefer. But it needs some preparation. More about that below.

  • Run Creator completely as root (root seems to be the default user for Java Enterprise System/Portal Server installs). But Creator was not really intended or tested for that.

Setting up the sudo environment

The sudo setup has to be done by the admin/root of your system! So, please switch to root before you try to do any of the following steps.

Sudo is installed by default on most Linux systems. Or if not, you can usually find it on your installation media.

Solaris does not have sudo out-of-the-box. You can build it yourself (Find the sources here!) or you can find a prebuilt package on the Companion CD (Solaris Freeware download).

The Creator EA2 will look in /usr/bin and /bin for sudo (Sorry, I realized too late that there is the Sun FreeWare package which installs the binary into /opt/sfw/bin. That path is already added for the next version of our sources.), so please make sure, the command is found there (ln -s might be your friend;-)

Use the visudo command to add a line to the sudoers file. It should look like:

<creator_user> ALL = NOPASSWD: <creator_home>/rave2.0/bin/ps6-deploy.sh

<creator_user> should be your normal user and <creator_home> the directory, where this user installed Creator.

That line in the sudoers file will allow the user to run one shell script as root without requiring a password. I suggest that you look at the script to make sure, we did not miss anything bad!

If you don’t add this line and Creator finds the sudo command, Creator will try to use sudo anyhow and that would ask for a password on the terminal where you started Creator, if you started Creator in a terminal! I don’t know what sudowould do when it was not run in a tty!

Deploying to a Portal Server

After sudois set up (or if you are running as root), simply add a Portal Server to the Remote Servers node in the Server Navigator.

Develop and test your portlet as you normally would and in the end, use the Deploy to Remote Server context action and select the added Portal Server. That should do it.

Ok, again: If you want to play with the Portal Server, feel free. But this was not extensively tested for EA2!

Have fun;-)

Creator 2 EA WebApps and Oracle

1 comment

Creator uses a lot of features in the JDBC 3.0 specification to create a good design time experience. For instance it uses table metadata to prepopulate the columns in the table component. But not all JDBC drivers support everything we would need and especially the Oracle JDBC drivers don’t give us the metadata when we need them.

That’s normally not a problem because Creator comes with a set of JDBC drivers, which will be used at design time and for the internal deployments. But those drivers are licensed only with Creator or with the Sun Java Enterprise System’s Application or Web Server’s. So if you want to deploy the application to a different container, you’ll have to find JDBC driver’s.

You don’t have to use the same drivers for the development and deployment. So it’s ok, to use Creator’s Oracle drivers at design time and Oracle’s set for the deployment. You could even use a completely different DB as long as the table layout etc. is the same;-)

I (or our SQA) tested the following drivers with a Oracle 9i database:

  • The Oracle JDBC drivers version 10.2.0.1.0 against a SJS Application Server PE 8.1 and Tomcat 5.5.9. They work fine but need a bit more preparation for updates. Try the following steps if you see

    java.sql.SQLException: attempt to update a row that has been updated or deleted by another user
    

    in the server’s log from the commitChanges() call:

    • After you’ve dropped your DataSource onto the project, go to the SessionBean source of that project and expand it’s constructor.

    • Add something like to following code after the Creator inserted initialization code:

      try {
      RowSet.setColumnTableNames(new String[]
      { ", ... });
      } catch(Exception e) {
      throw e instanceof FacesException ?
      (FacesException) e :
      new FacesException(e);
      }
      

    That should help for the update problem. Please let us know here or better in the Creator forum, if you still have problems.

  • The JDBC drivers included with the BEA WebLogic 8.1.4. They work similar to the Oracle drivers above and you might also need the little extra code.

  • The Oranox drivers from i-net software. I tested them in my Tomcat 5.5.9 installation. They did not seem to need the extra code for the DB updates.

I configured Tomcat in it’s global server.xml. I don’t know if that’s the best way, but it was certainly the easiest way. It looked like:

<!--
-->

Of cource, Oracle is only one database but I believe the general idea of possibly using different JDBC drivers will work for others as well.

This came up in the forum over the last week.

The easiest way to get access to native code from a Creator application is when that code can be handled as a global resource similar to a JDBC driver jar.

I created a little test case today (on Linux) and that seemed to work after the following steps:

  • Created a libmarco.so and libmarco.jar, The Java code does a

    static { System.loadLibrary("marco"); }
  • Copied both into /SunAppServer8/lib to make the appserver happy. This might be a different directory for other containers!

  • For Creator set the LD_LIBRARY_PATH to the directory where the libmarco.so is. (Is this PATH for Windows?)

  • For the project, add the libmarco.jar as library for the design time only! I believe that can somehow be added to a customized template if it’s needed in more than one project.

  • Use the library (mine just returns a String from the native side;-) and deploy the application.

That worked for me;-)

Trying to handle a native library as part of a WebApplication is probably a lot harder. Things to watch out for would at least include:

  • The Java wrapper code has to find the native library relative to it’s classloader.

  • The security manager of the container will probably have to be changed to allow loading of native libraries from applications.

  • The initialization code on the native side and the Java side have to be able to handle `redeployments’.

  • What would the container do when an undeploy attempt tries to delete a loaded native library?

So overall I don’t think that would be a good idea.

I hope this helps a bit;-)

Ok, first off: We don’t claim to support FC4 but since Creator and it’s components are mostly Java, it should still work, right? ;-) I don’t know if my SuSE Linux systems are officially supported either. But I know that people try different flavors of Linux until they find one they like. So why not help them a bit?

The solution is a bit long, because FC4 doesn’t really like the J2SE 1.4, so a couple of steps normally done at the end of the install, have to be done by hand.

  1. Make sure, you have the following packages installed. Otherwise the installer will not even start.

    • xorg-x11-deprecated-libs
    • compat-libstdc++
  2. Install Creator 2ea. That will complain, that it can’t start the AppServer etc. That’s ok for now.

  3. Add the -Djava.net.preferIPv4Stack=true option to the following files:

    • <CREATOR_HOME>/SunAppServer8/pointbase/tools/serveroption/startserver.sh – last line
    • <CREATOR_HOME>/SunAppServer8/bin/asadmin – last line
    • <CREATOR_HOME>/SunAppServer8/domains/creator/config/domain.xml – As a new <jvm-options/> element
    • <CREATOR_HOME>/SunAppServer8/imq/bin/imqbrokerd – to the _jvm_args variable
    • <CREATOR_HOME>/rave2.0/startup/bin/run-sql-bundled.sh – last line
    • <CREATOR_HOME>/etc/netbeans.conf – to the netbeans_default_options with the -J prefix!!
  4. Populate the examples etc:

    • Go to <CREATOR_HOME>/bin
    • run ./pe-start.sh
    • run ./db-start.sh
    • run ./create-travel-db.sh
    • run ./deploy-ejbs.sh
    • run ./deplo-ws.sh
  5. Finally, run ./creator and enjoy!

I hope that helps a bit.

Update for Creator 2 Final (Wed Jan 25 11:15:31 PST 2006):

We switched to JSE 5.0 for Creator 2 EA2 and Final. So all the hand editing is not needed any longer!

Have fun.
– Marco

The First Entry

4 comments

Why do we need another blog? I don’t know. I prefer not to repeat stuff said somewhere else before.

But I answer questions in different places and for different people all day long. And often I come across the same or similar problems over and over again. I hope this blog can serve me as a place to remember and share the solutions we find. I hope those answers might be useful for other people as well.

I’m yet another engineer in Sun’s Java Studio Creator team. I’m mostly working in the deployment area. So I will be happy when our users can deploy their web applications simply by hitting the “Green Arrow” without thinking about how all the configuration will be done on the deployment server.

But in the area of application servers/web containers there are sometimes a lot of problems. Different containers behave differently and we don’t claim to support everything out of the box. But maybe I can share the things I’ve tried (and will try) and that can help others.

OK, if somebody reads this, have a good weekend;-) I’ll try to play with a theme for this page now.