需要建议在ColdFusion 9上运行JPA + Hibernate java项目 [英] Need suggestion for running a JPA + Hibernate java project on Coldfusion 9

查看:157
本文介绍了需要建议在ColdFusion 9上运行JPA + Hibernate java项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个java项目,使用JPA 2 / Hibernate 3.5.6进行数据访问,它在JBoss应用服务器上工作得很好。现在我试图在Coldfusion 9环境运行这个,我看到CF 9已经有hibernate3.jar和相关的jar需要它的ORM实现。但是,我想使用我的java项目,因为在CF,我需要相同的hibenate 3.5.6 jar和相关的jar在CF。所以,我移动了所有的jar,我需要,在CF中创建一个新文件夹,并更新了jvm.config包括这个新的路径。它工作大!但现在关注的是,这将与CF9使用的默认Hibernate / ORM行为冲突。这将导致任何其他问题(类加载,冲突等..)?

I have a java project that uses JPA 2/Hibernate 3.5.6 for data access and it works great on a JBoss app server. Now I am trying to run this on a Coldfusion 9 environment and I see CF 9 already has hibernate3.jar and related jars thats needed for its ORM implementation. But, I would like to use my java project as is on CF and for that, I would need the same hibenate 3.5.6 jar and related jars on CF. So, I moved all the jars that I need, created a new folder in CF and updated the jvm.config to include this new path. It worked great!! But now the concern is, will this conflict with the default Hibernate/ORM behaviour that CF9 uses. Would this result in any other issues?(class loading, conflicts etc..)?

选项2:
另外,为了规避任何可能决定创建一个webservice应用程序,打包我需要的所有jar,并将其部署为一个war文件在CF9-JRun4,它工作得很好。在这种情况下,我不必担心clasloading,因为它在web应用程序的范围内。但是,我不希望我的来自CF应用程序的呼叫真的通过一个webservice层,当它所要做的是清楚地访问数据库和获取数据回来。所以我真的想要我的选项1(上一段)工作。

Option 2: Also, to circumvent any "possible" issues I decided to create a webservice application, package all jars that I need and deploy it as a war file on CF9-JRun4, and it worked great. In this case I dont have to worry about clasloading because its within the web application's scope. But, I wouldn't want my calls from CF app really go through a webservice layer, when all it has to do is plainly access the database and get data back. So I would really want my Option 1(previous paragraph) to work.

因此,任何人谁可能已经做过类似的设置之前提供一些洞察这一点。感谢帮助!

So could anyone who might have worked on a similar setup before provide some insight on this. Appreciate the help!

推荐答案

我目前正在准确的设置(spring / hibernate / jpa应用程序在CF应用程序)。唯一的区别是,我在Railo,但我也做了同样的事情与Adobe ColdFusion(ACF)之前。在ACF和Railo,你肯定会遇到带来自己的Hibernate的问题。共识似乎是,只要你不使用它的内置ORM功能,你就不用删除/替换ACF的Hibernate。

I'm currently working on exactly that setup (spring/hibernate/jpa app running within a CF app). The only difference is that I'm on Railo, but I've done the same thing with Adobe ColdFusion (ACF) before also. In both ACF and Railo you can definitely run into problems with bringing your own Hibernate. The consensus seems to be that you'll get away with removing/replacing ACF's Hibernate as long as you're not using it's built-in ORM functionality.

像你一样,我留下看看选项2,不喜欢它非常。
如果你想从正在运行的CF容器正确地分离你的Java应用程序,你应该使用 JavaLoader 。它提供了一个子级第一类加载器,它可以加载您的应用程序中的JAR,并从那里解析类和资源,优先将链提升到ACF中提供的类。

Like you, I was left looking at option 2 and not liking it very much. If you want to properly separate your Java app form the CF container you're running in, you ought to use JavaLoader. It provides a child-first classloader which can load up the JARs in your app and will resolve classes and resources from there in preference to going up the chain to the classes provided in ACF.

我会提到的唯一的问题是,很多现代框架(特别是Spring)使用线程上下文Classloader获取资源,所以你可能需要切换类装载器从你的Java代码构造对象时。这是JavaLoader文档中介绍的,但是值得了解的是,当你的代码呻吟无法从你的JAR等加载属性文件的原因。我倾向于创建一个CFC隐藏了构建Java对象的大量,让你的应用程序代码的其余部分保持简单。您可以查看CFSpreadsheet和此Railo实现特别是类的例子。

The only gotcha I'll mention is that a lot of modern frameworks (Spring in particular) use the thread context Classloader to get at resources so you may need to switch the classloader round when constructing objects from your Java code. This is covered in the JavaLoader documentation, but it's worth knowing that it's likely the cause when your code moans about not being able to load properties files from your JARs etc. I tend to create one CFC which hides the fuss of constructing the Java Objects and lets the rest of your application code stay simple. You could look at the Railo implementation of CFSpreadsheet and this class in particular for an example of that.

希望一切适用于您

这篇关于需要建议在ColdFusion 9上运行JPA + Hibernate java项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆