Friday, January 15, 2010

Jetspeed-2 and NetBeans 6.8

Well, I have been looking at Open Source portal products that are "easy" to setup and use and yet powerful enough to satisfy an enterprise. I settled on trying Apache Jetspeed-2, since it has licensing that is favorable to a business that might want to use it in a product offering, and it is fully compliant to the Java Portlet Standard 2.0.

Installing the demo version was easy, and it came with a bunch of portlets ready to use. But, I want to be able to create portlets myself and the Java development tool I have been using the past several years is NetBeans.

At first, it seemed as if there would be no support for developing and deploying portlets from NetBeans to Jetspeed-2 or even modifying/building Jetspeed from source. I asked a friend and all he said was "use Eclipse instead!" Which really isn't an option where I'm working these days.

I installed the Generic Portlet plugin and added the Jetspeed-2 server (Tomcat 6 server type) to the Servers list in NetBeans. I created a new Java Web project and chose the Portal Framework, with View only premissions. NetBeans pulled in the Portlet Standard 2.0 libraries along with the Jetspeed-2 libraries and created a portlet source file for me. I thought, "cool, this will be easy.", but the hard part was just beginning. Of course, NetBeans creates an index.jsp file for you, but as I was working along and built the WAR file, I noticed that the portlet.xml file was not continuously updated like the web.xml file does.

After building, I tried to deploy via NetBeans. It works, but it was deployed as a regular web application and not as a portlet for Jetspeed-2. If the server properties for Tomcat allowed you to specify the deployment directory, then NetBeans might be able to deploy the code to the proper place. As it was, I could bring up my code as a web application, but Jetspeed-2 didn't know a thing about it, so it did not show up as an available portlet to add and use.

So for the moment, I have to manually drop the .war file into the /webapps/jetspeed/WEB-INF/deploy/local/ directory in order for my portlet to be usable. I also found that the path to my .jsp files is all messed up because you are deploying your .war file underneath Jetspeed-2, which is itself a web application. So the path I found that worked so nicely and that I was able to specify in my portlet.xml when I deployed dirctly from NetBeans, no longer worked and I kept getting NPE's or path not found errors from Jetspeed. Now that I know the actual path, I have a couple of ways to specify the correct path, but it was such a pain...

Now that I have a basic "Hello World" portlet running, I'll start working on more complicated portlets and plan on posting my experiences with NetBeans and Jetspeed-2. Until then, happy coding!

Friday, September 4, 2009

Modifying Tomcat admin port in xampp control panel

After suffering through several hours of pulling hair and gnashing teeth while trying to figure out how to change the port location for Tomcat, I finally found a solution.

For those of you who work with xampp, the following image should be familiar:




In my installation, I already have a Glassfish server listening on port 8080, so I changed Tomcat to listen on 8082. That works fine, but if I click on the xampp admin button for Tomcat, it sends the browser to the default port (8080) instead of the actual port in use.

I hunted through php.ini files and Googled the heck out of things, but only found references to go to the application's conf/ directory and change the value there. But, alas, xampp control panel knows nothing about these changes. A colleageue at work said he thought he saw a xampp.ini file a long time ago, but it no longer exists, so I thought I would try it, since nothing else in the help, FAQ, or other documentation seems to work.

In the /xampp directory I created a file named xampp.ini and placed the following in it and restarted xampp control panel:


[PORTS]
tomcat = 8082

Then I tried clicking on the Tomcat admin button on xampp control panel, and the browser came up with the correct URL.

Sweet!

oh, yeah, this is on a Windows 2003 Server system in case anyone is curious...

Saturday, August 15, 2009

OpenSSO woes...

We have been using OpenSSO (Fam80b1) in combination with Glasffish and OpenDS v1b008/OpenDSv1.0GA and all has been working fine. Now that we want to upgrade to openSSO 8.0 Enterprise Edition, we have found that all our custom code that works to retrieve user data with a custom schema via both the Sun IDM and our custom IDM are now broken.

The problem lies with the deprecation of AMConfig.properties file, where much vital information is stored and read by OpenSSO on system startup. The API calls that return the information from this file still exist and are not marked as deprecated, and we cannot find alternative API calls to return the same information. The properties we need are com.iplanet.am.directory.host, com.iplanet.am.directory.port, com.sun.identity.authentication.special.users

For now, it appears we cannot upgrade due to the inconsistent deprecation of features + API...

Friday, June 26, 2009

Been to busy...

Been too busy trying to juggle work and an interview schedule that just won't quit... Hopefully, I'll get back on track again later this week.

Friday, May 8, 2009

Amazon.com phone interview

Well, today I had a phone interview for a SDE position at Amazon.com. Unfortunately, I have been putting out fires at work for the past 2 days and really wasn't in a good frame of mind to think about data structures and algorithms and Big O notation. A sample of questions...

Q1. In Java write a function that will scan an array of int for a value that occurs an odd number of times, specifically once, and return the value. Only 1 number in the array will occur an odd number of times, the rest will occur an even number of times. What would be the runtime order of magnitude of this solution?

Q2. Design a set of classes organizing a bank of elevators and to manage and control them.
Use case1: on floor X, a person presses the down button. How do your class designs handle this?
Use case2: a person enters an elevator on 8th floor and presses the button for 2nd floor, but the elevator is still going up. How do your class designs respond to this?

Q3: Given a table that contains company names and revenue columns, with more than one row for each company name. Design a SQL statement that will return only 1 company name and the corresponding total revenue?

Since I wasted too much time on the first question, thinking about what are some elegant ways to solve that problem, but coming up blank - I was still thinking about how to get one of my teams' Dev servers back up on the network and functioning again. I started to come up with a brute-force solution, but we had to move on to other questions. I got through the others fairly well. Of course, after the interview was over and while getting the server to stand up again, I came up with a solution. But by this time, it's an hour too late since the interview was over. Major screw up on my part, but the real world got in the way of preparing for a great opportunity. Amazon will probably never want to talk to me again...

Hopefully, I'll get another chance to speak with them...

Wednesday, April 29, 2009

Starting/stopping Windows services from a script

Ever had a situation where you needed to stop at least one Windows service that also is dependent on other services? I've got one now, where Oracle WCI and BPM Enterprise are running on a box with other more critical services, but eventually, one of the Oracle processes starts running out of control and takes up 100% of CPU and memory. If you can get to the console and eventually login (it take 5 minutes, literally), you see a message box telling you the server has run out of virtual memory.

Normally, we administer the server via remote desktop/terminal server from our desktop or VPN if we happen to be remote. But in this case, the box does not have enough free CPU or memory to even respond to remote connections and someone has to physically go into the server room and shutdown the box (it takes 30 minutes for the box to shutdown) or kill the power (if they don't have a login). Not very good options in any case...

So, I poked around the Microsoft site and thought, "hey, I've created Windows services before with sc.exe, I should be able to stop them from a command window." A great idea, until you try sc.exe to stop a service that depends on other services. You get the dreaded


[SC] ControlService FAILED 1051:

A stop control has been sent to a service that other running services are dependent on.


error message. Worst of all, you won't even see the error if you have written this in a batch script - it'll just fly on by.

I thought, ok, so I have to specify each service in reverse order of dependency in my script. There are 7 services to stop, so I had a line calling sc.exe for each one.


sc.exe stop Tomcat6
sc.exe stop ptautomationservices
sc.exe stop "Ldap server"
sc.exe stop wsserver
sc.exe stop OracleBPMWebApplications
sc.exe stop SQLBrowser
sc.exe stop MSSQL$SQLEXPRESS


Well, only the first service stopped and none of the others. Eventually I found that sc.exe returns immediately, and any dependent services probably haven't even begun to stop, so they fail the stop command. So we have to wait until each service completes stopping.

After Googling around for a while, I eventually came upon sites that pointed out that you have to prepend with "start" like velocityreviews or tek-tips.com suggests:

start /wait sc \\server_name stop service_name1
start /wait sc \\server_name stop service_name2

Great! every call to sc.exe will wait until the command finishes stopping the service befre executing the next one. So I happily went on to modify my script to:


start /wait sc.exe stop Tomcat6
start /wait sc.exe stop ptautomationservices
start /wait sc.exe stop "Ldap server"
start /wait sc.exe stop wsserver
start /wait sc.exe stop OracleBPMWebApplications
start /wait sc.exe stop SQLBrowser
start /wait sc.exe stop MSSQL$SQLEXPRESS


and then executed the batch script, expecting all the services to shutdown gracefully in order.

Wrong! On Windows 2003 Server, it doesn't wait. :-( WTF!!

Again, Tomcat stopped and sometimes the automation services, but I didn't see anything on the screen appear to wait or pause. The script still just flies by. So I Googled around a bunch more... There must be a solution and I can't be the only one trying to do something like this. I found similar issues with the same answers, but no resolution. One suggested, write a WMI script, another suggested write a VB program. What? Just to shutdown services? There has to be a better way.

Then I thought, you can use net \\servername stop servicename from the command line to stop a service on another box over the network, what happens when I do it on the same box? So I tried:

c:\net stop MSSQL$SQLEXPRESS

in a DOS window, and waited...


The following services are dependent on the SQL Server (SQLEXPRESS) service.
Stopping the SQL Server (SQLEXPRESS) service will also stop these services.

Apache Tomcat
BEA ALI Automation Service
BEA ALI LDAP Directory
BEA ALI API Service
Oracle BPM Web Applications
SQL Server Browser

Do you want to continue this operation? (Y/N) [N]:


hmm.... at least it asks me if I really want to do it, so I enter "Y" and cross my fingers:

The Apache Tomcat service was stopped successfully.

The BEA ALI Automation Service service is stopping.......
The BEA ALI Automation Service service was stopped successfully.

The BEA ALI LDAP Directory service is stopping........
The BEA ALI LDAP Directory service was stopped successfully.

The BEA ALI API Service service is stopping.......
The BEA ALI API Service service was stopped successfully.

The Oracle BPM Web Applications service is stopping.......
The Oracle BPM Web Applications service was stopped successfully.

The SQL Server Browser service is stopping.
The SQL Server Browser service was stopped successfully.

The SQL Server (SQLEXPRESS) service is stopping.
The SQL Server (SQLEXPRESS) service was stopped successfully.


it actually works! But what if I don't want the user to have a choice and just force the "y" answer? In my case, the machine is usually not responsive enough for the user to sit around for minutes before being prompted for a "Y" or "N", it just has to work. Is that possible inside a batch script? I still haven't found the answer to that yet, but this is a start...

Update... ( Wed 29 Apr 2009 10:09:20 PM PDT )
to force net stop to not prompt for user input you append /YES, e.g.:


c:\net stop MSSQL$SQLEXPRESS /YES


But, I still have the problem if the server is too busy, it may not be able to keep track of the dependent services to shutdown or the stop command may time out before the service even receives the event. So, I'm probably back to sending each service the shutdown signal:

net stop Tomcat6 /YES
net stop ptautomationservices /YES
net stop "Ldap server" /YES
net stop wsserver /YES
net stop OracleBPMWebApplications /YES
net stop SQLBrowser /YES
net stop MSSQL$SQLEXPRESS /YES

at least my user will be able to see the progress (or lack thereof) while the server attempts to stand itself back up.

Tuesday, April 21, 2009

Flying a dream

Wow, sounds like the Boeing 787 Dreamliner might actually fly before the end of the month! Finally, some great news after all the production delays.