JBoss 上的 Oracle ADF:Wrapped Jdbc 连接问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/277665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle ADF on JBoss: Wrapped Jdbc Connection problem
提问by ebirkenes
I'm trying to run an application using Oracle ADF Business Components on a JBoss Server. I've maneged to deploy it, but when I try to load the page I get below exception:
我正在尝试在 JBoss 服务器上使用 Oracle ADF 业务组件运行应用程序。我已经设法部署它,但是当我尝试加载页面时,出现以下异常:
java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection
Is there a way solve this? Maybe configure JBoss to not use this wrapped connection or configure the ADF framework to unwrap it?
有没有办法解决这个问题?也许配置 JBoss 不使用这个包装的连接或配置 ADF 框架来解包它?
采纳答案by ebirkenes
This is a while back, but I'll just follow up on my own question.
这是一段时间以前,但我会跟进我自己的问题。
There is a guide on Oracle Metalink(Needs login) wich explains how to deploy ADF/BC on JBoss. I'm pretty sure this is what solved this for me (it's a while ago..)
有一个关于Oracle Metalink(需要登录)的指南,其中解释了如何在 JBoss 上部署 ADF/BC。我很确定这就是为我解决这个问题的原因(这是前一段时间......)
Here is a copy of it:
这是它的副本:
Abstract
The purpose of this note is to show how you create an ADF BC Application Module and how you deploy it on a JBoss Application Server. It will also show you what configurations you need to perform on the JBoss side in order for the Application Module to work correctly.
摘要
本说明的目的是展示如何创建 ADF BC 应用程序模块以及如何将其部署在 JBoss 应用程序服务器上。它还将显示您需要在 JBoss 端执行哪些配置才能使应用程序模块正常工作。
Scope & Application
This note is intended for anyone who is about to deploy an ADF BC Module to a JBoss Application Server.
范围和应用
本说明适用于将 ADF BC 模块部署到 JBoss 应用服务器的任何人。
How To Deploy an ADF BC Module to a JBoss Application Server
The steps necessary for deploying an ADF BC Module to a JBoss Application Server are the following:
如何将 ADF BC 模块部署到 JBoss 应用服务器
将ADF BC 模块部署到 JBoss 应用服务器所需的步骤如下:
- Setup the ADF Runtime Libraries on the JBoss Server
- Setup data source(s) on the JBoss Server
- Configure the ADF BC Module
- Deploy the ADF BC Module
- 在 JBoss 服务器上设置 ADF 运行时库
- 在 JBoss 服务器上设置数据源
- 配置 ADF BC 模块
- 部署 ADF BC 模块
I will go through each of these steps more detailed. There is also a complete example attached for download here. Setup the ADF Runtime Libraries on the JBoss Server
我将更详细地介绍每个步骤。这里还有一个完整的示例可供下载。在 JBoss 服务器上设置 ADF 运行时库
- Shutdown the Application Server.
- Invoke the ADF Runtime Installer wizard. Choose Tools | ADF Runtime Installer, and choose a server type from the submenu.
- Proceed through the pages of the wizard. For detailed instructions for any page of the wizard, click Help.
- On the Location page, select the home (or root) directory of the server on which the libraries are to be installed.
- On the Installation Options page, you may choose the operation that you wish to perform. * Install the ADF runtime libraries from your JDeveloper installation. * Uninstall previously installed ADF runtime libraries. * Restore an archived version of the ADF runtime libraries as the active version.
- On the Summary page, click Migrate if you wish to prepare any existing UIX JSP projects for deployment.
- On the Summary page, confirm the details of the installation, and click Finish.
- Restart the application server.
- 关闭应用程序服务器。
- 调用 ADF 运行时安装程序向导。选择工具 | ADF 运行时安装程序,然后从子菜单中选择服务器类型。
- 继续浏览向导页面。有关向导任何页面的详细说明,请单击“帮助”。
- 在“位置”页面上,选择要安装库的服务器的主(或根)目录。
- 在“安装选项”页面上,您可以选择要执行的操作。* 从 JDeveloper 安装中安装 ADF 运行时库。* 卸载以前安装的 ADF 运行时库。* 将 ADF 运行时库的存档版本恢复为活动版本。
- 在摘要页面上,如果您希望准备任何现有的 UIX JSP 项目以进行部署,请单击迁移。
- 在“摘要”页面上,确认安装的详细信息,然后单击“完成”。
- 重启应用服务器。
Setup data source(s) on the JBoss Server
To create an Oracle data source in the JBoss server, you need to take the following steps:
在 JBoss 服务器上设置数据源
要在 JBoss 服务器中创建 Oracle 数据源,您需要执行以下步骤:
Create a file called oracle-ds.xml. This file will contain your data source configuration. Below is an example on how such a file can look like.
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>OracleDS</jndi-name> <use-java-context>false</use-java-context> <connection-url>jdbc:oracle:thin:@mydbhost.com:1521:mysid</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <user-name>hr</user-name> <password>******</password> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> </local-tx-datasource> </datasources>
Copy the file to the /deploy. This will install it on the JBoss server.
创建一个名为 oracle-ds.xml 的文件。此文件将包含您的数据源配置。下面是有关此类文件外观的示例。
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>OracleDS</jndi-name> <use-java-context>false</use-java-context> <connection-url>jdbc:oracle:thin:@mydbhost.com:1521:mysid</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <user-name>hr</user-name> <password>******</password> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> </local-tx-datasource> </datasources>
将文件复制到 /deploy。这会将它安装在 JBoss 服务器上。
Configure the ADF BC Module
There are a few steps that need to be taken upon the ADF BC Module in order for it to run on the JBoss server.
配置 ADF BC 模块
需要对ADF BC 模块执行几个步骤才能使其在 JBoss 服务器上运行。
When creating an ADF BC Module that will be used on a JBoss application server, one needs to set the SQL Flavor to SQL92 and the Type Map to Java. This change is required when using JBoss as the Application Server.
创建将在 JBoss 应用服务器上使用的 ADF BC 模块时,需要将 SQL Flavor 设置为 SQL92,将类型映射设置为 Java。使用 JBoss 作为应用程序服务器时需要进行此更改。
****Package the ADF Business Components project as an EJB session bean.****
****将 ADF 业务组件项目打包为 EJB 会话 bean。****
- Right Click on the Application Module, select Business Components Deployment.
- In the profiles Dialog, select EJB Session Beans.
- In the EJB Session Beans dialog, select Deploy To: Other EJB Container
- In the AppModules dialog, configure the Application Module as seen in the figure 1 below.
- 右键单击应用程序模块,选择业务组件部署。
- 在配置文件对话框中,选择 EJB Session Beans。
- 在 EJB Session Beans 对话框中,选择 Deploy To: Other EJB Container
- 在 AppModules 对话框中,配置应用程序模块,如下图 1 所示。
Figure 1. Configuration of the Application Module
图 1. 应用模块的配置
Once done, your Project will look similar to the one shown in the figure 2 below.
完成后,您的项目将类似于下图 2 中所示的项目。
Figure 2. The JDeveloper Project
图 2. JDeveloper 项目
The final step is to configure the Application Module to use the data source we created in the previous step. This is done as follows:
最后一步是配置应用程序模块以使用我们在上一步中创建的数据源。这是按如下方式完成的:
- Edit the application module.
- In the Navigator, right-click the Business Components application module icon and choose Configurations.
- Select the appropriate configuration.
- Select this configuration and click Edit.
- In the Connection Type list, choose JDBC DataSource.
- Enter a DataSource Name. For example: java:/OracleDS.
- 编辑应用程序模块。
- 在导航器中,右键单击业务组件应用程序模块图标并选择配置。
- 选择合适的配置。
- 选择此配置并单击编辑。
- 在连接类型列表中,选择 JDBC 数据源。
- 输入数据源名称。例如:java:/OracleDS。
Deploy the ADF BC Module
If you have your JBoss server either locally or mapped on your local machine, you can deploy it directly from inside JDeveloper. If your JBoss server is remote, and not mapped to the local machine, or you have a JSP application that later will use this module, you cannot deploy it directly from within JDeveloper. Both methods are described below.
部署 ADF BC 模块
如果您的 JBoss 服务器在本地或映射到本地机器上,您可以直接从 JDeveloper 内部部署它。如果您的 JBoss 服务器是远程的,并且没有映射到本地机器,或者您有一个稍后将使用此模块的 JSP 应用程序,则您不能直接从 JDeveloper 中部署它。下面介绍这两种方法。
Deploying the Module from within JDeveloper
1. Create a connection to the target application server.
2. If you want to support JBoss-specific configuration options for the EJB, add a jboss.xml deployment descriptor file. For more information on this file, see http://www.jboss.org.
3. If your project is a Business Components UIX JSP project, add required Cabo resources to it.
4. Select the deployment profile in the Navigator, right-click, and choose Deploy to | < application server connection> to package the application as an archive file and deploy it via the selected application server connection.
从 JDeveloper 中部署模块
1. 创建到目标应用程序服务器的连接。2. 如果要支持 EJB 的 JBoss 特定配置选项,请添加 jboss.xml 部署描述符文件。有关此文件的更多信息,请参阅http://www.jboss.org。3. 如果您的项目是业务组件 UIX JSP 项目,请向其中添加所需的 Cabo 资源。4. 在导航器中选择部署配置文件,右键单击,然后选择部署到 | <应用程序服务器连接> 将应用程序打包为存档文件并通过选定的应用程序服务器连接进行部署。
Deploying the Module outside of JDeveloper
If your JBoss server is remote, and not mapped to the local machine, or you have a JSP application that later will use this module you will have to do as follows:
在 JDeveloper 之外部署模块
如果您的 JBoss 服务器是远程的,并且没有映射到本地机器,或者您有一个稍后将使用此模块的 JSP 应用程序,您将必须执行以下操作:
- Choose Deploy to EAR file from the context menu to deploy it as an EAR file. You must deploy this application to an EAR file and not a WAR file, as JBoss will not add the EJB references under the java:comp/env/ JNDI namespace for a WAR file.
- Copy this file manually to the /deploy directory.
- 从上下文菜单中选择部署到 EAR 文件以将其部署为 EAR 文件。您必须将此应用程序部署到 EAR 文件而不是 WAR 文件,因为 JBoss 不会在 java:comp/env/ JNDI 命名空间下为 WAR 文件添加 EJB 引用。
- 手动将此文件复制到 /deploy 目录。