Hibernate的JNDI绑定分析

Redis从入门到精通专栏大纲 设计原则:Redis使用的黄金法则性能优化:生产环境调优checklist安全加固:Redis安全配置指南团队协作:Redis开发和运维规范。 阅读详情
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> Hibernate的JNDI名称绑定是在net.sf.hibernate.impl.SessionFactoryObjectFactory程序里面实现的,我来分析一下Hibernate的绑定JNDI的过程:   我们获得SessionFactory一般是这样写代码: Configuration conf = new Configuration().addClass(Cat.class); SessionFactory sf = conf.buildSessionFactory();   首先是new Configuration()创建一个Configuration,在这个构造器里面进行配置文件(hibernate.properties)的读取工作,然后保存到一个Properties对象里面去,和JNDI相关的是这个属性: hibernate.session_factory_name hibernate/session_factory   接着调用buildSessionFactory()方法,该方法检查一下配置信息,然后调用SessionFactoryImpl的一个构造器。在构造器里面注意下面两行代码: name = properties.getProperty(Environment.SESSION_FACTORY_NAME); SessionFactoryObjectFactory.addInstance(uuid, name, this, properties);   调用了SessionFactoryObjectFactory的addInstance方法,并且把自身(SessionFactory的实例)作为参数传递。最后在addInstance方法可以看到如下代码: Context ctx = NamingHelper.getInitialContext(properties); NamingHelper.bind(ctx, name, instance);   instance 就是SessionFactory的实例,通过读源代码,可以清楚的看到Hibernate是在conf.buildSessionFactory()的时候通过一系列类方法调用,把创建的SessionFactory实例绑定到配置文件(hibernate.properties)中 hibernate.session_factory_name属性指定的名称上的,因此可见Hibernate自身是具有JNDI的动态绑定功能的。但是Hibernate需要获得一个SessionFactory实例用于绑定,而这个SessionFactory实例需要我们写代码进行预先创建,并且必须保证该过程要在所有其它要从JNDI上获得SessionFactory实例的程序之前完成。   因此对于任何App Server来说,我们都不必去管JNDI名称的绑定过程,只需要保证预先创建一个SessionFactory实例出来就够了,剩下的工作 Hibernate会做的。那么如何确保预创建SessionFactory实例呢,如果是Servlet,可以配置一个初始化的Servlet,只要把 Configuration conf = new Configuration().addClass(Cat.class); SessionFactory sf = conf.buildSessionFactory();   这样的代码加进去就可以了。如果是包含EJB的的复杂的J2EE应用,可能需要依靠App Server的功能来保证预创建SessionFactory实例。
【100%通过率】华为OD机试真题 Python 实现【水库蓄水问题】【2022.11 Q4 新题】 给定一个长度为 n 的整数数组height。数组的元素表示山的高度,选择两个元素作为水库的边界,求蓄水量的最大值并输出蓄水量最大时的边界下标(蓄水量相同时输出下标较近的)。 阅读详情

相关推荐

【MCU】一种基于RTOS的无应答重发机制

文章目录一、背景描述二、结构框图三、基于RTOS的信号量的实现(3-1)思路描述(3-2)步骤(3-2-1)定义超时重发信号量(3-2-2)定义发送线程入口(3-2-3)定义接收线程入口四、基于定时器的实现(4-1)思路描述(4-2)步骤(4-2-1)创建定时器(4-2-2)定义定时器超时处理函数(4-2-3)定义发送线程入口(4-2-4)定义接收线程入口 一、背景描述 ​ 在微控制器之间进行数据通信时,大多需要添加无应答重发机制,以增强数据交互和通信的稳定性。 在使用UART通信的双方设备,当一次数据传输

iriczhao的博客 1524

通过DataSource创建新的数据库连接

 package com.songbx;import java.sql.Connection;import java.sql.SQLException;import java.util.Properties;import javax.naming.Context;import javax.naming.Name;import javax.naming.NameNot

kubete的专栏 2951

【Allegro学习笔记】常规标贴封装创建-0402封装创建实例

摘要 本文主要介绍如何使用Allegro制作表面贴装封装。 所使用的软件 使用Allegro制作常规贴片封装主要使用的软件有Pad Designer和Allegro 1 0402类封装制作 1.1 0402类封装焊盘分析 0402封装尺寸图如图1...

Honglong 1万+

EJB3.0中JNDI的绑定和多通路传输

http://blog.csdn.net/yiboo/article/details/263869 EJB3.0中JNDI的绑定和多通路传输 默认的会话bean会以路径或远程接口的全名绑定到JNDI。你可以通过定义你自己的@org.jboss.ejb3.LocalBinding或@org.jboss.ejb3.remoting.RemoteBinding来修改 本地接口的JNDI

天元喜羊羊的博客 1636

使用 Restart Extension 继续解决 Ansys 机械分析

您正在执行复杂或大型的多步有限元分析,突然,您意识到经过数小时的求解后,您需要添加或修改边界条件。在本篇博文中,您将了解如何利用 Ansys Mechanical 中的 RestartAnalysis 扩展来扩展多步分析,方法是合并额外的时间步骤和边界条件,而不会丢失已计算的结果。幸运的是,在 Mechanical 中,有一种直接的方法可以实现这一点,而不会损害您之前的结果,而这在添加新边界条件和使用重新启动点时经常发生。得到的结果符合预期,您可以看到施加的力产生的这两个部分之间的相对位移。

jkh920184196的博客 1238

游戏脚本开发避坑:Python调用OP模块实现阴阳师后台操作的5个关键点

本文深入探讨了使用Python调用OP模块开发《阴阳师》后台自动化脚本的5个核心避坑点。重点解析了窗口绑定、后台截图与图像识别、鼠标键盘模拟、脚本稳定性以及性能优化等关键环节的常见问题与实战解决方案,帮助开发者高效实现稳定的游戏后台挂机功能。

u0v1w2x3的博客 598

Hibernate的JNDI名称绑定分析

Hibernate的JNDI名称绑定是在net.sf.hibernate.impl.SessionFactoryObjectFactory程序里面实现的,我来分析一下Hibernate的绑定JNDI的过程:   我们获得SessionFactory一般是这样写代码:   Configuration conf = new Configuration()。addClass(Cat.class...

fengxiushuying的专栏 176

Memory SystemsCache, DRAM, Disk翻译学习DRAM部分(二)

DRAM 的发展史

qq_33473931的博客 1001

org.hibernate.engine.jndi.JndiException:Error parsing JNDI name[foo]

1、错误描述 WARN:HHH00027:Could not bind factory to JNDI org.hibernate.engine.jndi.JndiException:Error parsing JNDI name[foo] Caused by:javax.naming.NoInitialContextException:Need to specify class name ...

牛栏山矿泉水 369

DeepSeek与豆包无缝对接:5分钟搞定智能周报自动化(附完整代码)

本文详细介绍了如何利用DeepSeek与豆包API,快速搭建一个智能周报自动化系统。通过整合豆包平台的工作流数据,并调用DeepSeek大模型进行深度分析与内容生成,该系统能在5分钟内自动抓取、分析多源信息,并生成结构清晰、富有洞察力的团队周报,显著提升工作效率。

weixin_29029995的博客 502

【大模型】Coze AI 智能体工作流从配置到使用实战详解

Coze 扣子智能体工作流从配置到使用实战详解

congge 1万+

WARN: HHH000277: Could not bind factory to JNDI

WARN: HHH000277: Could not bind factory to JNDI WARN: HHH000277: Could not bind factory to JNDIorg.hibernate.engine.jndi.JndiException: Error parsing JNDI name [foo] at org....

weixin_30409849的博客 233

Unet++改进33:添加ConvolutionalGLU(2024最新改进方法)|紧凑的网络结构和高效的运算

由于残差连接的深度退化效应,许多依赖堆叠层进行信息交换的高效视觉变形模型往往不能形成足够的信息混合,导致视觉感知不自然。为了解决这个问题,在本文中,我们提出了聚合注意力,这是一种基于仿生设计的令牌混合器,它模拟生物中央凹视觉和连续眼运动,同时使特征映射上的每个令牌具有全局感知。此外,我们结合了可学习的令牌,与传统的查询和键交互,这进一步多样化了亲和矩阵的生成,而不仅仅依赖于查询和键之间的相似性。我们的方法不依赖于堆叠进行信息交换,从而有效地避免了深度退化,实现了自然的视觉感知。

AIcurator的博客 689

YL电厂WAS系统错误诊断日志分析

WAS系统垮了,客户疯了,又有事情做了!!! 分析了日志文件 Native_stderr.log Native_stdiut.log Server1.pid Startserver.log Stopserver.log ...

chenqunan3231的博客 150

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

绑定SessionFactory到JNDI

假若你希望把SessionFactory绑定到一个JNDI命名空间,用hibernate.session_factory_name这个属性指定一个名字(比如,java:comp/env/hibernate/SessionFactory)。如果这个属性省略了,SessionFactory不会被绑定到JNDI。(在一个只读的JNDI默认值实现的环境中,这特别有用。比如,Tomcat。) 当把Ses

penghuasheng的专栏 1126

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

[转载]在Weblogic上配置Hibernate为JNDI

在Weblogic上配置Hibernate为JNDI一、首先需要把Hibernate 用到的jar包和配置文件都放到Weblogic能够搜索到的CLASSPATH路径上。单单这一步就有很多人很迷茫,其实去仔细看看Weblogic...

congji3817的博客 178

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jndi weblogic mysql_Weblogic上配置Hibernate为JNDI_MySQL

HibernateWebLogicJNDI一、首先需要把Hibernate 用到的jar包和配置文件都放到Weblogic能够搜索到的CLASSPATH路径上。单单这一步就有很多人很迷茫,其实去仔细看看Weblogic的启动脚本文件startWeblogic.cmd和startWLS.cmd,我想大部分人都知道该怎么配置了。我机器上的有个Hibernate的项目,在D: estoracle目录下,...

weixin_42196667的博客 141

Hibernate 配置详解(2)

6) hibernate.session_factory_name: 配置一个JNDI名称,通过Configuration对象创建的SessionFactory会绑定到JNDI下该名称中。一般名字格式为jndi/someName。注意,要使用JNDI,需要在具有JNDI功能的环境之中,比如WEB容器或者EJB容器中。 下面再tomcat中做一个示例,首先在一个标准的WEB项目中添加hibern

lanyotechcs的专栏 2035

2.4.2 JNDI绑定的SessionFactory

在大多数的Hibernate程序中,SessionFactory只是在程序初始化的时候被初始化一次。这个单实例的SessionFactory对象被用来创建在程序中使用的Session。一个经常争论的问题就是sessionFactory应该被放在什么位置,以及如何去访问sessionfactory。在J2EE环境下,将SessionFactory与JNDI绑定在一起,这样可以更容易在线程之间以及

oneGeng的专栏 1438

Tomcat+Hibernate+JNDI DataSource配置排错全指南

JNDI(Java Naming and Directory Interface)是Java EE中实现资源解耦的核心命名服务机制,其本质是通过标准化的逻辑名称(如java:comp/env/jdbc/MyDS)绑定物理资源,由容器(如Tomcat)统一管理生命周期。Hibernate作为ORM框架,需通过JNDI查找DataSource而非直连数据库,这要求严格遵循JEE规范:完整路径、无冲突配置、容器级权限开放。技术价值在于提升部署一致性、支持连接池复用与运行时资源治理。典型应用场景包括传统WAR包迁移

weixin_31742871的博客 327

数据库连接池与JNDI介绍与使用

数据库连接池 数据库连接池在初始化时将创建一定数量的数据库连接放到连接池中,这些数据库连接的数量是由最小数据库连接数制约。无论这些数据库连接是否被使用,连接池都将一直保证至少拥有这么多的连接数量。连接池的最大数据库连接数量限定了这个连接池能占有的最大连接数,当应用程序向连接池请求的连接数超过最大连接数量时,这些请求将被加入到等待队列中。 连接池基本的思想是在系统初始化的时候,将数据库连接作为对...

venus321的博客 1472
上一篇: JDK1.5新特性介绍
下一篇: 20分钟熟悉猛虎脾气-JDK1.5新特性介绍
java169
博客等级 码龄19年 27粉丝 2568原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址