は私がhibernate
、springframework
、およびglassfish
で、Javaのウェブでプロジェクトをやっています。プロキシを初期化できませんでした - セッションはありませんか?
、それが次のエラー表示されて落下するプロジェクトの実行:それは動作しなくなった場合は
Glassfishの
Grave: could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at com.pojos.Aplicacion$$EnhancerByCGLIB$$abe88be6.getVersionApp(<generated>)
at com.beans.LoginSdiBean.logear(LoginSdiBean.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Grave: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at com.pojos.Aplicacion$$EnhancerByCGLIB$$abe88be6.getVersionApp(<generated>)
at com.beans.LoginSdiBean.logear(LoginSdiBean.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
休止
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://star.elrio.cl:3306/star?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">usuario</property>
<property name="hibernate.connection.password">clave</property>
<mapping resource="com/DatosOcOriginal.hbm.xml"/>
<mapping resource="com/Usuario.hbm.xml"/>
<mapping resource="com/EstadosOc.hbm.xml"/>
<mapping resource="com/ProyectoCompras.hbm.xml"/>
<mapping resource="com/Agendamiento.hbm.xml"/>
<mapping resource="com/Solicitud.hbm.xml"/>
<mapping resource="com/UsuarioAplicacion.hbm.xml"/>
<mapping resource="com/Aplicacion.hbm.xml"/>
<mapping resource="com/AplicacionVersion.hbm.xml"/>
<mapping resource="com/Propiedad.hbm.xml"/>
<mapping resource="com/Proyecto.hbm.xml"/>
<mapping resource="com/DatosCorreo.hbm.xml"/>
<mapping resource="com/ProyectoTi.hbm.xml"/>
<mapping resource="com/EventoUsuario.hbm.xml"/>
<mapping resource="com/Componente.hbm.xml"/>
<mapping resource="com/Permiso.hbm.xml"/>
<mapping resource="com/NotaProyecto.hbm.xml"/>
<mapping resource="com/ArchivosCargados.hbm.xml"/>
<mapping resource="com/DatosOc.hbm.xml"/>
<mapping resource="com/Email.hbm.xml"/>
<mapping resource="com/Evento.hbm.xml"/>
</session-factory>
</hibernate-configuration>
を
Map<String, UsuarioAplicacion> aplicaciones = usuario.getAplicaciones();
System.out.println("aplicacion key"+ aplicaciones.keySet());
Set<String> keySet = aplicaciones.keySet();
DefaultMenuItem item = null;
UsuarioAplicacion ua = null;
for (String key : keySet) {
ua = (UsuarioAplicacion) aplicaciones.get(key);
HERE FALLS item = new DefaultMenuItem(ua.getAplicacion().getNombre());
item.setUrl(ua.getAplicacion().getUrl());
item.setTitle(ua.getAplicacion().getDescripcion());
item.setIcon("../resources/images/" + ua.getAplicacion().getIcono());
menuAplicaciones.addElement(item);
}
アプリケーション
public class Aplicacion implements java.io.Serializable {
private String codAplicacion;
private String nombre;
private String lenguaje;
private String autor;
private Date fechaImplementacion;
private String descripcion;
private String versionApp;
private String url;
private String icono;
private Set componentes = new HashSet(0);
private Set usuarioAplicacions = new HashSet(0);
private Set propiedads = new HashSet(0);
private boolean asignada;
public static final String APLICACION_SDI = "SDI";
public static final String MSJ_EXITO_ASIGNAR = "Asignación de aplicación actualizada correctamente";
public Aplicacion() {
}
public Aplicacion(String codAplicacion, String nombre, String autor, Date fechaImplementacion, String descripcion, String versionApp) {
this.codAplicacion = codAplicacion;
this.nombre = nombre;
this.autor = autor;
this.fechaImplementacion = fechaImplementacion;
this.descripcion = descripcion;
this.versionApp = versionApp;
}
public Aplicacion(String codAplicacion, String nombre, String lenguaje, String autor, Date fechaImplementacion, String descripcion, String versionApp, Set componentes, Set usuarioAplicacions, Set propiedads) {
this.codAplicacion = codAplicacion;
this.nombre = nombre;
this.lenguaje = lenguaje;
this.autor = autor;
this.fechaImplementacion = fechaImplementacion;
this.descripcion = descripcion;
this.versionApp = versionApp;
this.componentes = componentes;
this.usuarioAplicacions = usuarioAplicacions;
this.propiedads = propiedads;
}
@Override
public int hashCode() {
int hash = 3;
hash = 17 * hash + (this.codAplicacion != null ? this.codAplicacion.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Aplicacion other = (Aplicacion) obj;
if ((this.codAplicacion == null) ? (other.codAplicacion != null) : !this.codAplicacion.equals(other.codAplicacion)) {
return false;
}
return true;
}
public String getCodAplicacion() {
return this.codAplicacion;
}
public void setCodAplicacion(String codAplicacion) {
this.codAplicacion = codAplicacion;
}
public String getNombre() {
return this.nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getLenguaje() {
return this.lenguaje;
}
public void setLenguaje(String lenguaje) {
this.lenguaje = lenguaje;
}
public String getAutor() {
return this.autor;
}
public void setAutor(String autor) {
this.autor = autor;
}
public Date getFechaImplementacion() {
return this.fechaImplementacion;
}
public void setFechaImplementacion(Date fechaImplementacion) {
this.fechaImplementacion = fechaImplementacion;
}
public String getDescripcion() {
return this.descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public String getVersionApp() {
return this.versionApp;
}
public void setVersionApp(String versionApp) {
this.versionApp = versionApp;
}
public Set getComponentes() {
return this.componentes;
}
public void setComponentes(Set componentes) {
this.componentes = componentes;
}
public Set getUsuarioAplicacions() {
return this.usuarioAplicacions;
}
public void setUsuarioAplicacions(Set usuarioAplicacions) {
this.usuarioAplicacions = usuarioAplicacions;
}
public Set getPropiedads() {
return this.propiedads;
}
public void setPropiedads(Set propiedads) {
this.propiedads = propiedads;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getIcono() {
return icono;
}
public void setIcono(String icono) {
this.icono = icono;
}
public boolean isAsignada() {
return asignada;
}
public void setAsignada(boolean asignada) {
this.asignada = asignada;
}
}
私は数日間、これできたと私はいくつかの同様の質問を見てきましたが、答えは動作しません。 UsuarioAplicacion内部
私はhibernate 3.6を使用していますが、コード行を追加しても動作しません。同じエラーが表示されます。 – Rarilex
https://stackoverflow.com/questions/21574236/org-hibernate-lazyinitializationexception-couldを確認してください-not初期化しない - プロキシ-NO-SESのとhttp://javarevisited.blogspot.com/2014/04/orghibernatelazyinitializationException-Could-not-initialize-proxy-no-session-hibernate-java.html –