Sitecore tells you: “Specified cast is not valid” during startup

An annoying issue which came across twice this week: Sitecore was throwing “Specified cast is not valid”-Exceptions:

"Specified Cast is not valid"-exception

And seriously, if there’s one thing I hate about .NET in general, it are exceptions. 95% of the time they are non self explaining and sometimes even nonsense. This exception would normally take me 20 minutes to solve at least. But not this time. So how to solve this one?

Basically, this is nothing more than a Database Connection error… When I added /sitecore behind my url, I received a generic connection failure exception. I had to do some work on my connection string(or start my SQL Server). That’s all. But Alex, where did it come from? And why does the login page show something different?

Chicken and the egg issue: when accessing an Item we need a (SQL)-Database, but before allowing to access an Item, we need a User, a User needs a (SQL)-Database. And of course, this dependancy became stronger when we introduced Sitecore v6 with the Membership Providers.

So what can we learn from this? Always consult both pages: / and /sitecore. Often, there’s a different message. Sitecore is all based on context(yes, Sitecore.Context…). So when you have a problem, always try different entry points to minimize the Context. For example, Sitecore has by default 2 active websites running: ‘website’ and ‘shell’. In this case, I tried to access both of them.

Happy coding out there 🙂

Sitecore 6.1 Update 1 Released

To all of you Sitecore Developers, Architects and Webmasters out there. I just want to point you on our latest update: CMS 6.1.0 Update rev. 090722 , also known as 6.1.0 Update-1 ) and OMS 1.0.0 (full version number: Sitecore Online Marketing Suite 1.0.0 rev. 090722).

Although it isn’t a recommended release at the moment, I’d suggest everybody who’s working with the Sitecore OMS to update your installation to this version. Especially when you’re still in the development process of your website. Directly after the final release we’ve been working for a full month to make sure this release would fix every annoying issue which was introduced with our newest release feeded by the earliest Customer and Partner feedback.

So to give your site an optimal boost: install this version! 🙂

Later this week, I do expect some more exciting news… I’ll keep you posted!

Sorting Sitecore Items

One of the most unknown but very useful feature in Sitecore is the Subitem Sorting. Often there’s a need to sort a group of Items in a particular order. Either to create a good navigation or to help the content editor find their content.

So let’s have a look how this functionality is working. I’ve installed an empty Sitecore 6.1 installation and created a couple of sample items in a random order.

Sitecore tree with random items
Now I want to sort my items in a less random order. Let’s order them on Display Name. To do so, I’ve to go to my Home and click on the Sorting Command:
Sorting command in Home tab
A new windows will appear with a list of the default Sitecore Sorting settings:
image

In this case I select ‘Display Name’. The box below will give me an immediate preview how the new order of the Subitems looks:

image 
There are plenty other options to choose, including Standard Values.
When I click on ‘Ok’, the setting will be applied and my content tree will refresh:
To reflect the change in the front-end, you’ve to publish the Home item including subitems (or execute an Incremental Publish).
Note: As always, it’s a best practice to setup Subitem Sorting on the Standard values of a template. That will make sure that all the items based on the Template will reflect the same sort order. For individual cases, you can set it up on an individual item.

To make sure that this example works fine, I’ve made sure that the name of the item is also inserted in the Title field of my Item:

imageNow I want to create a custom Sorter which sorts my items rather on Title than on Display Name. The first thing I’ve to do is to write a small class:

   1: using Sitecore.Data.Comparers;

   2: using Sitecore.Data.Items;

   3:  

   4: public class YetAnotherComparer1 : Comparer

   5: {

   6:     protected override int DoCompare(Item item1, Item item2)

   7:     {

   8:         string x = item1["title"];

   9:         string y = item2["title"];

  10:  

  11:         return x.CompareTo(y);

  12:     }

  13: }

The class implements Sitecore.Data.Comparers.Comparer. This base class forces you to implement the DoCompare method. Basically, this method reads both title values and compares it using the .NET built-in string.CompareTo().

Note: I’m using the indexer([“fieldname”]) to retrieve fields. This will never return a null, only a string.Empty when the field doesn’t exist or is empty.

Afterwards, we’ve to register the class in Sitecore. We can create an item of the template ‘Child Sorting’ (/sitecore/templates/System/Child Sorting) in /sitecore/system/settings/Subitems Sorting:

imageNow I’m able to select my item from the sorting dialog:

imageAnd from now on, my items will get sorted by title-value.

Of course this is just an example. You can think about different sorters and also use them in the front-end.

Sitecore’s VP and Founder Lars Fløe Nielsen will follow up on this post with more technical details and how to use Sitecore Sorters in the frond-end. I’ll update this post once his second article is published.

Thank you, Sitecore community

Just a short blogpost from me this morning. I want to thank all of you for supplying us so much valuable input. We highly appreciate the way you guys are helping us on improving all the different functionalities in Sitecore.

Today I had a short conversation with a partner and later on one of our core developers about the page editor. It seems that we can accelerate very quickly when you express what your thoughts are.

It’s also a big compliment to our core team. These highly skilled guys are able to look through the bush and discover real life issues. It requires a high level of abstraction but also a deep insight in daily issues at our partners and customers.

Please keep the suggestions coming. I try to direct them. Likewise will Lars and Darren. And when I’m talking about suggestions, don’t stick to API changes, also higher level opinions such as documentation or development strategies are welcome. Feel absolutely free to contact us either using email(adg-at-sc-net), Twitter or any other media.

That’s it for this morning. Have a great day, I’ll have a great coffee :).

CMIS, my vision

Today I represent (as usual) my personal vision. I tell this once again, just to be sure that my personal vision won’t become Sitecore’s public vision :).

This morning while I was running through my task list I decided to share this on my twitter account:
Thinking about my CMIS proposal for product management: can WCM really benefit from an ECM(mostly DM) standard?!

I see it as one of my primary responsibilities inside Sitecore to inform product management about changes in our world of content management. Most of the time they’ve already added something similar on the roadmap, but it’s good to have my input. I talk on daily base with our implementation partners and customers, they do not always get that chance.

After a while, a couple of reactions showed up. John Newton, one of the founders of Alfresco replied to me and so did some others. It shows how constructive a tool like Twitter can be, but more important, how hot this topic is.

JBoye just posted a blogpost(also a reaction) about what they think customers should do an not do at this moment. I agree with them to some level, but only if you include the reactions in your vision.

But let’s get back! What is CMIS? It is a standard for communicating between different ECM installations. There’s a big need for the possibility to interexchange documents including metadata between these systems. These documents often have a lot of metadata and also their folder structure tells a lot about their semantics. As every vendor has its own idea about how to store this data, it is very important to have an common format for communication otherwise exchange of documents becomes impossible or very expensive.

(This is of course a simplified view on CMIS. It does include the state where a document is in and lots of other features. Some more or less important.)

The evolution of having such a ‘protocol’ and to see the different vendors talking about these things is a very good step. As vendors ECM, DM and WCM have to deal with all kinds of different standard. Most of them are very technical, take for example Web services, RSS, Atom, WebDAV, etc. Most of them are also not intended to become a standard in our particular space of issue solving. Which means that they are too general or too domain specific to integrate tight with a system like Sitecore.

The question is now what value CMIS brings to WCM. WCM is not document minded and often it does not focus at all on storing document. Looking at today’s Web pages, you often see that companies try not to deliver to many documents on their websites. Which is a good move, as it improves usability. But CMIS is not just about PDFs or Word documents. It does include movies, illustrating images and results of collaborated documents as well.

As soon as the standard will reach its public stages, we as Sitecore, but all the purely WCM vendors should definitely start supporting this standard. But not as a content producer. ECM and DM will continue to focus on creating documents. Although WCM can deliver this, their main target is a markup languages. WCM is very good in producing (X)HTML, XML and image manipulation. Its strength is definitely not creating PDFs or so. Most WCM vendors are capable of doing it technically, but they cannot facilitate the quality process steps ECM can.

Therefore it doesn’t make a lot of sense to integrate the whole standard a producer. But as a consumer it does. Often documents get published out of intranets and other collaboration environments. It does make sense to be able to consume these documents and use them on all kind of web pages.

In some way WCM should support the production side as well. WCM has a real strong relation minded structure. This means that content tagging, inter-content-relations and other ways of categorizing are available out of the box. Why not use this data back to feed the ECM again? Looking at the world of web 2.0, you often see the end consumer(also known as website visitor) does tag/rate content. This information is highly interesting for the content producer.

On the other hand that’s also the challenge for WCM. Because of our nature in linking data to each other, you can harder define a single asset. That’s a pity as you have to define, in my suggestion above, if user generated content is a property of a certain asset or not.

As you have seen above, I see a lot of value in CMIS for WCM. But we should keep in mind that the standard is still a draft. When the final version is there Sitecore and all the other WCM should start to support it as a data consumer(once again: my opinion). It will decrease the investment for companies to get their back office to communicate to the front-end. Which is always a great step. Beside of that it can decrease the time to market for certain information and allows team to gather feedback from the web(depending on the implementation and the product visions of both vendors: ECM & WCM).
It also shows how separated WCM can be from ECM. This discussion wasn’t ongoing when ECM had incorporated WCM totally.

The acceptance of the standard can highly benefit from a toolset developed for the different platforms. I would highly support the idea of having Microsoft (.NET) and Sun (Java) writing the communication layer as a library. The specific implementation can be completed by every individual vendor. But this communication part shouldn’t take to much time from every individual vendor, reinventing the wheel.
It doesn’t matter if it are Microsoft and Sun or if it becomes an open source project. As long a the biggest vendors doe support this open source solution as well and give an indication of it’s quality.

This whole CMIS standard, all the attention and discussion around it will hopefully open the discussion for standardizing WCM solutions as well. Similar to DM I think that it would be good to come to an exchange format which allows WCMS’s to exchange data but in a more specific way than RSS and Atom do these day. A big lack of these formats are internal linking and once again document support. Also, you’re strictly bounded to a set of predefined data.

But that’s a total different discussion. Hopefully this posting explains a lot to you. I’m sure I haven’t covered all parts of CMIS and also haven’t spoken about all the business opportunities WCM can get out of it. But I’ll leave that up to the imagination of you, my reader and commenter.
It’s time now to get this in more in-depth and slightly more technical to product management :).

Sitecore and SSL

As a Solution Architect in Sitecore you often get request ‘howto do SSL in Sitecore’. Beside of our great Shared Source SSL module, you’ve to do something on configuring the network/OS level to register the certificate.

So what’s the general idea of SSL? You want to have certain pages to execute over an encrypted connection. The most feasible solution is SSL which encrypts the data by default using a 128bit encryption. Still pretty strong these days, although I won’t be surprised if we move to 256bit somewhere in 2010. There are several traditional vendors who deliver certificates. In the Netherlands for example KPN. All register their certificates at VeriSign, a party who does take care of the strength of the encryption and the validation of newly created certificates.

Afterwards you’ve to integrate it into Sitecore. A very simple solution is to decide per item if you want to run the constructed page on SSL or not. The Shared Source component takes care of that part.

Now the infrastructure / OS ‘issue’. It seems for a several reasons that running certificates on the web application software(IIS) is very expensive. Combining encryption with page rendering is always possible in every internet server(Apache, Tomcat, IIS, etc), but all have significant disadvantages when it comes to delivery.

I often suggest to rather use a network based solution. These days’ routers, load balancers and switches have the possibility to handle https/ssl for you. As these machines are designed for passing TCP/IP packages thru, they can easily encrypt them. Beside of that, when you run into out scaling scenarios, you don’t have to manage your certificates on multiple places.

Here’s a simple diagram:

SSL Executor

In this case the SSL Executor is a Reversed Proxy, but it can also be a firewall or other network interface.

Hope this helped. 🙂

Note: This is a post written out of my experience as an architect in many projects. I’m involved in general in Sitecore projects, but rarely I’ve got the opportunity to ‘work’ a little outside of this boxed environment. Often these high level problems arise in project where Sitecore is involved but also in other projects. It’s never my intention to blame a vendor, although I might point out some weaknesses.

About Data Driven Websites and Object Relation Modeling

I’ve reinstalled my machine of last night with Windows 7. I’m very happy with this new platform! Thank you Microsoft. One of the final reasons to start yesterday was that my database integration in Visual Studio was broken. Of course there where many more reasons, but that was the issue which made me do it yesterday evening.

So far so good. This morning I started of with a clean and very fast machine. Visual Studio 2008 was ready to roll. I’ve installed the Developer Edition of VSTS yesterday eve.

Today I decided to spent a little bit of time on getting the Entity Framework to work for a small, highly data-driven portal I’ve to develop. One of the issues with the portal is that it should be ready by yesterday. Not so much pressure, but I wanted to be highly productive. Unfortunately I’m highly disappointed.

While we all still claim that simplistic data driven websites should be online in a couple of hours, the truth is the opposite. I’ve got an app where you’ve got users. Users can be in a WorkGroup and some of those these users are leaders of the group. In objects:

  • User.WorkGroups –> List<WorkGroup>
  • WorkGroup.Users –> List<User> –> All users associated, incl leaders.
  • WorkGroup.Leaders –> List<User> –> All leaders

In the database you’ll store this as 3 tables: User, WorkGroup and an AssociationTable with a property ‘IsLeader’ (bit).

The database design was easily made, as I told you before, I decided to use the Entity Framework. But somehow I was absolutely unable to get this to work. I could get the User <-> WorkGroup(many to many relation) to work, but the Leader-relation couldn’t be made without modifying the generated code(or maybe the XML?). 

I’m sure one of you guys will give me the solution how to get this to work. And once again absolutely sure that this is not impossible. But I’m in general wondering why I couldn’t figure this out during the 2 hour R&D I’ve spent on it. The designer doesn’t seem to support something like that. Or it is hidden, somewhere. I’m not sure if this is just a limitation of the Entity Framework or of many O/R mappers.

I do know I generally dislike my whole process. I’ve been switching over and over between the different designers for my entities and database. This makes me wondering. What if this is your daily task? Getting a model designed by business users(interpretation I), normalize this(interpretation II), fit this into an object design(interpretation III) and maybe redo some of these part during one of the stages.

Let’s look from a perspective of a developer. I do not care about the database. It should just be stored. I care about the way I can access the data, so I want to control the types in my entities. My illusion: create a model(we’ve got a language for that: UML). Hit a button, and code + database should be ready.

Optimizations for storage and in the data access code should be done by the generation. The computer is way smarter when it comes to optimizing, it can calc all data access roads and ask if I want to flag more often used data. When I want to create a specific method(for example: GetById) I can define it in OCL.

The solution seems to be so obvious. Why can’t I find such a tool? I can find database generation tools, I can find O/R mappers. I can even find frameworks which should be O/R mappers(isn’t the Entity Framework the framework to be?). But none of these support my vision.

What can I do know? I can use a CMS to store my relational data. All my relational data, maybe thousands of records. I’ve to find a way how to store it internally as CMS’s use all kind of structures, but never a relational one.

I’ll end up in this project using an heavily modified Sitecore installation with lots of custom code to get around the limitations(I’m able to write that quickly as you can imagine). But hopefully you’ve seen my point. I gives me a huge headache in this age of data generation, web service generation for out scaling, advanced cache structures, cloud computing, etc.

Do you got a solution in mind for me?

Note: This is a post written out of my experience as an architect in many projects. I’m involved in general in Sitecore projects, but rarely I’ve got the opportunity to ‘work’ a little outside of this boxed environment. Often these high level problems arise as well in project where Sitecore is involved. I won’t blame a vendor, but I’m wondering why we smart guys are not able to solve issues like productivity without doing concessions on the business requirements.

Solving strange errors when updating more items in hooks

Sometimes when you’re updating item in hooks, you’ll receive strange error messages in the client. The reason for this is quite clear. Sitecore has an event system divided in 2 parts: the regular events such as item:created. The other one is the NotificationContext. This particular class is used by the Sitecore client to get notified before time intensive actions such as event broadcasting is done.
You can use this functionality as well by simply subscribing to the delegates in Sitecore.Context.Notifications.

But what if you’re updating or manipulating your repository triggered by a client action? Exactly, the client has subscribed to a specific action, but when the event will be triggered, a collection has changed or a DataContext is missing. The solution is easy: use Sitecore.Data.BulkUpdataContext in a using statement:

using(new Sitecore.Data.BulkUpdate())

{

//Your update code

}

Nobody gets notified, but important events(configured in the web.config/include files) will get triggered.

Have fun coding!

The world is changing…

You can feel it everywhere! Lord of the Rings starts with these sentences.
So does my new project. I’m not going to reveal anything. But some parts might be interesting for you. On January 1st 2009, I’ll start of with a new website. This website is rather a project then just a single website. It all has to do with Web 2.0, Social Networking, but also Sitecore. It’s all about experiencing what goes around on the web these days. And how to take advantage of it.

On technical side: I’m developing a close integration of Sitecore with all kinds of social networks / web 2.0 services. When I’m talking about close, we’re talking this time about tight! Using Sitecore as data aggregator in several ways. But also a web 2.0  portal and main distribution channel.

Expect my sources to be published on our shared source repository somewhere February. When everything is stable.

More info upcoming later this week.

Show Sitecore how to improve…

Sitecore is alive and kicking. A lot is happening internally on product development. New modules and integrations with technology partners get released at the same speed as Bugatti Veyrons get sold ;). In new (even emerging) markets such as Australia, South Africa, Israel, Asia and New Zealand, Sitecore becomes the standard for Web Marketing.
Yeah that’s right: Web Marketing. More then ever Sitecore becomes a tool for the Marketers. Once again: yes, just the tool. IT grows up, we are more then often just the tool to reach goals. Information goals, conversion goals and even more physical commercial goals such as direct sale.

All of this doesn’t mean that Sitecore forgets where we came from. Very often Lars Fløe Nielsen and I have talks about the incredible number of developers who work with Sitecore, other Sitecore technical numbers like our implementations but also namespaces, classes and methods in our product(s). Both Lars and I are very proud when we look at Sitecore as a company. Almost 50% of our colleagues are involved in Product development. When I’m talking about involved, this doesn’t mean that they contribute code to the repository, but rather talk on a daily base about product directions. We supply our feedback, feeded by our outstanding power team of partners and customers, in a well formed way to product development. In this way there’s no way for them to find excuses for such another outstanding improvement in the product. We provide the exact reason, the pain and possible solution. Together with the right business case supplied by you out there, we’re able to remain world leading in innovative content management :).

This morning in the train I’ve been thinking how to address some of the issues of our developer customer around the world. The guys who are writing and rewriting code on a daily base. A lot of you have made us famous inside your company. So we should listen to you guys as well. Like I said, we try to do this always, but sometimes, it’s good to trigger people. So please! go ahead, react on this post. Tell us what we should do better, what we should different, what’s working what not. I’m particular interested in what makes your process less time intensive and more efficient.
Should we come up with a Visio shape for designing your data? Or should we deliver you a templated WebControl for our advanced types? Is a part undocumented what should be documented? Please let me know.
But please note one thing: I’m looking for feedback, not for a flame war. This is my first try to do this. Hopefully we can start a dialogue more often.

So please go ahead!