Neighborhoods: Used Struts + SessionBean + Hibernate framework development process friends please come! (When enough points plus)

Category: Java EE
 
qiwujia
2013-02-12 01:59:54

Sponsored Links
My current system architecture are:
Struts in Action calls sessionBean remote interface
then by sessionBean called Hibernate DAO (the code generated by the plug-in, all the Hibernate methods of repackaging)

I ask you is to sessionBean with Hibernate in an EJB project, such as on the Struts web project it? Or put sessionBean on the EJB project, the Hibernate and Struts Web project on it?

I am now on the sessionBean an EJB with Hibernate project, such as on the Struts web project, but when it can not find the call Hibernate hibernate.cfg.xml file, EJB project The directory structure is such that:

sjrkxtEJB \ ejbModule
com.sjrkxt ...... / / Hibernate DAO class
; org ............ / / EJB classes

hibernate.cfg.xml file

sjrkxtEJB \ ejbModule \ META-INF
........ / / EJB deployment file

it is placed on the root directory of classes, ah, how still can not find it? Put it in the directory where the calling class EJB, Hibernate DAO directory
down, sjrkxtEJB \ ejbModule \ META-INF under, sjrkxtEJB following are not?

did not move, please help! Is not that kind of non-like Web project directory structure (on JavaSource) it is to find one ah? However, if placed in the EJB project, then, is not used JavaSource directory ah!

Jijiji ah!

Sponsored Links

haiming_1986
2013-02-12 02:07:40
Your This architecture is very good, I also try to look back, come back to tell you ah! Attention!
fengsun888
2013-02-12 02:16:40
really do not know, you can top it.
nqh_829
2013-02-12 02:31:02
hibernate on the server's classpath,
chjiandan
2013-02-12 02:46:48
hibernate.cfg.xml placed in classes directory
hujunwen1113
2013-02-12 02:58:05
Why did you do it?
If you do not need to use ejb
distributed directly struts + hibernate do not like it?
txiaobao
2013-02-12 03:08:22
Here sessionBean is used to handle business logic
gzp198
2013-02-12 03:12:00
no one has done it?
yunnanwang
2013-02-12 03:26:28
No one can help me ah?
lyz372
2013-02-12 03:42:38
packaged in CLASSES \ META-INF directory should be.
wlwantgirl
2013-02-12 03:50:08
you configure how to write the code? Stickers look?
a34870352
2013-02-12 04:03:56
SessionBean in:
package com.beststar.sjrkxt.ejb.sb;
public void Hello () {
try {
_RootDAO . initialize ("/ hibernate.cfg.xml");
} catch (HibernateException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}

RootDAO in:
package com.beststar.sjrkxt.hbnt.base;

public static void initialize (String configFileName) throws HibernateException {
if (null == configFileName && sessionFactoryMap.size () ;> 0) return;
else if (null! = sessionFactoryMap.get (configFileName)) return;
else {
Configuration cfg = new Configuration ();
if (null == configFileName)
cfg.configure ();
else
cfg.configure (configFileName );
setSessionFactory (configFileName, cfg.buildSessionFactory ());
}
}
www232676
2013-02-12 04:15:45
protected static void setSessionFactory (String ; configFileName, SessionFactory sessionFactory) {
sessionFactoryMap.put (configFileName, sessionFactory);
}
huang1986hui
2013-02-12 04:22:33
code is automatically generated for the plug, not will lead to problems in the web project under normal ah, how we would not put it in the EJB project?
skyant1987
2013-02-12 04:33:06
you put all the classes Hibernate labeled jar package, add the EJB project as a resource, it can.

others cite a passage:
Look, this guy gets troubles. It is the Hibernate's problem.

You can try this, all your hibernate classes are saved in one URL, and make a resource refered by the EJB. Inside the EJB you code JNDI look up the URL and download the class for local use. I don't think this is J2EE project if you play Hibernate.

Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.