Skip to main content
Participant
February 15, 2022
Answered

Migration CF11 to CF21

  • February 15, 2022
  • 1 reply
  • 545 views

I'm trying to migrate from cf11 to cf21 and I'm getting a series of errors which I assume are related to hibernate.

I already tried to use the .car generated in cf11 for cf21....

this is the entire stack trace:

java.lang.NullPointerException at com.sun.xml.bind.v2.runtime.unmarshaller.StAXConnector$1.getPublicId(StAXConnector.java:101) at org.apache.xerces.util.SAXLocatorWrapper.getPublicId(Unknown Source) at org.apache.xerces.xni.parser.XMLParseException.<init>(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source) at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown Source) at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:101) at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75) at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.handleStartElement(StAXEventConnector.java:261) at com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:130) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:460) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:435) at org.hibernate.boot.jaxb.internal.AbstractBinder.jaxb(AbstractBinder.java:171) at org.hibernate.boot.jaxb.internal.MappingBinder.doBind(MappingBinder.java:61) at org.hibernate.boot.jaxb.internal.AbstractBinder.doBind(AbstractBinder.java:102) at org.hibernate.boot.jaxb.internal.AbstractBinder.bind(AbstractBinder.java:84) at org.hibernate.boot.jaxb.internal.JaxpSourceXmlSource.doBind(JaxpSourceXmlSource.java:29) at org.hibernate.boot.MetadataSources.addDocument(MetadataSources.java:409) at org.hibernate.cfg.Configuration.addDocument(Configuration.java:462) at coldfusion.orm.hibernate.HibernateConfiguration.buildConfiguration(HibernateConfiguration.java:647) at coldfusion.orm.hibernate.HibernateConfiguration.initHibernateConfiguration(HibernateConfiguration.java:213) at coldfusion.orm.hibernate.HibernateConfiguration.<init>(HibernateConfiguration.java:186) at coldfusion.orm.hibernate.ConfigurationManager.initConfiguration(ConfigurationManager.java:68) at coldfusion.orm.hibernate.HibernateProvider.initializeORMForApplication(HibernateProvider.java:168) at coldfusion.orm.hibernate.HibernateProvider.beforeApplicationStart(HibernateProvider.java:77) at coldfusion.filter.ApplicationFilter.fireBeforeAppStartEvent(ApplicationFilter.java:819) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:433) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:43) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:162) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:97) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:60) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:231) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:311) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:228) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:46) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:47) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) at coldfusion.inspect.weinre.MobileDeviceDomInspectionFilter.doFilter(MobileDeviceDomInspectionFilter.java:121) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:47) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:373) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1723) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)

I noticed that in cf11 I have many libs that in cf21 I didn't find in the cf_root/lib folder, including files from hibernate itself, so I copied these .jar to cf21 and still no success....
these are the hibernate files I tried to copy to cf21:

hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.10.Final.jar
hibernate-ehcache-4.1.10.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
dpHibernate.jar

I've also tried to remove from the jvm the "all-unnamed" statements seen in other forums....


this is a small example of the application file ->

component
  output = "false"
  hint   = "xxxx"
{
  this.baseDirectory            = getDirectoryFromPath(getCurrentTemplatePath());
  this.name                     = "xxxxxx";
  this.sessionManagement        = true;
  this.applicationTimeout       = createTimeSpan(2,0,0,0);
  this.sessionTimeout           = createTimeSpan(0,0,30,0);

  this.mappings[ "/app" ]       = (this.baseDirectory & "app/");
  this.mappings[ "/component" ] = (this.baseDirectory & "component/");
  this.mappings[ "/config" ]    = (this.baseDirectory & "config/");
  this.mappings[ "/src" ]       = (this.baseDirectory & "src/");
  this.mappings[ "/web" ]       = (this.baseDirectory & "web/");

  this.ormEnabled               = true;
  this.datasource               = "xxxxxxxxx";
  this.ormSettings              = {
    cfclocation       = "src",
    dialect           = "Oracle10g",
    namingStrategy    = "app.DataBaseNameStrategy",
    logSQL            = false,
    automanageSession = false,
    flushatrequestend = false,

    secondaryCacheEnabled = false,

    autogenmap = true,
    savemapping = true,
    useDBForMapping = true
  };
......................................
And this is a small example of the generated .hbmxml of an entity ->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="CidadeEntity" lazy="true"
name="cfc.api.src.AdminBundle.entity.CidadeEntity" table="XXXXX">
<id name="codigo" type="integer">
<column name="CODIGO"/>
<generator class="sequence">
<param name="sequence">SEQ_XXXX</param>
</generator>
</id>
<property name="nome" type="string">
<column length="255" name="NOME"/>
</property>
<many-to-one class="cfc.api.src.AdminBundle.entity.EstadoEntity"
column="FK_ESTADO" name="estado"/>
</class>
</hibernate-mapping>


does anyone have any directions?






This topic has been closed for replies.
Correct answer Jonathan CR

The cause of the error may be that the hbmxml file is not valid. Was it perhaps generated in CF11? If so, that would explain it. Similar errors on the web resulted from a breaking-change in Hibernate 5.2, for example,

https://discourse.hibernate.org/t/getting-npe-while-using-cache-usage-read-only-in-hbmxml-in-hibernate-5-2-11/4730

 

Do the following test. After backing up the hbmxml file elsewhere, delete it from ColdFusion. Then get ColdFusion 2021 to generate a new hbmxml file. Does that help?


It worked!

after a lot of suffering, and a lot of refactoring, the more than 400 cfc files came back to life!

I had to manually adjust some (many) files generated by hibernate (.hbmxml)...

I noticed that the new errors that were appearing were referring to 'finding' a particular 'entity'

so I standardized all the "name" attributes of the first class tag inside the .hbmxml files ->

<hibernate-mapping>
    <class NAME

And I also adjusted the relationships (many-to-one, etc...) by changing the "class" attribute, for entities in the same folder I used the entity name directly, and for entities in other folders I used mapping for this, for example:

  • root
    • file A
      • FisrtEntity.cfc
      • SecondEntity.cfc
    • file B
      • ThreeEntity.cfc
      • FourEntity.cfc

 

in FirstEntity.hbmxml ->

<bag name="test">
    <key column="FK_TEST"/>
    <one-to-many class="SecondEntityEntity"/>
<bag name="test2">
    <key column="FK_TEST2"/>
    <one-to-many class="root.fileB.ThreeEntity"/>

1 reply

BKBK
Community Expert
Community Expert
February 16, 2022

I agree with you that the error relates to Hibernate. But note that, as from CF2021, there is a big change in the location of Java libraries in ColdFusion. Many libraries that used to be in the cf_root/lib folder are no longer there.

 

They are now bundled as parts of packages and are located in /ColdFusion2021/bundles/. For example, Hibernate libraries are now parts of packages /ColdFusion2021/bundles/orm***.jar.  

 

So, there was no need for you to copy any Jar files or to modify jvm.config. I would suggest that you return the CF2021 installation to the state it was in before you made those changes. 

 

Once you are done, restart CF2021. We shall then begin the discussion from there.

Participant
February 17, 2022

I reinstalled CF21 yesterday, and the only lib addition I did was ojdbc8.jar to create a connection to the sql server database....

I still have the exact same stack trace of errors...
###############################################################################

The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values.
 
Resources:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.
Browser  	Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Remote Address  	127.0.0.1
Referrer  	
Date/Time  	17-Feb-22 08:46 AM
Stack Trace


java.lang.NullPointerException
	at com.sun.xml.bind.v2.runtime.unmarshaller.StAXConnector$1.getPublicId(StAXConnector.java:101)
	at org.apache.xerces.util.SAXLocatorWrapper.getPublicId(Unknown Source)
	at org.apache.xerces.xni.parser.XMLParseException.<init>(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source).........




##################################################################################

I tried to run the project with as few entities as possible, and it worked!

however it is a legacy project where there are more than 400 .cfc files, and there are many relationships, so I can't go "entering 1 by 1" to see where the error occurs....

And the problem is that this stack trace does not say in which file or when the error occurred.... It would be easier to debug....



BKBK
Community Expert
Community Expert
February 17, 2022

The cause of the error may be that the hbmxml file is not valid. Was it perhaps generated in CF11? If so, that would explain it. Similar errors on the web resulted from a breaking-change in Hibernate 5.2, for example,

https://discourse.hibernate.org/t/getting-npe-while-using-cache-usage-read-only-in-hbmxml-in-hibernate-5-2-11/4730

 

Do the following test. After backing up the hbmxml file elsewhere, delete it from ColdFusion. Then get ColdFusion 2021 to generate a new hbmxml file. Does that help?