Lucee doesn't start and fail on "ContextLoaderListener"

We trying to move from ACF 2016 to Lucee 5.3.9 and facing issue (see below) when starting up Lucee.

Our existing appplication run the following:

  1. Java web service
  2. Spring 5.3.4
  3. Hibernate 5.4.28.Final

The issue appears to be failing on “ContextLoaderListener” defined in our web.xml.
Lucee runs if we comment out the listener “ContextLoaderListener”.

I tried the following but it didn’t work.

  1. Moved all JARS to \webapps\WEB-INF\lucee\lib
  2. Moved all JARS to \webapps\WEB-INF\lucee-server\context\lib
  3. Tried converting WAR file as OSGI bundle and dropped into \webapps\WEB-INF\lucee-server\bundles folder
  4. Uninstalled Hibernate extension that is pre-installed with Lucee (thinking that it is causing conflict during runtime).

Anybody have ideas why Lucee is failing during startup? to me it seems like the issue is caused by Lucee’s class loader being used instead of Tomcat’s. Tomcat is aware of the hibernate entities but Lucee’s is not?

Thank you and hoping somebody can shed some light.

2022-04-15T15:40:32,481|39812|Catalina-utility-1|INFO |Version|HHH000412: Hibernate ORM core version 5.4.28.Final
2022-04-15T15:40:32,851|40182|Catalina-utility-1|INFO |JavaReflectionManager|HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-04-15T15:40:33,992|41323|Catalina-utility-1|INFO |Dialect|HHH000400: Using dialect: org.hibernate.dialect.SQLServer2012Dialect
2022-04-15T15:40:34,672|42003|Catalina-utility-1|INFO |Version|HV000001: Hibernate Validator 6.0.22.Final
2022-04-15T15:40:35,180|42511|Catalina-utility-1|INFO |JtaPlatformInitiator|HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform]
2022-04-15 15:40:36,3231|Catalina-utility-1|ERROR|ContextLoader|Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘blockApiServiceImpl’: Unsatisfied dependency expressed through field ‘blockApiDAO’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘blockApiDAO’ defined in com.domain.accommodation.dao.BlockApiDAO defined in : Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.domain.model.HotelsToRoomType
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)

Our stack:

OS: Linux
Java Version: 11
Tomcat Version: 9
Lucee Version: lucee-5.3.9.120-SNAPSHOT.war

I would use stable war, vs snapshot.
I would mirror the same java version and tomcat version in both servers.

You may need look at the java source and recompile, depending on how your code was setup. some folks LOVE to hardcode class paths.

I’m a little confused here as you said this is a Lucee application, but your list appears to be a regular native Java Spring app. Where is the Lucee part of this? In another WAR? Somehow embedded in the Spring WAR? Are you even using a WAR at all? So much missing context here.

To be clear, is Spring trying to use Lucee’s Hibernate bundles, or its own? Do you have Lucee’s ORM extension installed or uninstalled? I see a note that you Uninstalled Hibernate extension that is pre-installed with Lucee though I’m not clear whether you were intending to use the jars in that extension or not.

Can you be more specific? Is this a web.xml you created from scratch, or a stock Lucee web.xml you’ve modified? What’s in it?

To be clear, is Lucee itself erroring out, or is your Spring app simply having an error of its own which aborts the startup of the WAR, and therefore the startup of anything else being loaded including Lucee? It’s not clear here whether you’re saying a side effect of your Spring app is making Lucee not work, or if Lucee is just an innocent bystander trapped in a doomed WAR with unrelated issues.

And again-- can you be more clear? is this your ContextLoaderListener or something Lucee has defined?

Is “Lucee” failing though? The error you posted doesn’t even mention Lucee and the stack trace isn’t even coming from any class inside or or related to Lucee (it also appears you may have truncated the stack trace which doesn’t help us)

What makes you say that? I’m not saying it’s not possible, I don’t just see anything in the evidence you presented that would make me think Lucee is involved.

I’m not sure what this even means. Neither Tomcat proper nor Lucee directly interact at all with Java-based Hibernate Entities. That’s a concern of the Hibernate library. I don’t even see evidence of classloading being an issue. Here is the actual root cause of the exception:

Not a managed type: class com.domain.model.HotelsToRoomType

This is an error coming from your Hibernate library inside of Spring. I see nothing related to Lucee here. If you Google “Not a managed type”, you’ll find several hits on StackOverflow that suggest your Spring application is misconfigured.

Thanks so much guys!

@Terry_Whitney I tried using the stable WAR but it doesn’t work so I am trying the latest snapshot as a test.

@bdw429s, our application is written in ACF and utilizing Java spring app. Our existing setup is running ACF via JEE configuration so we are using ACF WAR file. Now trying to use Lucee WAR file.

In Spring, we are trying to use Hibernate as separate dependency and not using Lucee hibernate bundle. I just suspect that it might probably be causing conflict so I tried to uninstall it.

As for web.xml, it was a modified Lucee web.xml with our Spring services.

Lucee is not erroring out I guess because commenting out the listener works fine (I can open up Lucee Admin and able to run some CF codes). Spring app simply having an error of its own which aborts the startup of the WAR.

Not an experienced Java guy here and just trying to make it work with the existing working ACF setup to Lucee without having to refactor existing Java app, so I believe I am lost as to what is happening during startup.

Mirror everything first.

You more than likely are going to have to reconfigure or rewrite the spring boot services piece.

Its not as hard or as bad as it sounds, but spring boot is a framework designed to be an all-in-one framework, which on many platforms requires an investment to keep running securely.

This is why I would suggest roll up your sleeves and convert that chunk of code to ColdFusion, and only what you need from it.

You could try to get that piece to work, mess with mappings, spend time, money and resources fixing a closed app, only to spend more time and resources updating the app every time there is a security issue with it, or you can convert it to open source coldfusion and then only spend time updating your servers core application server and underlying infrastructure.

As for the app, most java applications that span thousands of lines of code can be done in coldfusion in less than a thousand lines.

Really, just have to wrap your head around how Java conceptually works and the conversion will go quickly.

2 Likes

+1 for converting the Spring app to good old CFML to make your life easier :slight_smile:

That said, I think you just have a Hibernate specific issue going on where it’s not finding your entities. I’d go down that rabbit hole first and assume Lucee probably isn’t related. In ACF 2018 and before, the Hibernate jars were baked into the WAR so it’s possible some things were working by accident. I would suspect you’d want all the jars for your Spring app and your own Hibernate version all inside of the WEB-INF/lib folder just like a “normal” WAR and not inside any of the internal Lucee folders. They would be along-side the Lucee.jar basically. The servlet container (Tomcat) loads the WAR’s libs with a dedicated class loader for the deployment. Do some research on that Not a managed type error and see if there’s just some configuration for Hibernate missing somewhere. I know Hibernate has tons of logging you can enable via Log4j categories.

1 Like

Very informative. Thank you so much!