I have a Tridion 2013SP1 Content Delivery .net web-application. In its global.asax, I am attempting to make a call that requires the JuggerNET bridge to be initialized (e.g. new PageFactoryMeta()).

I tried placing this code in Application_Start:

void Application_Start(object sender, EventArgs e)
    new PageMetaFactory(0);

But it doesn't behave consistently. Occasionally it works, but sometimes it throws the JuggerNET not initialized error:

[Exception: <JavaException>
  <StackTrace><![CDATA[java.lang.ClassNotFoundException: com.tridion.meta.PageMetaFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.codemesh.bootstrap.JarInputStreamBootstrapper.forName(Unknown Source)
   at Codemesh.JuggerNET.JavaClass.ThrowException(Exception ex)
   at Codemesh.JuggerNET.NTypeValue.Throw(Int64 inst)
   at Codemesh.JuggerNET.JavaClass.ThrowTypedException(Int64 inst)
   at Codemesh.JuggerNET.JavaClass.init()
   at Codemesh.JuggerNET.JavaClass.get_JObject()
   at Codemesh.JuggerNET.JavaMethod.init()
   at Codemesh.JuggerNET.JavaMethod.get_MethodPtr()
   at Codemesh.JuggerNET.JavaMethod.get_Handle()
   at Codemesh.JuggerNET.JavaMethod.CallObject(JavaProxy jpo, JavaMethodArguments args)
   at Com.Tridion.Meta.PageMetaFactory..ctor(Int32 publicationId)
   at Tridion.ContentDelivery.Meta.PageMetaFactory..ctor(Int32 publicationId)
   at ASP.global_asax.Application_Start(Object sender, EventArgs e) in c:\_GITHome\ExampleWebsite\Global.asax:line 10]]></StackTrace>

If I put the code in Session_Start, it works fine, but then it will be called every time a new session is created. I don't want that -- it should run only once.

Somewhere in between Application_Start and Session_Start, JuggerNET bridge is initialized. But where exactly?

Where would be the best place to put my code such that it is only executed once, and that is after JuggeNET has been initialized?

  • If you put in session start, can you use a singleton pattern to do it only once? Nov 5, 2016 at 21:39
  • Indeed that would work as workaround. I'm trying to find the 'purest' solution :) Nov 6, 2016 at 4:46
  • You say it throws a "not initialized" error, but the Exception you've pasted is Class not found. Dec 6, 2016 at 8:26

1 Answer 1


Instead of instantiating class object on session_start or application_start, I would recommend using dependency injection IOC container: List of cotainers

We have used Autofac in our implementation.

While registering dependencies with Autofac, specify which class are to be instatiated for each call vs which classes are to be instantiated once per application.

Reference for using autofac to achieve the same

  • 2
    I agree with what you are saying Hiren and that would solve the issue, but I still think it's a workaround :) At the moment I'm kinda of set to understand the lifecycle when JuggerNET bridge is created. Nov 6, 2016 at 19:17
  • @MihaiCădariu If this is workaround then what kind of solution are you looking for? Web is stateless so instantiating something on per application, you will have to use: singleton implementation, application_start, IOC container. Since first option is reducing application scalability and second option application_start not working for you so only option left is IOC container suggested above.
    – Hiren Kaku
    Nov 7, 2016 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.