Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Archives

Archives / 2004
  • [Java] jcifs problem fixed in 1.1.5

    I got a message from Mike of the jcifs team that the problem with ArrayIndexOutOfBoundsException should be fixed in version 1.1.5. From http://jcifs.samba.org/:

    jcifs-1.1.5 released / ArrayIndexOutOfBoundsException
    posted by Santa, Dec 17, 2004
    It was discovered that an ArrayIndexOutOfBoundsException could occur if the list of domain controllers returned by NbtAddress.getAllByName was shorter than the list returned in the previous call (possibly because the WINS query timed out and switched to an alternate WINS server). All NTLM HTTP Authentication Filter users should upgrade to prevent this error. Also, the value of jcifs.netbios.cachePolicy set by the NTLM HTTP Filter if it is not specified has been doubled to 20 minutes. Finally, some log levels have been increased such that running with jcifs.util.loglevel = 3 temporarily is actually reasonable in a production environment (must use loglevel > 3 to see individual SMB messages and loglevel > 5 to get hexdumps).

    Will test the new version in January I think.

  • [Java] Crash in the jcifs 1.1.3 version

    UPDATE: I got a message from Mike of the jcifs team that the problem with ArrayIndexOutOfBoundsException should be fixed in version 1.1.5.

    I though I would just warn users of the jcifs 1.1.3 and maybe also 1.1.4 package.

    We got a pretty serious crash in our portal application this morning. We released a new version of the portal utilizing jcifs version 1.1.3 for NTML authentication. When we reached a higher number of concurrent users (perhaps some 50+ sessions) we got internal server error:

    Error 500--Internal Server Error
    java.lang.ArrayIndexOutOfBoundsException: 25
    at jcifs.smb.SmbSession.getChallengeForDomain(SmbSession.java:94)
    at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:123)
    at weblogic.servlet.internal.FilterChainImpl.doFilter
    (FilterChainImpl.java:27)
    at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run
    (WebAppServletContext.java:6354)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs
    (AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs
    (SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet
    (WebAppServletContext.java:3635)
    at weblogic.servlet.internal.ServletRequestImpl.execute
    (ServletRequestImpl.java:2585)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

    We had to go back to an older version of jcifs now.

  • [Java] Cookies in VAP

    I found out a few more things about using cookies in the VAP portal. I blogged earlier about this, but I found a way to set cookies from the grid-file of the portal. It's not possible setting cookies through the response.addCookie() method, but since the grid also controls the <HEAD> section of the HTML page, use the <META> tag:

    <meta http-equiv="set-cookie" content="cookiename=cookievalue; path=/">

    This works just fine, but if you want to grab the cookies from a JSR 168 portlet, you must do that from a JSP page in the portlet applications. To write out all cookies you can see from the portlet:

    <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

    <portlet:defineObjects/>

     

    Hey, these are my cookies:

    <p>

    <%

       Cookie[] cookies = request.getCookies();

       for(int i=0; i<cookies.length; i++)

       {

          Cookie cookie = cookies[i];

    %>

     name=<%=cookie.getName()%>,

     value=<%=cookie.getValue()%><br>

    <%

       }

    %>

    I've not found any way to do it from within the portlet class. Nor have I found a way to set a cookie from a portlet.

    There is another way to send "parameters" to a JSR 168 portlet from a link or a button or a form in the "portal wireframe". For example from a style file. I'll write about that later, need to run now.

  • [Interop] How to Apply the Basic Profile (Web Service practices)

    Got this URL on a Microsoft seminar. Seems to contain some pretty good recommendations and best practices. Especially the chapter about "How to Apply the Basic Profile":

    This chapter details some best practice recommendations. These recommendations explain how to use Microsoft® Visual Studio® .NET to create Web services and Web service clients that conform to the Basic Profile. Some recommendations are general guidelines while others apply to particular directives in the Basic Profile. If a recommendation does apply to particular directives, their numbers are listed in square brackets after the recommendation (for example, [R1120]).

    The whole thingy is available as a pdf file too.

  • MVC in ASP.NET

    I agree with Eric that the way the Model-View-Controller (MVC) pattern is described at the .NET architecture center is not really spot-on. I've always looked at the (typed) DataSets as the model.

    Not that it matters much but it's fun to discuss common patterns like this :)

  • Unable to load DLL (oci.dll)

    It's been written in several places, but lots of people still seem to get this error when deploying ASP.NET apps that use Oracle on win2k3. It's all about permission to the oracle client directories. Make sure Everyone or the ASPNET account got read and execute access to the oracle client directories, especially the bin dir and where you keep your tnsnames.ora file.

    You may have to reboot the server to make it work properly. Sometimes it works straight off with a restart of the web app, but I've had to reboot the server once to make it work.

    If you add the rights to the top "oracle" or "ora92" directory or similar, make sure the rights gets applied to the lower directories. Windows 2003 can be a bit tricky with that.

  • "What are the best practices for J2EE?"

    I'm reading the comments-battle between IBM and Microsoft regarding the IBM WebSphere/J2EE versus Microsoft .NET "Productivity, Performance, Reliability and Manageability Analysis" performed by The Middleware Company not long ago. I have long experience from both large and small J2EE and .NET projects, and some of the comments from Microsoft are quite funny and I must say spot on. Like this one:

    IBM comment: We believe that if J2EE development best practices had been used, the developer productivity would have exceeded that of Visual Studio.NET. The performance and manageability of the WebSphere J2EE application also would have exceeded the published numbers.

    Microsoft comment: The tricky question here is what are the best practices for J2EE? In several cases, the  WebSphere team was using best practices documented by Sun, and yet IBM claims that they were not best practices. This confusion is typical in the J2EE programming model, and is the source of a programmer productivity tax. One thing these studies have shown over and over again is that with J2EE, often times the huge number of architectural choices, with no clear guidance on the tradeoffs between them, leads to failed implementations and loss of productivity. This study and IBM’s response proves that even the J2EE vendors themselves do not agree on how to build a J2EE application. for example, use EJBs or no EJBs? Use stateless session beans or entity beans? Use JDO vs. entity beans? Use POJOs with embedded JDBC? Use a straight servlet architecture instead? Use a third party framework (eg. Struts) or not? The choices are complicated, and many customers find out late in the game they have made the wrong choice. A choice that  works well in one application server, may not work well in another.

  • Using the OracleHelper class

    Last week I moved some Data Access Layer code from MSSQL to Oracle and I started out downloading the Oracle provider for .NET from OTN. I thought that OracleHelper would work well with the provider from Oracle, but it didn't. At least not the provider for Oracle 9.2.

    So I went with the System.Data.OracleClient namespace instead and it works like a charm.

    The OracleHelper  that looks and works similar to the SqlHelper 2.0 class is available in the Nile 3.0 sample project from Microsoft.

  • [Java] Things I learn while I dig into JSR 168

    The portlet API spec (JSR 168) is a piece of good work, but once you want to do something out of the ordinary with a portlet, it feels a bit...limited. Perhaps it depends on what portal engine you're using, but I'd like to share some stuff I've noticed with session variables.

    A portlet sitting in one page needs to know on what portal page it is used - it needs to know the name of the portal page or the name of the navigation item / menu item the user clicked so that the portlet may show dynamic content based on that. If this is possible, I could use the same portlet instance on several portal pages.

    I know, maybe portlets shouldn't be aware of where they are used, be it a mobile phone, digital TV-box or in a java portal, but I sure would like to get some more information out of the portal context.

    My first thought was - the session object. I can extend the portal navigation or the portal frame (which is just a JSP page) and add code to it that sets the name of the current page or the menu item the user clicked in a session variable. Problem is that it seems impossible for a JSR 168 portlet to get to the Session object of the portal. Since the portal and the portlet are two separate web applications, this is maybe as it should be, but even so...

    Then I had a quick look at the portal context object to see if I could add a property to the context from the portal framework, then read it from the portlet, but it seems impossible without changing some of the portal code that I'm not sure I want to (or can) do.

    So, final option seems to be to store the name of the selected portal page in the database, using the username as key, then read it from the database in the portlet. Not the most effective solution, but I can't find any other way to do this.

  • ASP.ASP - good at generating a dynamic RSS feed

    I did a few tests some weeks ago and coded some base classes and an HttpHander that generates an RSS feed depending on the URI of the get request. I ended up with an RssHandler that does:

    1) listens on get requests for *.rss
    2) parses the URI to see what kind of feed the requester wants to have (news.rss, 123.rss, whatever.rss)
    3) gets the requested data from different data sources and builds up a rss object generated with the XSD Object Generator
    4) Serializes the RSS object back to the user on the Response-stream.

    Using .NET to do this is really a walk in the park. Some of the code looks like this:

    public class RssHandler : IHttpHandler

    {

               public void ProcessRequest(HttpContext context)

               {

                          HttpRequest Request = context.Request;

                          HttpResponse Response = context.Response;

     

                          //Gets som info about the requested data

                          string newsType = GetNewsType(Request);

     

                          //Build up the RSS object – consider caching

                          rss rssData = GetRss(newsType);

     

                          //set response content type to text/xml

                          Response.ContentType = "text/xml";

     

                          //Add namespace for my extension to the RSS

                          XmlSerializerNamespaces ns =

                              new XmlSerializerNamespaces();

                          ns.Add("ext", "http://company.com/myRssExtension");

     

                          //serialize via response stream back to browser

                          XmlSerializer serializer =

                                     new XmlSerializer(typeof(rss));

                          serializer.Serialize(Response.OutputStream, rssData, ns);

               }

     

               private static rss GetRss(String newsType)

               {

                          rss rssData = new rss();

                          rssData.version = "2.0";

     

                          //Add other stuff to rss object here

                          //things like author, all the items etc...

     

                          return rssData;

               }

    }

    The rss object is automatically created from a sample rss XML file and a schema, therefore it is serialized into correct RSS XML. I modified the generated RSS types to support a few extensions I wanted to have, with their own namespace. To do this, add a Namespace="someNamespace" to the XmlElement attribute for each element that should have it.

  • XSD Object Generator

    Found this tool on MS Downloads some time back, used to generate sample C# & VB classes from a XSD schema.

    The Sample Code Generator (XSDObjectGen) tool takes an XSD schema as input and generates sample code showing how to mark up C# and VB.Net classes so that when serialized with the XML serializer, the resulting XML will be valid according to the original schema.

    If Visual Studio .NET is present, will also install a new XSD project type in the C# and VB.NET project types.

    XSD Object Generator

     It seems to work a bit better than the XSD tool that ships with VS.NET.

  • Anyone looked at the OWL standard from W3C?

    I'm having a taxonomy/ontology discussion in the project I'm involved with. I was suggesting we build our own XML structure and someone suggested to have a look at OWL.

    To me it looks like OWL has extended RDF into something very complex, and it would probably take quite a while just to define all the OWL "classes" we would need. I'd like to know if anyone has had a look at OWL to see if it's useful. What we need to describe are primarily things like organisation, location and similar items.

  • Selecting the tools before you know what your needs are

    (blowing off some steam here)

    Someone blogged earlier about selecting tools and platforms before you're sure about what your needs are. Looks like I'm going to be affected by that now. I'm one of the responsible architects for implementing a java based portal that must integrate with a document management system and a search system that knows nothing about each other, has no standard ways of plugging into each other and no one seems to have done this before. Yay! Besides, one of the requirements are to have automatic and seamless login for the windows users into the portal, which, as I said, is based on Java...

    We fixed the automatic login requirement by using JCIFS open source stuff from samba, which implements the CIFS/SMB protocol, but IMHO it's sort of a hacky way of doing it. I'm looking at replacing that part with some 3rd party access management system though... For large enterprise sized portals I prefer using a supported way of doing access, which *is* a pretty important part. No access - no portal, right?

    Well, only thing to do is just smile and dig into each product and make them talk to each other somehow. It will take much longer to implement and it won't be a standard way of integrating portals with content and search, that's for sure.

    Some people complains about the risk of "getting stuck into proprietary Microsoft products", but personally I prefer that to getting stuck into a much smaller product that once sprung up from some open source portal framework initiative and now has evolved into a monster that needs a gazillion of bytes just to wake up and start chewing request! During the time it grew from baby monster to a huge monster the owner of the pet changed a number of times and the price went from zero buckazoids to a price relative to the amount of memory needed to get it running...

    At least I got the power (in my dreams) to select the platform for building the Web Service layer we will need to integrate with other systems. I'll certainly raise my hand for .NET Web Services and use WSE 2.0 (or what there will be in ASP.NET 2.0) for security. I'll see how far AXIS and WSS4J has come...

    I need to say though, that I don't mind being involved in this project because even though that it could have been easier with other products, it's pretty fun to try to solve problems with integration, security, where to store content and how to search for it :)

    (I feel much better now, thanks)

  • Spent a day of WSE 2.0 coding at Microsoft Sweden

    Johan Lindfors, who is a Developer Evangelist at the Swedish Microsoft office, came up with the good idea of inviting interested people to a full day of WSE 2.0 coding. Some of us brought our own laptops and Johan had prepared DVD discs with VPC images of Windows XP, VS.NET and WSE 2.0 and some WSE labs from Teched 2004. Really smooth! In 20 minutes I had everything I needed to get going and a bunch of really good people to talk to and discuss stuff.

    We looked at Messaging with SoapReceiver and SoapSender and also using SoapService and SoapClient and running SOAP over TCP. Then we had a look at Security and Policy, digging into security tokens, roles, signing and stuff like that.

    I had a nice day indeed :)

  • [.NET 2.0] Adding Web Parts programmatically (part 2)

    I got a tip from Mike Harder on the ASP.NET Team to derive from CatalogPart and do my own catalog. So I tried that and it works pretty nice. I'd like to share my experience like this. Note that I'm a complete newbie when it comes to WebParts and the 2.0 documentation in this area is sort of under construction it seems :)

    Anyway, first create a simple ASPX page with the basic stuff needed (I won't go into details of the manager and such):

    <%@ Page Language="C#" CompileWith="MyCatalog.aspx.cs" ClassName="MyCatalog" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

        <title>Untitled Page</title>

    </head>

    <body>

        <form id="form1" runat="server">

            <asp:WebPartManager ID="WebPartManager1" Runat="server" OnDisplayModeChanged="WebPartManager1_DisplayModeChanged">

            </asp:WebPartManager>

            <asp:WebPartPageMenu ID="WebPartPageMenu1" Runat="server" Text="Display Mode" Mode="Menu">

                <HoverStyle BorderWidth="1" />

                <MenuStyle BorderWidth="1" />

                <BrowseModeVerb Text="Browse" />

                <DesignModeVerb Text="Design" />

                <EditModeVerb Text="Edit" />

                <CatalogModeVerb Text="Catalog" />

            </asp:WebPartPageMenu>

            <br />

            <h1>

                Web Parts Testing Page</h1>

            <br />

            <table cellspacing="0" cellpadding="0" border="0">

                <tr>

                    <td valign="top">

                        <asp:WebPartZone ID="WebPartZone1" Runat="server" DragHighlightColor="244, 198, 96"

                            HeaderText="My Zone" HeaderStyle-Font-Bold="true">

                            <PartTitleStyle ForeColor="#666644"></PartTitleStyle>

                            <ZoneTemplate>

                            </ZoneTemplate>

                            <PartStyle BorderWidth="0px" BackColor="Yellow"></PartStyle>

                        </asp:WebPartZone>

                    </td>

                    <td valign="top">

                        <asp:EditorZone ID="EditorZone1" Runat="server">

                            <ZoneTemplate>

                                <asp:AppearanceEditorPart Runat="server" ID="AppearanceEditorPart1" />

                                <asp:LayoutEditorPart Runat="server" ID="LayoutEditorPart1" />

                            </ZoneTemplate>

                        </asp:EditorZone>

                        <asp:CatalogZone ID="CatalogZone1" Runat="server" HeaderText="Add Web Parts">

                        </asp:CatalogZone>

                    </td>

                </tr>

            </table>

        </form>

    </body>

    </html>

     

    It's very simple, and has only one WebPartZone in it. The code behind for the ASPX page looks like this:

    using System;

    using System.Web.UI.WebControls.WebParts;

     

    public partial class MyCatalog

    {

               void Page_Load(object sender, EventArgs e)

               {

                          //if we're in catalog mode, show our special catalog

                          if (WebPartManager1.DisplayMode.Name == "Catalog")

                          {

                                     AddMyCatalog();

                          }

               }

     

               /// <summary>

               /// Code to add our own catalog to the catalog zone

               /// </summary>

               private void AddMyCatalog()

               {

                          MyCatalogPart catalogPart = new MyCatalogPart();

                          catalogPart.ID = "mycatalog";

                          catalogPart.Title = "My Catalog";

     

                          CatalogZone1.CatalogParts.Add(catalogPart);

               }

     

               void WebPartManager1_DisplayModeChanged(object sender, WebPartDisplayModeEventArgs e)

               {

                          //if the user has changed display mode to catalog, add it to the catalog zone

                          if (WebPartManager1.DisplayMode.Name == "Catalog")

                          {

                                     AddMyCatalog();

                          }

     

               }

    }

    And finally, the implementation of MyCatalogPart. It is derived from CatalogPart and must implement GetAvailableWebPartDescriptions() and GetWebPart()

    using System;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Collections;

     

    /// <summary>

    /// Test implementation of my own catalog part, which displays a dynamic list

    /// of web part that I can get from a database, xml or by perhaps looking for

    /// web parts assemblies on disk.

    /// </summary>

    public class MyCatalogPart : CatalogPart

    {

     

               /// <summary>

               /// Returns a collection of available web parts in my catalog

               /// </summary>

               /// <returns></returns>

               public override WebPartDescriptionCollection GetAvailableWebPartDescriptions()

               {

                          //normally get a list of web parts dynamically from XML or database or something

                          WebPartDescription wpDescription = new WebPartDescription("MyWebPartID", "My Web Part", null);

                          ArrayList arrWpDescriptions = new ArrayList();

                          arrWpDescriptions.Add(wpDescription);

                          return new WebPartDescriptionCollection(arrWpDescriptions);

               }

     

               /// <summary>

               /// User has selected a web part in my catalog, return the correct instance of that web part

               /// </summary>

               /// <param name="description">The selected web part from the catalog</param>

               /// <returns></returns>

               public override WebPart GetWebPart(WebPartDescription description)

               {

                          if (description.ID == "MyWebPartID")

                          {

                                     //returning an instance of the selected web part

                                     return new MyWebPart();

                          }

     

                          return null;

               }

    }

    The very simple Web Part called MyWebPart is described in my previous blog post, but you can replace it with whatever web part you wish. Let me know if you try this one out and anything seems to crash. As I said, I'm new to this portal framework - haven't even looked at how things are done in SharePoint.

  • [.NET 2.0] Adding Web Parts programmatically

    I'm playing around with the portal frameworks and web parts in .NET 2.0 and it looks powerful. The thing that bugs me most right now is the built in personalization stuff that remember everything I do on my web page (like closing a web part by mistake and not being able to get it back :)

    At the moment I'm looking at the best way to programmatically add web parts from say another assembly and allow the user to add it to a zone. The way I'm doing it now is by implementing the abstract WebPart class and adding it to the zone.

    A very simple Web Part class looks like this:

    using System;

    using System.Security.Permissions;

    using System.Web;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

     

    public class MyWebPart : WebPart

    {

               public MyWebPart()

               {

                          //comment to allow close

                          this.AllowClose = false;

               }

     

               public MyWebPart(String Title) : base()

               {

                          this.Title = Title;

               }

     

               protected override void CreateChildControls()

               {

                          Controls.Clear();

                          Label DisplayContent = new Label();

                          DisplayContent.Text = "Hello web part";

                          this.Controls.Add(DisplayContent);

                          ChildControlsCreated = true;

               }

     

    }

    And I'm adding it to the zone like this:

    private void AddPart()

    {

        MyWebPart myPart = new MyWebPart("MyPart");

        WebPartManager1.AddWebPart(myPart, LeftZone, 0);

    }

    Problems I have now is that the Web Part disappeares sometimes and I don't know how add this Web Part to a CatalogZone. Not much info on the Net about stuff like this. Pity I didn't attend the TechEd, I'm sure there was lots of Web Parts coding samples there. If anyone knows the best way to do it, please let me know.

    EDIT 1: It seems that you're not supposed to be using a CatalogZone when you want to add Web Parts at run time. Just implement you own kind of catalog and use the AddWebPart() to add it to the zone you want to have it in. The Web Part will saved in the personalization data.

    EDIT 2: I've implemented my own catalog now by deriving from CatalogPart. See my other blog post for a sample.

    Anyone working on doing a portal framework on top of this? Something like IBuySpy Portal but based on Web Parts instead of User Controls?

  • Installing SQL 2005 Express on top of SQL 2000

    I'm going to install the VS 2005 beta on one of my lab boxes here, and this machine already has SQL 2000 on it. What happens if I check to install SQL 2005 Express during the VS 2005 installation? Will it upgrade 2000 to 2005 or what?

    I'm sure people has tried this out there, but if I don't get any response I'll just go ahead and try and see what happens :)

    EDIT 1: Brilliant... Ok, first I installed VS 2005 and all the MSDN stuff, then I rebooted the machine and tried to add SQL 2005 Express. Problem is that it hung in the end (progress meter near 100%) and refused to finish. So I killed the setup process and had a look at the box. It looks like SQL 2005 was installed properly and everything. Just one thing I wonder now... and this sounds stupid maybe, but how do I know which database service I'm running against?? *confused*

    EDIT 2: Ok, I'm almost there! I downloaded the SQL Server Express Books Online and I'm following the walkthrough to create a database app. To be cont.

    EDIT 3: Right, I'm in! It was very easy once I got into it (as usual). 1) Install SQLExpress 2) Make sure SQLExpress service is started and you may also want to start the SQL Browser service and enable some of the other network protocols if you're not running locally only 3) Use your favourite SQL manager (like the server browser in VS 2005) and access the database instance by calling it .\SQLExpress or <computername>\SQLExpress.

    *running off to try some of the new features*

  • No PDC this year?

    I'm trying to find information about a PDC 2004 from Microsoft, but I can't find anything about it. Aren't there going to be one this year?
  • Got a cat

    After 5 weeks of vacation it's time to get back to work again. It's not that funny considering the really, really hot weather we got here in Stockholm at the moment. Not much to do about it though...

    We've got ourselves a kitten. A black male, just 10 weeks old. He's half Maine Coon, half Norwegian Forest so I guess he's going to be a really big and good hunter.

  • [Java] New versions of Eclipse and Lomboz

    New versions of Eclipse (3.0) and Lomboz (3rc2) "forced" me to update the walkthrough / getting started I have written. If you're a Java jockey looking for one of the (IMHO) best free Java IDEs out there with pretty good support for J2EE, debugging and ANT, the article may help you.

    Note that the latest version of Lomboz that runs with Eclipse 3.0 needs the EMF plugin.

  • [Books] Test-Driven Development in Microsoft .NET?

    I was thinking of buying the book "Test-Driven Development in Microsoft .NET", but is it a good idea when you look at what's coming in VS.NET 2005? I guess the way we do and run (unit) testing will change a bit with the great tools shipped with VS.NET 2005...

    Maybe the book is good reading anyway?

  • Re-throwing exceptions

    Brad Wilson wrote a short thing on re-throwing exceptions that I like:

    What bugs me is that "throw exception;" line. In my mind, that code is always wrong, because it throws away valuable information. It's not your exception, but you're "laying claim" to it by pushing in your own stack trace, killing the potentially valuable information in the original stack trace

    Read the full post (it's a short one).

  • [Java] Done with Java for a while

    Three days ago we released a pilot system based on Vignette Application Portal and it seems to hold up pretty well even though we have ripped out and replaced most of stuff that has to do with login, navigation and page/portlet display :)

    The most complex part of the portal is the automatic creation of user accounts and silent login. With the help of the NTLM servlet filter from the jcifs package, the system extracts the user's Windows username and domain and is automatically logged into the portal. For first time users we extract required fields like first name, last name and e-mail address from our internal LDAP directory and then create the account in the portal. Would have been quite a bit easier if this was a system running on the Microsoft platform but thanks to jcifs it works pretty well. If anyone wants to know how it's done, just contact me.

    This is my last day before vacation, and after the summer it looks like I'll be going back to work with .NET stuff again. After messing around with Notepad and loads of xml files and property files and open source packages from all over the Internet and Java apps that consume every bit of physical memory my laptop has, it sure feels good with vacation. Not that I don't like Notepad or open source, it's just that I'm getting older and like comfortable coding environments, like VS.NET ;)

  • SunkCostDrivenArchitecture

    Very true words from Martin Fowler:

    "I find this to be a sadly common architectural style. Your company buys some very expensive piece of infrastructure software. You are then told you must use it on a project even if it's not suitable for the project and causes you extra effort. After paying all that money for it you don't want it to go to waste do you?"

  • [Java] How to install Eclipse and Lomboz

    I wrote a small walkthrough, getting started, tutorial or whatever about how to install and configure Eclipse and Lomboz, mostly for myself. Someone else might find it useful too so I decided to post it on my blog more or less as it is. Most of the information is gathered from other sources on the Internet, and I've tried to list the resources in the article. If you find a missing resource or error in the text, please send me a note.

    Much of the information in this "article" is gathered from the ObjectLearn website, which has a number of great walkthroughs for Lomboz.

    EDIT: I've updated the article and corrected a few errors in it. Thanks for the feedback.

  • [Java] Installing Eclipse and Lomboz

    About

    This is a walkthrough, getting started, tutorial or just something I wrote down mostly for myself. Someone else might find it useful too so I decided to post it on my blog more or less as it is. Most of the information is gathered from other sources on the Internet, and I've tried to list the resources. If you find a missing resource or error in the text, please send me a note.

    Much of the information in this "article" is gathered from the ObjectLearn website, which has a number of great walkthroughs for Lomboz.

    Note! Please read the changes section below, it may contain important information.

    Changes

    2005-10-31 Important note! I got a message that the ObjectWeb people now have repackaged Lomboz into something a little easier to install and get started. Have a look at their website before you dig into this (perhaps now obsolete) article -> http://lomboz.objectweb.org/downloads/drops/S-3.1RC2-200508311616/

    2004-07-07 (a little bit later) Ok, article is now updated. I use Eclipse 3.0 and Lomboz 3rc2, and I've also added a short "getting started" section at the end.

    2004-07-07 I just realized that both Eclipse and Lomboz had been updated with newer versions (version 3.0 of Eclipse for example) and I have to update this article again! :)

    2004-07-06 Updated the Lomboz installation steps. A few things were very wrong. Also updated a few typos in the text. Thanks for the feedback.

    Purpose

    This document is intended to explain how to install the Java IDE Eclipse and the Lomboz plug-in. Some of the information in this article is taken from the Eclipse and Lomboz (ObjectLearn) websites.

    General Information

    Eclipse is a kind of universal tool platform - an open extensible IDE for anything and nothing in particular. Eclipse is an open platform for tool integration built by an open community of tool providers. Operating under an open source paradigm, with a common public license that provides royalty free source code and worldwide redistribution rights, the eclipse platform provides tool developers with high flexibility and control over their software technology.

    Lomboz is a free eclipse plug-in for the J2EE developers, developed by Objectlearn. It is a tool with a simple philosphy: "No magic tricks". Lomboz is integrated with many popular open source J2EE tools such as: Jasper, XDoclet, Axis and Ant. Lomboz is available as open source under LGPL license from at the ObjectWeb Forge.

    Resources

    Eclipse http://www.eclipse.org/
    Lomboz http://www.objectlearn.com/
    Eclipse plug-ins http://eclipse-plugins.2y.net/

    Lomboz v3.0 uses models based on eclipse EMF project. If you do not have it installed already, You will need to download and install EMF runtime builds release 2.0.0 or later. EMF MUST BE INSTALLED PRIOR TO USING LOMBOZ.

    Installation of Eclipse

    How to install and configure Eclipse.

    1) First of all, download and install a Java 2 SDK, Eclipse needs version 1.3 or higher, but Lomboz needs 1.4, so use J2SDK 1.4.2 from Sun http://java.sun.com/j2se/1.4.2/download.html.
    2) Download Eclipse from http://www.eclipse.org/, preferably the latest 3.0 version.
    3) Unzip the file to the root of the drive, for example C:\, this will give you a C:\eclipse\ directory where you’ll find the eclipse.exe binary.
    4) Start eclipse by executing the eclipse.exe file.
    5) Go to Window->Preferences then look at the settings for Java->Installed JREs and make sure that your JSDK is used. If it is not, add it to the list of installed JREs and check it. When I change JRE, I usually exit Eclipse and restart it... just to be sure.

    Installation of EMF

    How to install and configure EMF, a required J2EE plug-in for Eclipse if you want to use Lomboz.

    1) Download EMF (in my case, version 2.0.0) from the EMF site.
    2) Unzip it so it fits nicely into the existing Eclipse directory, in my case I unzip it to the C:\ because that's where I unzipped Eclipse (default).

    Installation of Lomboz

    How to install and configure Lomboz, a J2EE plug-in for Eclipse.

    PRE-REQ: Lomboz v3.0 uses models based on eclipse EMF project. If you do not have it installed already, You will need to download and install EMF runtime builds release 2.0.0 or later. Download the "ALL" package.

    1) First, download a version of Lomboz that runs well with the version of Eclipse that you use. In my case I use Lomboz version 3 RC 2 available from http://forge.objectweb.org/project/showfiles.php?group_id=97
    2) Exit Eclipse if it is running.
    3) The plug-in is distributed in ZIP format, therefore, using your ZIP file utility, unzip lomboz.zip file into the <Eclipse_Home> directory. This will create a couple new plug-in directories named com.objectlearn.jdt.j2ee and com.objectlearn.jdt.j2ee.editors. Make sure that Lomboz is extracted properly into the C:\eclipse\plugins directory.
    4) Start Eclipse.
    5) Select menu "Window>Customize Perspective...", in the "Shortcuts" tab choose the "New" submenu and check "Java->Lomboz J2EE Wizards".
    6) Select menu "Window>Customize Perspective...", in the "Shortcuts" tab choose the "Show View" submenu and check "Lomboz J2EE".
    7) Select menu "Window>Customize Perspective...", in the "Command"s tab in the available commands tab, check Lomboz Actions.
    8) Close the "Customize Perspective" dialog by presseing the OK button.
    9) Select menu "Window>Preferences", in the "Workbench->Label Decorations", check "Lomboz J2EE Decorators".
    10) Once you confirmed your selections, you will see the newly added toolbar button in the Eclipse toolbar and the different Lomboz wizards will be available to you from the “File->New ” menu.

    Configure Lomboz

    Some settings really MUST be properly configured for Lomboz to work. Follow these instructions to the point.

    Java Settings

    You must make sure that Java projects have separate source and binary folders. Open the preferences dialog from "Window->Preferences" menu and expand the "Java->Build Path->New Project" settings. Make sure you set it up with this values:

      • Check the "folders" radio button.
      • Source folder name should be "src".
      • Output folder name should be "bin".
      • Select "JRE_LIB variable" in the drop-down list for JRE libraries.

    Lomboz Settings

    Most application servers use the standard Java compiler (javac) to compile JSP files.  Javac is found in the tools.jar distributed with standard Java JSDKs (NOT JREs), that is why a proper JSDK must be installed for Lomboz (see above). You must select the tools.jar that will be used by the application servers here. It is normally found inside the “lib” folder under the JSDK installation.

    Open the preferences dialog from "Window->Preferences" menu and expand the Lomboz settings. Then enter the path to the tools.jar file, something like: C:\j2sdk1.4.2_03\lib\tools.jar (depending on where you installed your JSDK). Leave the default values, but if Tomcat is used, you might want to check the setting for restarting server after deploy.

    Open the preferences dialog from "Window->Preferences" menu and expand the "Lomboz->Server Definitions" settings. This is where you enter the correct settings for your selected application server. If you for example are using Tomcat 5.0.x, it might look like this:

      • Application Server directory: C:\jakarta-tomcat-5.0.19
      • Address: localhost
      • Port: 8080
      • Classpath variable name: TOMCAT_HOME
      • Classpath variable: C:\jakarta-tomcat-5.0.19

    NOTE: It is VERY important that you click Apply after you have changed the server settings. Step through the other tabs to make sure that the different CLASSPATH settings are correct.

    Files with server definitions are stored in a folder named "servers" below the Lomboz plug-in directory. Lomboz scans the folder every time it needs a definition. To add a new server type, just add anotherone of these files into this folder.

    In order to use (activate) any of these definitions you must ALWAYS visit the Lomboz preferences.

    Creating and Testing a J2EE Application

    Now Eclipse and Lomboz is ready for testing. Just to get you started:

    1) Select "File->New->Project..."
    2) Expand "Java" and select "Lomboz J2EE Wizards->Lomboz J2EE Project". (There are many ways to get here, just make sure you end up selecting "Lomboz J2EE Project" in the end :)
    3) Continue the wizard by clicking "Next" to the "Project Settings" dialog.
    4) Give it a project name, something like "My Lomboz Project". Press "Next".
    5) In the "Java Settings" dialog, just press "Next" button again, no need to add any things here unless you know you will need some cool java libraries in your project.
    6) In the "Create J2EE Module" dialog, you must add a "Web Module". Click the little "Add..." button and enter a module name called "myweb" or something.
    7) Select the "Targeted Servers" tab, find your selected application server in the "Type:" dropdown (in my case Apache Tomcat v5.0.x) and press the little "Add..." button to add it to the list of targeted servers. I know, these dialogs are a bit strange, but you get used to them eventually...
    8) If you added one (or more) servers, the "Finish" button activates, and you can click it.
    9) The "Package Explorer" window should now show you the newly created project. Expand it and see "myweb" there. It should contain 2 jsp-files created for you.
    10) To test the stuff:
        a) Find the "Lomboz J2EE View" window and expand "My Lomboz Project".
        b) Right click "myweb" and select "Deploy" and messages should start showing up in your "Console" window.
        c) Start the application server (unless it's already started). If it's Tomcat, you can start it from the "Lomboz J2EE View" by right clicking the server item below "myweb" and select "Run Server" or "Debug Server".
        d) Test the web page, in my case I run against http://localhost:8080/myweb/

    Something like that should get you started, but it depends a bit on what kind of application server you've got. Good luck!

    Other Tutorials

    Visit and walk through the following great tutorial pages on the ObjectLearn website:

    Creating Your First J2EE Project - http://www.objectlearn.com/support/docs/creatingFirstJ2EEProject.jsp

    Adding a new J2EE Module to a Project - http://www.objectlearn.com/support/docs/addingNewContainer.jsp

    Your First Web Application - http://www.objectlearn.com/support/docs/firstWebApplication.jsp

    The same web site contains a number of other good tutorials, but the ones above are needed to get a grip of the IDE.

  • [Java] Deep into the Java trenches

    Long time no blogging... I'm deep, deep under cover... uh, no, not really. I'm deep into the Java portlet stuff at the moment, and I've realized (once more) that doing stuff (like coding some simple functionality in a portal) takes WAY longer in a Java portal than it does in say for example SharePoint or even the free IBuySpy portal. At the moment it feels like I'm spending 90% working with the environment, trying to get things to work and compile and only 10% coding the actual function!

    It was the same thing 2-3 years ago when I was architecturing a full fledged J2EE app using BEA Weblogic, Oracle and the iPlanet LDAP catalogue and amazingly enough NOTHING HAS CHANGED! I'm getting stuck editing sh*tloads of xml config files, ANT scripts, finding the right plug-ins (and the right version of this plug-in that works with the version of the IDE I'm using), finding the right jar-files (downloding loads of them from apache and jakarta) etc... Must it really be like this? Then you got the never ending discussion amongst the coders about which Java editor to use... yikes!

    One way is to go for a certain portal, say from BEA, then use their tools to develop portal functionality. But then your're stuck with BEA and you'll get hell when/if you want to move to another J2EE portal platform, even if you stick to coding JSR168 portlets.

    I really don't mind the coding bits, the Java language is great, but the rest that comes with it I can do without for sure.

  • [Java] Coding java (jsr168) portlets with Eclipse

    On my third and last day at the Vignette Application Portal coding course, and I'm glad I sat down last week to really learn the coding IDE Eclipse and the Lomboz plug-in.

    I can now code jsr168 portlets with full intellisense/code completion in Eclipse, package and hot deploy it in weblogic - really, really nice. Once you got the environment set up, coding java portlets isn't too bad. Pity it takes ages to learn and set up the environment, and all hell breaks loose if you get a stacktrace :/

    I still have to learn how to start weblogic in debug mode inside Eclipse so that I can debug the portlets. Not sure it will work at all actually...

    EDIT: I had spelled Lomboz wrong, sorry bout that :)

  • [Java] Attending a Vignette course...

    Vignette Application Portal (VAP) is a Java portal application that runs on most application servers out there, and I've been more or less forced into attending it :/

    Anyway, I'm on day 4 of this course, which is very much about how to administer VAP, and it's so boring it's killing me! I've had enough editing of property files and XML files and setting of permissions that it will last for a year... Thank God, there will be another course next week with 3 days of how to code portlets. It's not .NET, but it's coding anyway... I've not been to a course for years and years, usually it's me standing there talking about stuff. I prefer installing something I need to learn on my own machine and play with it for a week rather than attending courses, but my new manager wouldn't listen to that :/

    How on earth did I get involved into all this Java stuff??? I want to do .NET, not Java!! *sob*

  • How to list active connections for a process in win2k?

    I'm sure many people have been trying the same thing, but I need to get the name or id of the process that owns a certain ip port or connection on the machine. I found the undocumented API:s called AllocateAndGetTcpExTableFromStack and AllocateAndGetUdpExTableFromStack but as far as I know, they are only available for WinXP and possible Win2k3 as well, but my program should run on win2k as well. I've been looking for hours for a way do get open connections for a process in win2k, but it's impossible. I don't want to write my own device driver...

    Some tools do it, like Fport.exe, but I wonder how!


    So, any idea about how to solve this? Preferably in c# or vb.net...

  • PacManhattan

    I got this page from Jan-Erik, and it looks really fun. Real Life PACMAN around Washington square park! And it is software-related too! ...sort of ;) Quoted from their webby:

    Pac-Manhattan is a large-scale urban game that utilizes the New York City grid to recreate the 1980's video game sensation Pac-Man. This analog version of Pac-man is being developed in NYU's Interactive Telecommunications graduate program, in order to explore what happens when games are removed from their "little world" of tabletops, televisions and computers and placed in the larger "real world" of street corners, and cities.

    A player dressed as Pac-man will run around the Washington square park area of Manhattan while attempting to collect all of the virtual "dots" that run the length of the streets. Four players dressed as the ghosts Inky, Blinky, Pinky and Clyde will attempt to catch Pac-man before all of the dots are collected.

    Using cell-phone contact, Wi-Fi internet connections, and custom software designed by the Pac-Manhattan team, Pac-man and the ghosts will be tracked from a central location and their progress will be broadcast over the internet for viewers from around the world

  • [Java] JAX-RPC vs. ASMX (a few things I noticed)

    Note: This is just a reflection, not a full comparison between the two. I don't have time to do a full review of JAX-RPC I'm afraid ;)

    I dedicated yesterday to looking at JAX-RPC, which is supposed to be a pretty good and standardized way to build web services in Java. I didn't want to use a vendor specific implementation of JAX-RPC, so I downloaded Java Web Services Developer Pack (Java WSDP) from Sun, which has a decent tutorial and numerous examples. It took some hours to get everything going, but the Java WSDP has EVERYTHING you need to get going, except for the Java SDK and a proper editor.

    Well what can I say. It's far from simple. Without proper tools that does the mapping and generation of class-files for you, it is more or less a mess and it's a total pain compared to how easy it is on the .NET platform. Even if you're not using VS.NET and doing it by hand using Notepad.

    Good things about JAX-RPC is that most things seems to be doable with it. The coding part is dead easy and you can do Handlers (just like SoapExtensions in .NET) and stuff too. I noticed that default encoding seems to be rpc/encoded though.

    What I need to stay sane is a good JAX-RPC plugin to intelli-j, eclipse, NetBeans or something. I'll continue to write small stuff about what I find in this field.

  • WS-Security webcasts

    This evening I'm going to hunt for webcasts about WS-Security. I'll try to find fresh ones, starting on Microsoft sites:

    Architect Webcast: Securing Web Services (interwise recording)

    Support WebCast: Introduction to Microsoft Web Services Enhancements (Windows streaming media)

    This one is good if you've been into soap headers and such before:

    Support WebCast: Microsoft ASP.NET: Advanced XML Web Services Using ASP.NET (Windows streaming media)

    And this is an older, but very good article that describes the different proposed security specs around web services.

    If you know of good webcasts about WS-Security, please comment.

  • WS-Security receives official blessing from OASIS

    If someone out there missed it :)

    "Web Services Security 1.0, the foundation specification for creating a security infrastructure around Web services, officially became a standard Monday, paving the way for corporate adoption."

    InfoWorld April 20, 2004 

    One of many articles is available here.

  • Note to self

    Stuff I found while surfing last night...

    Links about MCAD certification and such: http://www.codeclinic.com/certification.htm and  http://weblogs.asp.net/pscott/archive/2004/04/13/112235.aspx

    Some good links and articles about WSE and WS-Security: http://www.bristowe.com/articles/

    A gazillion webcasts on MSDN: http://msdn.microsoft.com/library/default.asp?url=/seminar/mmcfeed/mmcdisplayfeed.asp

    .NET webcasts on MSDN: http://msdn.microsoft.com/library/default.asp?url=/seminar/mmcfeed/mmcdisplayfeed.asp?lang=en&product=103364&audience=100402

    About the (no) need to set objects to nothing in VB: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=953vib%24q24%241%40nnrp1.deja.com&rnum=21&prev=/groups%3Fq%3Dmatt%2Bcurland%2Bnothing%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26start%3D20%26sa%3DN

    MSDN Webcast archive: http://www.microsoft.com/seminar/events/webcasts/library/default.mspx

    Software Fortress Model (SFM) by Roger Sessions (Objectwatch)

    Using Role-Based Security with Web Services Enhancements 2

    SoapHandlers in Weblogic 8.2

    JAX-RPC at Sun

    Eclipse plug-ins

    Lobaz docs and something about eclipse and web services with axis

  • Ways to protect a Web Service

    I'm having a hot discussion with a fellow at work about different ways to protect a Web Service and we're of course having different opinions about this. If you look at the Web Service method or end-point as a resource available on a network and you want to protect that resourse from being called by someone who isn't allowed - how should you do it?

    My friend works for a LARGE company that has a web access management product and he is a product specialist, and this product is pretty good at protecting URL sources. So, he naturally suggests that we use this product and put an access layer in front of all our Web Services. Each Web Service proxy/client must then add a special HTTP header or encrypted cookie that this access management agent looks for before it's allowed to access the service method. Each Web Service method has a unique URL or URI so we just configure it as a protected resource in the access management catalogue and put it's agent (which is a ISAPI filter) on each Web Service server. We don't want to protect the resource with basic authentication because we prefer not to store uid and pw on the machine. Each end user will be using a web browser and also be authenticated through this product, so each user will have a unique and encrypted cookie which can be used to protect each Web Service as well.

    This will probably work pretty fine, and you get rid of access management stuff from the Web Service implementation. But I don't like this solution, for several reasons, but mainly: 

    1. I personally believe that each service should be autonomous and take care of it's own user authentication. In this case I would send the user id as an encrypted token in a SOAP header or implement WS-Security, and do user authentication in a SOAP filter or similar so that Web Service method implementors didn't have to worry about it. Keep out of band data away from message implementation. Besides, isn't this what WS-Security is all about?

    2. I don't like to have HTTP headers or cookies added to the SOAP message. Doesn't that make you transport protocol dependant? What if the services were moved to the back end of MQ or something similar in the future?

    What do you think? Do you see any other reasons to use or not use an access management layer in front of and separated from the Web Service?

    If you know about any good resources on the Net (papers, talks, web cast etc.) that brings this matter up, please write a comment about it. Pat Helland talks much about autonomous services and fiefdoms, and how they should take care of everything themselves, but I've not read or heard much about protecting access to Web Services.

  • Anyone tried encrypting soap messages with WS-Security yet?

    The security guys here also banned access to the soap chat server I set up on the Internet to be able to chat with my old pals... correct, they don't allow Messenger or any other chat-programs. I know I'm not allowed to do chat-stuff over the Internet according to the IT-rules here, but gaaaaahhh!!! I must be able to chat a little with my friends, my mailbox is flooding as it is already!

    I'm thinking of moving my chat Web Service (which is already protected by userid and password in a SOAP header) to another location and encrypting the messages. How hard can it be in .NET?

  • Too much Visio and too little programming - what to do?

    I've been doing too little programming and too much Visio and Word lately, it's getting to me. I guess I have to think up some hobby project or other - any good ideas anyone? I don't have enough spare time to join some bigger projects on the Net though. I've been through a large project like that already when I spent 2 years coding up the UnrealTournament TC called Unreal Fortress. It was way fun but took too much time.

    There must be other programmers like me out there that gets thrown into system architecture land instead of software architecture. Way too many nodes and arrows, and way too few classes and uses ;)

  • Entertaining Pat Helland

    Pat Helland is always good to both read and listen to. This web cast may have been up there on the Net for some time now, but I must have missed it somehow. The presentation is called Metropolis : Envisioning the Service-Oriented Enterprise, and it available here http://msdn.microsoft.com/architecture/enterprise/default.aspx . Personally I think this is one of Pat's better performances, if you're into system / software architecture and Web Services  - don't miss it.

    EDIT: Part 2 of the Metropolis talk is available on this page: http://msdn.microsoft.com/library/default.asp?url=/seminar/mmcfeed/mmcdisplayfeed.asp?lang=en&product=103364&audience=100402

  • Running a VB6 application as a service

    I must give praise to a really nice little tool that I'm sure many of you have used the last years - the NTSVC.OCX control. The control was a sample control made by some guy at Microsoft a long time ago and was provided with the January 1997 edition of MSDN. I'm not sure where or if it is available for download anymore, but boy, has it made life easier for me the last 6 years! I had pretty complex VB6 services running on an NT4 box for over a year without a single stop or reboot of the machine. In the end we had to install a service pack and some hotfixes for NT4 on the machine.

    Someone at Microsoft once coded this thingy, I'm sure some of you know who it is. If so, send my best regards - that control has been of great use.

  • Why I prefer working with Microsoft stuff

    I'll be the first to admit that integration between different Microsoft server products and stuff you develop yourself on the Windows platform isn't always easy, but compared to the PAIN it is to do the same stuff on the Java/J2EE platform it's nothing!

    I've been sitting for days now trying to get Vignette 7 (a java portal server) running on top of BEA Weblogic 8.1 (J2EE app server) against an Oracle database and having Vignette running in a mixed mode with RSA ClearTrust for authentication where the ClearTrust agent is installed as an ISAPI filter on an IIS web server on another machine (for security reasons). GAHH! Forget about any nice looking configuration tools here, we're talking heavy Notepad sessions here! I spent hours and hours in Notepad, with property files and xml files all over my screen. AND THANK GOD FOR GOOGLE!

    The easiest thing to get going so far has been Oracle actually. It would have been cool to use Oracle 10g with it's new and easier setup, but I had to use 9.2 for now. The last thing we have to fix now is automatic login into Vignette after a successful authentication against ClearTrust. If anyones interested (guess you're not :) I'll write another entry and let you know how things went... Man! I want to write programs, not configure Java stuff!

    EDIT: Now we got automatic (Single Sign On) login into Vignette working! After some digging into readme-files and a couple of property and xml files it runs. Had to configure the realm correctly and specify the HTTP header that ClearTrust use for setting the username of the authenticated user. Cool, the biggest problem now will be to build up a good user and group catalogue structure. This will take a long time because we're going to have lots of portal sites, lots of different roles and need distributed admin for this... :/

    One sad thing we notices was that when creating users from Vignette, they ended up properly in the ClearTrust LDAP catalogue, but were marked as private and you couldn't specify a password. Not good. May have to change Vignette config to use read-only mode against the ClearTrust LDAP. Hmmm... Perhaps it's better to move this blog-entry to a new post with a proper Post Title :D

  • Wiki is cool

    I've finally discovered the power of a good Wiki-web. For certain projects it's a wonderful tool - as a tool for collecting requirements, collecting research data for book or whatever job that involves a large amount of text.

    I downloaded and installed OpenWiki (asp/iis) and it runs pretty smooth. Just have to figure out how to upload files to it now :)

  • Oracle 10g for Windows

    Jan-Erik reports on his blog:

    Yes! At last it is here and I just got it up and running on my XP machine.

    For some strange reason I haven't been able to install it on my newer and faster Win2K machine. It keeps on saying

      Error in starting the service. The service 
      OracleCSService was not found
    

    I have tried deinstalling all my old Oracle stuff but it still wont work... darn!

  • How to move the cursor to the correct line in a RichTextBox

    I'm sure there is a really simple way of doing this, but this works out for me. Please write a comment and tell me how it's supposed to be done if this isn't the best way (which I'm sure it isn't ;)

    public void SetCaretLine(int linenr)

    {

          if(linenr > this.richTextBox1.Lines.Length)

          {

                MessageBox.Show("Line " + linenr + " is out of range.");

                return;

          }

     

          int row = 1;

          int charCount = 0;

          foreach(string line in richTextBox1.Lines)

          {

                charCount+=line.Length + 1;

                row++;

                if(row == linenr)

                {

                      //set the caret here

                      this.richTextBox1.SelectionStart = charCount;

                      break;

                }

          }

    }

    Well? I guess there's a win32 api lurking in the shadows that does this in 1 or 2 lines of code - then show me already!

  • Use LockWindowUpdate to get flicker-free RichTextBox update

    Very simple, but I had to dig around to find it so I might as well share it here. I do lots of updates to a RichTextBox while colorparsing some code, and I didn't like the flickering.

    Since there is no BeginUpdate() or similar, I had to use Win32 api from user32.dll:

          [DllImport("user32.dll")]

          public static extern bool LockWindowUpdate(IntPtr hWndLock);

    To use it just:

    try

    {

          LockWindowUpdate(richTextBox1.Handle);

          //change colors and stuff in the RichTextBox

    }

    finally

    {

          LockWindowUpdate(IntPtr.Zero);

    }

     

    UPDATE: I got a tip fom Kevin Westhead to use SendMessage() with WM_SETREDRAW instead:

     

    I think it's better to use SendMessage with WM_SETREDRAW to enable/disable drawing on a window since LockWindowUpdate can only be applied to one window. This means that you might not be able to lock your window if someone else has already locked a window, or someone else could unlock your window without you knowing.

    So if you prefer this alternative, please do like this:

     

    private const int WM_SETREDRAW      = 0x000B;

    private const int WM_USER           = 0x400;

    private const int EM_GETEVENTMASK   = (WM_USER + 59);

    private const int EM_SETEVENTMASK   = (WM_USER + 69);

     

    [DllImport("user32", CharSet = CharSet.Auto)]

    private extern static IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam);

     

    IntPtr eventMask = IntPtr.Zero;

    try

    {

          // Stop redrawing:

          SendMessage(richTextBox1.Handle, WM_SETREDRAW, 0, IntPtr.Zero);

          // Stop sending of events:

          eventMask = SendMessage(richTextBox1.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero);

     

          // change colors and stuff in the RichTextBox

    }

    finally

    {

          // turn on events

          SendMessage(richTextBox1.Handle, EM_SETEVENTMASK, 0, eventMask);

          // turn on redrawing

          SendMessage(richTextBox1.Handle, WM_SETREDRAW, 1, IntPtr.Zero);

    }

     

    Thanks Kevin!

  • Better Visio stencils for UML drawing

    Pavel Hruby keeps a set of Visio stencils for UML that are intuitive and easy to use. Very good if you want to do a bit of free hand UML drawing. From his webby:

    Thank you for your interest in the stencil and template for the drawing tool Visio. The stencil supports all symbols of UML 1.5, specified in the OMG document formal/03-03-01, as well as previous UML versions 1.4, 1.3 and 1.1. The stencil also contains several symbols of the newly adopted UML 2.0, particularly, the Socket and new Pseudostate symbols, and additional symbols not specified by the standard, but used by many UML users. 

    I can recommend them for sure. The stencils are free to be used, copied and modified as you like, and can be downloaded here. Pavel, my humble thanks to you for giving such nice stuff away.

     

     

  • Found a bug in SqlHelper's UpdateDataset() method

    UPDATE: This is for version 2.0. I just did a few searches on the GotDotNet workspace and saw than another fellow had reported the same thing in their forum. But there were no replies.

    UPDATE 2: I couldn't get into their Bug Tracker coz of some Passport error before. But I can now see that the problem with the UpdateDataset() method is on the list. I guess it will be fixed in version 3.

    After a couple of hours of debugging I finally found the bug. It wasn't in my code, it was in the UpdateDataset() method of SqlHelper!

    I had a strongly typed DataSet with 2 tables in it (with a relation between them) that I wanted to add to the database. It was an order (in one table) with several order details (in another table). Problem was the order details were never written to the database!

    So, first I called on SqlHelper.UpdateDataset() for the order data, then I did the same with the order details, but the problem was that the UpdateDataset() method calls dataSet.AcceptChanges() after the dataAdapter.Update(), and this changes EVERY datarow and datatable in the whole dataset! The result of that was that my order details were never written to the database, because they were flagged in the RowState as "unchanged". The correct thing (I guess) would be to accept changes on the affected table only as the code at the bottom of this post shows.

    This is the original code with the error in it:

        Public Overloads Shared Sub UpdateDataset(ByVal insertCommand As SqlCommand, ByVal deleteCommand As SqlCommand, ByVal updateCommand As SqlCommand, ByVal dataSet As DataSet, ByVal tableName As String)

     

            If (insertCommand Is Nothing) Then Throw New ArgumentNullException("insertCommand")

            If (deleteCommand Is Nothing) Then Throw New ArgumentNullException("deleteCommand")

            If (updateCommand Is Nothing) Then Throw New ArgumentNullException("updateCommand")

            If (dataSet Is Nothing) Then Throw New ArgumentNullException("dataSet")

            If (tableName Is Nothing OrElse tableName.Length = 0) Then Throw New ArgumentNullException("tableName")

     

            ' Create a SqlDataAdapter, and dispose of it after we are done

            Dim dataAdapter As New SqlDataAdapter

            Try

                ' Set the data adapter commands

                dataAdapter.UpdateCommand = updateCommand

                dataAdapter.InsertCommand = insertCommand

                dataAdapter.DeleteCommand = deleteCommand

     

                ' Update the dataset changes in the data source

                dataAdapter.Update(dataSet, tableName)

     

                ' Commit all the changes made to the DataSet

                ' This is a buggy one, it resets other tables RowState to "unchanged" /Johan

                dataSet.AcceptChanges()

            Finally

                If (Not dataAdapter Is Nothing) Then dataAdapter.Dispose()

            End Try

        End Sub

    And this is how it should look:

        Public Overloads Shared Sub UpdateDataset(ByVal insertCommand As SqlCommand, ByVal deleteCommand As SqlCommand, ByVal updateCommand As SqlCommand, ByVal dataSet As DataSet, ByVal tableName As String)

     

            If (insertCommand Is Nothing) Then Throw New ArgumentNullException("insertCommand")

            If (deleteCommand Is Nothing) Then Throw New ArgumentNullException("deleteCommand")

            If (updateCommand Is Nothing) Then Throw New ArgumentNullException("updateCommand")

            If (dataSet Is Nothing) Then Throw New ArgumentNullException("dataSet")

            If (tableName Is Nothing OrElse tableName.Length = 0) Then Throw New ArgumentNullException("tableName")

     

            ' Create a SqlDataAdapter, and dispose of it after we are done

            Dim dataAdapter As New SqlDataAdapter

            Try

                ' Set the data adapter commands

                dataAdapter.UpdateCommand = updateCommand

                dataAdapter.InsertCommand = insertCommand

                dataAdapter.DeleteCommand = deleteCommand

     

                ' Update the dataset changes in the data source

                dataAdapter.Update(dataSet, tableName)

     

                ' Commit all the changes made to the DataSet

                ' Commit changes to THIS TABLE ONLY! /Johan

                dataSet.Tables(tableName).AcceptChanges()

            Finally

                If (Not dataAdapter Is Nothing) Then dataAdapter.Dispose()

            End Try

        End Sub

    It's late, maybe I'm wrong, but things work way better now. Am I wrong? I'll try to notify the devs about this.

  • Getting Intel 815 display adapter to work in Longhorn

    I installed Longhorn on a separate box a couple of days ago but it couldn't find a suitable driver for the built in Intel 815 graphics chip. I tried to download and run the driver installer from Intel, but the program bombed. Then I extracted all the files from the install program (with WinRar), and pointed the the display driver installation wizard at the win2000 folder from the extracted files. Yay! I now got a high rez Longhorn!
  • [Java] Java taglibs are quite useful

    My adventure down the Java road continues and it's starting to look like something. The little project I'm doing makes use of JSP pages and instead of using Servlets as the controller, I've dived into JSP taglibs.

    Taglibs work somewhat like ASP.NET user controls, but they are not as powerful. Each taglib class represents a HTML-tag and you can specify different attributes for it, quite similar to user controls, but very different in implementation. The biggest problems I've had so far is working with the taglibs in my jdev 9 editor. Sometimes my taglib classes doesn't show up after using the jdev wizards, etc. I'm thinking of trying out Intellij or NetBeans instead, but I don't know how well they handle taglibs.

    God what I miss DataSets when working with Java and JDBC!!

  • Nominated to the Swedish .NET Awards

    One of the web projects I architected has been nominated to the Swedish .NET Awards in the Web Services category. Cool, free food and drinks I hope, and I know there's gonna be some kind of show afterwards :)

    The project itself isn't very that large, but parts of it is pretty complex. All the business and data logic is separated from the front web by firewalls and we make heavey use of SOAP attachments to upload and send Word documents to the back end. The worst thing was the COM interop with Word... I hate it. If you're not careful and catch every possible error, you end up with a terrble list of orphan WINWORD.EXE processes...

    Wish me luck, the cermony is held by Microsoft on the 3rd of March. I'm sure we won't win, but it's still action, isn't it :)

  • Installed Linux, MySQL and Tomcat...

    Going to do a small job for a friend of mine, but it has to be done using Java and a bunch of open source stuff. So a couple of days ago I took an old, dusty puter I had lying around in a corner, 333Mhz and 256MB or RAM and started to install Red Hat 9. 2-3 hours later I had everything I needed in the box. The Red Hat install was very smooth and found all the old stuff I had in the machine. DHCP configuration and everything worked at once.

    The worst problem was getting the correct Java SDK downloaded and installed, then configure Tomcat and MySQL correctly. I still have to figure out how to autostart them... probably some weird config file or other in some strange user directory...

    MySQL works pretty fine with the J/Connector driver. The manuals suck, but you shouldn't expect anything else from software you don't pay anything for. Thank God for Google and good friends to help you sort out all the strange stuff with MySQL and Tomcat. All in all, it runs pretty well on that old machine. We'll see what happens when I try to deploy the stuff I'm coding in JDeveloper on my Windows machine over to the Linux box. Things will probably not work at once, even though it's a J2EE appliation (did I hear anyone say "write once - deploy everywhere"? Yeah sure ;)

  • Viewstate problems in web farm

    The second time I'm involved in a large ASP.NET web project with a web farm and load balancing with no afinity (no sticky sessions), and the second time we're experiencing problems with viewstate errors :(

    Again, I had to go through the code and look for Server.Transfers, identical machine keys etc. all according to the KB articles regarding this problem. But everything looks OK in the code! Things work perfect on a single box, and even on the load balanced testing machines, which has exactly the same configuration, hardware etc. I hate these problems! I heard somewhere that the viewstate problems could happen when the ASP.NET pages were compiled at different times, so what we did yesterday was to remove all temporary compiled ASP.NET files and touched the machine.config files at the same time. Now things seems to run fine.

    The first time we had a few problems with the case sensitive Server.Transfers, and we upgraded to .NET Framework 1.1 and problems were solved. This application I'm talking about is still running on version 1.0 and we cannot yet upgrade it to 1.1 until it's been fully tested and so on... I'm not sure it will help, but it looks like Microsoft fixed more than a few viewstate errors from version 1.0. Tried once to disable the viewstate MAC checking, other strange things started to happen then, like form posts that didn't generate postbacks... *yikes*

    Does anyone have any experience to share? The application consists of a large number of ASP.NET pages and quite many assemblies.

  • [Refactoring] ReSharper EAP is Open

    Old news for some here maybe, but anyway - the ReSharper (C# refactoring and other goodies) plugin for VisualStudio.NET 2003 is available for download now.

    ReSharper is developed by JetBrains, Inc, and will contain a number of features that we see and love in the IntelliJ editor. I've just downloaded it and will try it out later today. It doesn't contain more than one refactoring so far, but has a number of other goodies in it that is worth trying I think.

    Quote from the IntelliJ forums at http://www.intellij.net/forums/thread.jsp?forum=7&thread=76005&tstart=0&trange=15 :

    "We have opened the EAP for our new product for C# development: ReSharper.

    EAP M1 (build 64) is available at http://www.jetbrains.net/resharper

    Please use the following credentials to access the ReSharper EAP site
    (
    http://www.jetbrains.net/resharper):

    User name: eapuser
    Password: eapuser

    --
    Oleg Stepanov
    Software Developer
    JetBrains, Inc
    http://www.jetbrains.com
    "Develop with pleasure!""

  • Oh, so slow

    I finally got the Longhorn and Whidbey DVD from Microsoft! It only took them 2,5 months - yay ;)

    Anyway, installing VPC went smooth, but MY GOD how slow the Longhorn build is! I knew it was slow from all the reports, blog posts and articles some of you had submitted, but this is hurting my stomage :o Perhaps I installed the wrong ISO? I installed the file LH_USA_4051_X86CHK_PRO.ISO  - is that the right one? I wish the readme could have been just a bit more informative... guess I'll have to dig around the longhorn sites out there and see what I find. Can anyone be so kind and tell me if that's the right one? Perhaps I installed the build with a gazillion debug-lines in it, instead of the build with just a million debug-lines... ;)

    My box has a 2 GHz pentium and 512MB memory, I gave VPC half of it, and I know it might need more, but still... well, I guess I will have to take it. Besides, once you've set your eyes on that desktop clock...you...can't...take...your...eys...off... eeeeeekkkkk!!!

  • The Last Samurai - better than I thought

    I saw the movie "The Last Samurai" last night, and it was way better than I thought it was going to be. IMHO it's the best movie Tom Cruise has been in. Lovely props and some nice moves with the sword by Tom. Nice to see realistic ken (japanese sword) techniques for once in a movie...
  • The mysterious ways of the RichTextBox...

    The kind of systems and applications I normally develop are browser-based, but now and then I try my luck at Windows Forms. Right now I'm doing this little instant messaging program, a pretty simple chat that communicates with a server via SOAP. Anyways, I'm having this battle with a RichTextBox I'm using in a form to display chat messages, smilies and such. Explain this to me: When the RichTextBox is designed to be anchored to the bottom of the form, whenr I add text to it while it's minimized in the task-bar, it refuse to scroll down to the end/bottom of the RichTextBox. The effect is that when I bring up the form from the task-bar and look at it, no messages are displayed until I tap once on the vertical scrollbar! Very amazing and feels like a bug. It doesn't matter how much I try to use the ScrollToCaret() method or other tricks, if the RichTextBox has the anchor property set to bottom, ScrollToCaret() doesn't work as it should.

    I think I'll have to subclass the RichTextBox and send my own scroll-messages to it to make this work. :(

  • Redrawing a resized owner drawn listbox

    For some strange reason the MeasureItem event isn't fired when an owner drawn listbox (or similar control) is resized. If you have lots of items in the listbox with variable height, for example text that needs to wrap, this becomes a problem. I tried different stuff to fix this, but it seems that the MeasureItem event is only fired when things are added or removed from the listbox, so the simplest fix was this:

                listBox1.Resize += new System.EventHandler(listBox1_Resize);

     

                private void listBox1_Resize(object sender, System.EventArgs e)

                {

                      RefreshListBox(sender);

                }

     

                private void RefreshListBox(object sender)

                {

                      ListBox listbox = (ListBox)sender;

                      object[] items = new object[listbox.Items.Count];

                      listbox.Items.CopyTo(items,0);

                      listbox.BeginUpdate();

                      listbox.Items.Clear();

                      listbox.Items.AddRange(items);

                      listbox.EndUpdate();

                }

     

    Take a copy of the current items in the box, remove the items and just add them again. Stupid, but as far as I know, this has to be done if you want the correct item height.

  • NUnit 2.1 and Whidbey

    Peter Golde blogs this:

    I was very happy to discover that it is trivial to get NUnit 2.1 to work with the Whidbey version of the .NET runtime. If you have the PDC release, you just need to do the following:

    First, create a new NUnit directory (say, "NUnit Whidbey") and copy everything from your Program FilesNUnit V2.1 directory over to the new directory. Second, open the two files "bin\nunit-console.exe.config" and "bin\nunit-gui.exe.config" inside a text editor. Right above the other lines that start with "supportedRuntime", add the following line:

    <supportedRuntime version="v1.2.30703" />
    After that, NUnit runs just fine with Whidbey, and you can test code that uses Whidbey-only features. 
  • Is Messenger that dangerous?

    The place I'm working at for the moment stops Messenger in their firewall due to some security reason or other. Is Messenger really that dangerous? I've heard about some kind of trojan virus or other that could affect Messenger, but come on! I tried to configure Messenger to use HTTP proxy but it seems to fail. It's probably turned off in the firewall as well (unless someone out there knows how to get it working).

    Anyway, I'm desperate to be able to chat with my old pals, so I'm thinking of rolling my own simple chat program, which uses a chat-server implemented as a web service, and throw the client at my pals... I've been without Messenger for almost 3 months now... must...chat...now...

  • Got a new aquarium

    Well, I got me a new aquarium, and this one doesn't leak. Not yet at least :) Only thing I need now is some nice looking fish to put in it.

  • Leaking aquarium.... gah!

    I bought an aquarium today, just a small one, 50 liters, but very nice hexagon shaped. I've spent the last hour or so setting it up and filled it with water, just to find out that it LEAKS!!

    [insert favourite words here]

    Lucky I didn't buy any fishes yet. I was going to do that tomorrow, when things were ready, water temperature right etc... That shop is going to hear a few nice words from me tomorrow...

  • [Books] The practice test for the web app MCAD exams really sucks

    A year or so ago I got the MCAD/MCSD self-paced training kits from MS Press to do the test exams. I've been through 12-13 of the questions now and I've seen an embarrassing number of errors so far. Code snippets with obvious errors that would never compile etc. etc. Right now I'm looking at a question about settings in web.config with 4 answers, and all of them are wrong! Amazing...

    This practice test cannot have gone through any review whatsoever by someone who really knows ASP.NET :(

  • Watched some of the Indigo presentations from PDC

    I watched a few of the streamed Indigo presentations from the PDC the other day. I got a good grip of the basics of what Indigo brings now, even though I think the presentations I saw wasn't really up to the standards.

    The best way to prepare for Indigo seems to be to use ASMX and ES (Enterprise Services) inside the ASMX methods if you really need ES features like automatic transactions. I got the feeling that Don and the Indigo guys recommeded to stay away from .NET Remoting and I don't have a problem with that :)

    The peer-to-peer stuff in Indigo looks really nice, and I will sure test them out once I get my hands on the libraries needed.

    First day at work after 2 weeks off... I need coffee!!