OK, this is my first post, so please don't blame me for posting something wrong. May this be of help for anyone,
I think I did everything according to the documentation, but I am still getting the unknown scope error. (Yes, I updated the jar-file)
1) I took Michael Gloegl's Event example and (
http://www.gloegl.de/8.html) tried to apply it to Hibernate/JBOss.
Here the code of the POJO and the hibernate files:
Code:
/*
* Created on Aug 8, 2004
*
*/
package com.yankeezulu.flightlog.vo;
import java.io.Serializable;
import java.util.Date;
/**
* @author marc_mulzer
*
*/
public class EventVO implements Serializable {
private String title;
private Date date;
private Long id;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
and
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.yankeezulu.flightlog.vo.EventVO" table="EVENTS">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="date" type="timestamp"/>
<property name="title" column="eventtitle"/>
</class>
</hibernate-mapping>
2) in the same package, I created the hibernate MBean configuration file, hibernate-service.xml.
Code:
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">java:/DefaultDS</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.HSQLDialect</attribute>
<attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="Hbm2ddlAuto">create-drop</attribute>
</mbean>
2) then I created a stateless session bean.
(Note the XDoclet annotation for transaction support)
There is only one business method, though, see CreateEvent(), to keep it simple. This method is where I put the Session code from the JBOSS WIKI.
Code:
/*
* Created on Aug 8, 2004
*
*/
package com.yankeezulu.flightlog.ejb;
import java.rmi.RemoteException;
import java.util.Date;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import com.yankeezulu.flightlog.vo.EventVO;
/**
* @ejb.bean name="Event"
* display-name="Name for Event"
* description="Description for Event"
* jndi-name="ejb/Event"
* type="Stateless"
* view-type="remote"
* transaction-type = "Container"
*
* @ejb.transaction type="Required"
*
*
*/
public class EventBean implements SessionBean {
private Session session = null;
/**
*
*/
public EventBean() {
super();
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbActivate()
*/
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbRemove()
*/
public void ejbRemove() throws EJBException, RemoteException {
session = null;
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
*/
public void setSessionContext(SessionContext ctx)
throws EJBException,
RemoteException {
// TODO Auto-generated method stub
}
/**
* Default create method
*
* @throws CreateException
* @ejb.create-method
*/
public void ejbCreate() throws CreateException {
// TODO Auto-generated method stub
}
/**
* Business method
* @ejb.interface-method view-type = "remote"
*/
public void createEvent(String title, Date date) {
session = org.jboss.hibernate.session.SessionContext.getSession("java:/hibernate/SessionFactory");
try {
Transaction tx = session.beginTransaction();
EventVO event = new EventVO();
event.setTitle(title);
event.setDate(date);
session.save(event);
tx.commit();
session.close();
}
catch (HibernateException he){
System.err.println(he.getMessage());
}
}
}
3) XDoclet created the necessary home and remote interfaces for me.
Code:
/*
* Generated by XDoclet - Do not edit!
*/
package com.yankeezulu.flightlog.interfaces;
/**
* Remote interface for Event.
*/
public interface Event
extends javax.ejb.EJBObject
{
/**
* Business method
*/
public void createEvent( java.lang.String title,java.util.Date date )
throws java.rmi.RemoteException;
}
and
Code:
/*
* Generated by XDoclet - Do not edit!
*/
package com.yankeezulu.flightlog.interfaces;
/**
* Home interface for Event.
*/
public interface EventHome
extends javax.ejb.EJBHome
{
public static final String COMP_NAME="java:comp/env/ejb/Event";
public static final String JNDI_NAME="ejb/Event";
public com.yankeezulu.flightlog.interfaces.Event create()
throws javax.ejb.CreateException,java.rmi.RemoteException;
}
4) Then I created a jboss-container.xml configuration file per the instructions. I put it in a folder under my src/ called container-configuration/
Code:
<container-configurations>
<container-configuration extends="Standard Stateless SessionBean">
<container-name>Hibernate Stateless SessionBean</container-name>
<call-logging>true</call-logging>
<container-interceptors>
<interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
<!-- CMT -->
<interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
<interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor transaction="Container">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
<!-- BMT not feasible using Hibernate interceptor with 'transaction' scope!!!! -->
<!-- Notice that the service name is the same as that used to define the MBean -->
<interceptor service="jboss.har:service=Hibernate" scope="transaction">org.jboss.hibernate.session.EjbInterceptor</interceptor>
</container-interceptors>
</container-configuration>
</container-configurations>
4) Then I created a XDoclet that merges the container config file into the ejb descriptors from that directory.
Here my descriptors:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
<jboss>
<enterprise-beans>
<!--
To add beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called jboss-beans.xml that contains
the <session></session>, <entity></entity> and <message-driven></message-driven>
markup for those beans.
-->
<session>
<ejb-name>Event</ejb-name>
<jndi-name>ejb/Event</jndi-name>
<method-attributes>
</method-attributes>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
<container-configurations>
<container-configuration extends="Standard Stateless SessionBean">
<container-name>Hibernate Stateless SessionBean</container-name>
<call-logging>true</call-logging>
<container-interceptors>
<interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
<!-- CMT -->
<interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
<interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor transaction="Container">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
<!-- BMT not feasible using Hibernate interceptor with 'transaction' scope!!!! -->
<!-- Notice that the service name is the same as that used to define the MBean -->
<interceptor service="jboss.har:service=Hibernate" scope="transaction">org.jboss.hibernate.session.EjbInterceptor</interceptor>
</container-interceptors>
</container-configuration>
</container-configurations>
</jboss>
and
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar >
<description><![CDATA[No Description.]]></description>
<display-name>Generated by XDoclet</display-name>
<enterprise-beans>
<!-- Session Beans -->
<session >
<description><![CDATA[Description for Event]]></description>
<display-name>Name for Event</display-name>
<ejb-name>Event</ejb-name>
<home>com.yankeezulu.flightlog.interfaces.EventHome</home>
<remote>com.yankeezulu.flightlog.interfaces.Event</remote>
<ejb-class>com.yankeezulu.flightlog.ejb.EventBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<!--
To add session beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called session-beans.xml that contains
the <session></session> markup for those beans.
-->
<!-- Entity Beans -->
<!--
To add entity beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called entity-beans.xml that contains
the <entity></entity> markup for those beans.
-->
<!-- Message Driven Beans -->
<!--
To add message driven beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called message-driven-beans.xml that contains
the <message-driven></message-driven> markup for those beans.
-->
</enterprise-beans>
<!-- Relationships -->
<!-- Assembly Descriptor -->
<assembly-descriptor >
<!--
To add additional assembly descriptor info here, add a file to your
XDoclet merge directory called assembly-descriptor.xml that contains
the <assembly-descriptor></assembly-descriptor> markup.
-->
<!-- finder permissions -->
<!-- transactions -->
<container-transaction >
<method >
<ejb-name>Event</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<!-- finder transactions -->
</assembly-descriptor>
</ejb-jar>
5) then I used eclipses packaging feature to create a jboss.har. I put the EventVO.class , the EventVO.hbm.xml file and the hibernate-service.xml in the .har file.
the structure is as follows
/jboss.har
/META-INF/hibernate-service.xml
/com/yankeezulu/flightlog/vo/EventVO.class
/com.yankeezulu/flightlog/vo/EventVO.hbm.xml.
6) then I packaged the EJB as usual (per JBOSS/IDE tutorial).
/EventEJB.jar
/META-INF/jboss.xml
/META-INF/ejb-jar.xml
/com/yankeezulu/flightlog/ejb/EventBean.class
/com/yankeezulu/flightlog/interfaces/Event.class
/com/yankeezulu/flightlog/interfaces/EventHome.class
/EventEJB-client.jar
/com/yankeezulu/flightlog/interfaces/Event.class
/com/yankeezulu/flightlog/interfaces/EventHome.class
7) then I create a servlet to call the EJB.
I am lazy, so I used the servlet's init() method to call it. I am not good at writing JUnit/Cactus test cases, but I am learning that right now.
So, here the code ( I know that is dirty, but I don't want to mess with the client code much, just testing the code.)
Code:
/*
* Created on Aug 9, 2004
*
*/
package com.yankeezulu.flightlog.web;
import java.util.Date;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import com.yankeezulu.flightlog.interfaces.Event;
import com.yankeezulu.flightlog.interfaces.EventHome;
/**
* Servlet Class
*
* @web.servlet name="EventServlet"
* display-name="Name for EventServlet"
* description="Description for EventServlet"
* @web.servlet-mapping url-pattern="/EventServlet"
*
* @web.ejb-ref name="ejb/Event"
* type="Session"
* home="com.yankeezulu.flightlog.interfaces.EventHome"
* remote="com.yankeezulu.flightlog.interfaces.Event"
* description="Reference to the Event EJB"
*
* @jboss.ejb-ref-jndi ref-name="ejb/Event"
* jndi-name="ejb/Event"
*/
public class EventServlet extends HttpServlet {
private EventHome home;
/**
*
*/
public EventServlet() {
super();
// TODO Auto-generated constructor stub
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
Context context = new InitialContext();
Object ref = context.lookup("java:/comp/env/ejb/Event");
home = (EventHome) PortableRemoteObject.narrow(ref, EventHome.class);
Date date = new Date();
String title = "Cool Event";
Event bean = home.create();
bean.createEvent(title,date);
} catch (Exception e) {
throw new ServletException("Lookup of java:/comp/env/ failed");
}
}
}
8) XDoclet creates the necessary web container configuration files jboss-web.xml and web.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app >
<distributable/>
<!--
To use non XDoclet filters, create a filters.xml file that
contains the additional filters (eg Sitemesh) and place it in your
project's merge dir. Don't include filter-mappings in this file,
include them in a file called filter-mappings.xml and put that in
the same directory.
-->
<!--
To use non XDoclet filter-mappings, create a filter-mappings.xml file that
contains the additional filter-mappings and place it in your
project's merge dir.
-->
<!--
To use non XDoclet listeners, create a listeners.xml file that
contains the additional listeners and place it in your
project's merge dir.
-->
<!--
To use non XDoclet servlets, create a servlets.xml file that
contains the additional servlets (eg Struts) and place it in your
project's merge dir. Don't include servlet-mappings in this file,
include them in a file called servlet-mappings.xml and put that in
the same directory.
-->
<servlet>
<servlet-name>EventServlet</servlet-name>
<display-name>Name for EventServlet</display-name>
<description><![CDATA[Description for EventServlet]]></description>
<servlet-class>com.yankeezulu.flightlog.web.EventServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EventServlet</servlet-name>
<url-pattern>/EventServlet</url-pattern>
</servlet-mapping>
<!--
To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir.
Organize mime-mappings.xml following this DTD slice:
<!ELEMENT mime-mapping (extension, mime-type)>
-->
<!--
To specify error pages, create a file named error-pages.xml, put it in your project's mergedir.
Organize error-pages.xml following this DTD slice:
<!ELEMENT error-page ((error-code | exception-type), location)>
-->
<!--
To add taglibs by xml, create a file called taglibs.xml and place it
in your merge dir.
-->
<!--
To set up security settings for your web app, create a file named web-security.xml, put it in your project's mergedir.
Organize web-security.xml following this DTD slice:
<!ELEMENT security-constraint (display-name?, web-resource-collection+, auth-constraint?, user-data-constraint?)>
<!ELEMENT web-resource-collection (web-resource-name, description?, url-pattern*, http-method*)>
<!ELEMENT web-resource-name (#PCDATA)>
<!ELEMENT url-pattern (#PCDATA)>
<!ELEMENT http-method (#PCDATA)>
<!ELEMENT user-data-constraint (description?, transport-guarantee)>
<!ELEMENT transport-guarantee (#PCDATA)>
<!ELEMENT login-config (auth-method?, realm-name?, form-login-config?)>
<!ELEMENT auth-method (#PCDATA)>
<!ELEMENT realm-name (#PCDATA)>
<!ELEMENT form-login-config (form-login-page, form-error-page)>
<!ELEMENT form-login-page (#PCDATA)>
<!ELEMENT form-error-page (#PCDATA)>
-->
<ejb-ref >
<description><![CDATA[Reference to the Event EJB]]></description>
<ejb-ref-name>ejb/Event</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.yankeezulu.flightlog.interfaces.EventHome</home>
<remote>com.yankeezulu.flightlog.interfaces.Event</remote>
</ejb-ref>
</web-app>
and
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
<jboss-web>
<!-- Resource Environment References -->
<!--
For additional resouce-env-ref tags add a merge file called jbossweb-resource-env-ref.xml
-->
<!-- Resource references -->
<!--
For additional resouce-ref tags add a merge file called jbossweb-resource-ref.xml
-->
<!-- EJB References -->
<!--
For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml
-->
<ejb-ref>
<ejb-ref-name>ejb/Event</ejb-ref-name>
<jndi-name>ejb/Event</jndi-name>
</ejb-ref>
<!-- EJB Local References -->
</jboss-web>
9) I package my web app as follows:
/EventWeb.war
/META-INF/lib/EventEJB-client.jar
/META-INF/web.xml
/META-INF/jboss-web.xml
/com/yankeezulu/flightlog/web/EventServlet.class
10) Almost there. now I create the jboss-app.xml file per instrcutions on the WIKI
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-app SYSTEM "file:///C:/jboss-3.2.6RC1/docs/dtd/jboss-app_3_2.dtd">
<jboss-app><module><har>jboss.har</har></module></jboss-app>
11) I also need an application.xml to package the EAR
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>Sum Application</display-name>
<module>
<ejb>EventEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>EventWeb.war</web-uri>
<context-root>/event</context-root>
</web>
</module>
</application>
12) now I can package the EventApp.ear
/EventApp.ear
/META-INF/jboss-app.xml
/META-INF/application.xml
/EventEJB.jar
/EventWeb.war
/jboss.har
13) In my application, I set a break point in the session ejb where the session gets created from the session factory:
this is the line in the EventBean.java file:
Code:
/**
* Business method
* @ejb.interface-method view-type = "remote"
*/
public void createEvent(String title, Date date) {
session = org.jboss.hibernate.session.SessionContext.getSession("java:/hibernate/SessionFactory");
try {
...
...
14) I fire up Jboss in the debugger
15) now I drop the EventApp.ear in the deployment folder. But before I do that, I make sure I updated the hibernate jar and the hibernate service deployer files per the WIKI.
16) the hibernate service MBean and my EJB get deployed, i can see that in the output:
Code:
19:43:05,217 INFO [Configuration] Searching for mapping documents in jar: jboss.har
19:43:05,217 INFO [Configuration] Found mapping documents in jar: com/yankeezulu/flightlog/vo/EventVO.hbm.xml
19:43:05,598 INFO [Binder] Mapping class: com.yankeezulu.flightlog.vo.EventVO -> EVENTS
19:43:06,028 INFO [Configuration] processing one-to-many association mappings
19:43:06,028 INFO [Configuration] processing one-to-one association property references
19:43:06,028 INFO [Configuration] processing foreign key constraints
19:43:06,279 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.HSQLDialect
19:43:06,279 INFO [SettingsFactory] Use outer join fetching: false
19:43:06,369 INFO [NamingHelper] JNDI InitialContext properties:{}
19:43:06,369 INFO [DatasourceConnectionProvider] Using datasource: java:/DefaultDS
19:43:06,379 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
19:43:06,379 INFO [NamingHelper] JNDI InitialContext properties:{}
19:43:06,379 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
19:43:06,379 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
19:43:06,379 INFO [NamingHelper] JNDI InitialContext properties:{}
19:43:06,389 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
19:43:06,389 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
19:43:06,429 INFO [SettingsFactory] Use scrollable result sets: true
19:43:06,429 INFO [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
19:43:06,429 INFO [SettingsFactory] Optimize cache for minimal puts: false
19:43:06,439 INFO [SettingsFactory] Query language substitutions: {}
19:43:06,439 INFO [SettingsFactory] cache provider: net.sf.hibernate.cache.HashtableCacheProvider
19:43:06,449 INFO [Configuration] instantiating and configuring caches
19:43:07,240 INFO [SessionFactoryImpl] building session factory
19:43:08,892 INFO [SessionFactoryObjectFactory] Factory name: java:/hibernate/SessionFactory
19:43:08,892 INFO [NamingHelper] JNDI InitialContext properties:{}
19:43:08,902 INFO [NamingHelper] Creating subcontext: hibernate
19:43:08,902 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/SessionFactory
19:43:08,902 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
19:43:08,953 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.HSQLDialect
19:43:08,953 INFO [Configuration] processing one-to-many association mappings
19:43:08,953 INFO [Configuration] processing one-to-one association property references
19:43:08,953 INFO [Configuration] processing foreign key constraints
19:43:08,963 INFO [Configuration] processing one-to-many association mappings
19:43:08,963 INFO [Configuration] processing one-to-one association property references
19:43:09,143 INFO [Configuration] processing foreign key constraints
19:43:09,313 INFO [SchemaExport] Running hbm2ddl schema export
19:43:09,313 INFO [SchemaExport] exporting generated schema to database
19:43:09,313 INFO [NamingHelper] JNDI InitialContext properties:{}
19:43:09,313 INFO [DatasourceConnectionProvider] Using datasource: java:/DefaultDS
19:43:09,353 INFO [SchemaExport] schema export complete
19:43:09,353 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.HSQLDialect
19:43:09,353 INFO [Configuration] processing one-to-many association mappings
19:43:09,353 INFO [Configuration] processing one-to-one association property references
19:43:09,353 INFO [Configuration] processing foreign key constraints
19:43:09,353 INFO [Configuration] processing one-to-many association mappings
19:43:09,353 INFO [Configuration] processing one-to-one association property references
19:43:09,353 INFO [Configuration] processing foreign key constraints
19:43:09,353 INFO [NamingHelper] JNDI InitialContext properties:{}
19:43:09,894 INFO [EJBDeployer] Deployed: file:/C:/jboss-3.2.6RC1/server/default/tmp/deploy/tmp31808EventApp.ear-contents/EventEJB.jar
I also check my JNDI tree and see that my EJB and the Session factory are listed in the tree.
see here the output of the JNDI list methof form the jmx-console:
Code:
Ejb Module: EventEJB.jar
java:comp namespace of the Event bean:
+- env (class: org.jnp.interfaces.NamingContext)
java: Namespace
+- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
+- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
+- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
+- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
+- comp (class: javax.naming.Context)
+- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
+- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
+- jaas (class: javax.naming.Context)
| +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
| +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
| +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
+- timedCacheFactory (class: javax.naming.Context)
Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
+- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
+- Mail (class: javax.mail.Session)
+- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
+- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
+- TransactionManager (class: org.jboss.tm.TxManager)
+- hibernate (class: org.jnp.interfaces.NamingContext)
| +- SessionFactory (class: net.sf.hibernate.impl.SessionFactoryImpl)
16) then I fire up the browser and go to
http://localhost:8080/event/EventServletThe debugger stops at the sessionfactory line where I had set the break point. so I know, my servlet was able tolook up the EJB and call the ejbcreate() method. So I also know that all my packaging is correct and that JBOSS likes my session bean.
17) but then when the sessionfactory tries to get a session, then it blows up with the error state by previous posts.
Code:
19:45:35,854 ERROR [LogInterceptor] RuntimeException:
java.lang.IllegalArgumentException: Unknown session scope for jndi name [java:/hibernate/SessionFactory]
at org.jboss.hibernate.session.SessionContext.getSessions(Ljava.lang.String;)Ljava.util.Hashtable;(SessionContext.java:167)
at org.jboss.hibernate.session.SessionContext.getSession(Ljava.lang.String;)Lnet.sf.hibernate.Session;(SessionContext.java:77)
at com.yankeezulu.flightlog.ejb.EventBean.createEvent(Ljava.lang.String;Ljava.util.Date;)V(EventBean.java:94)
at COM.jrockit.reflect.NativeMethodInvoker.invoke0(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Native Method)
at COM.jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at COM.jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(StatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(Lorg.jboss.invocation.Invocation;Z)Ljava.lang.Object;(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(TxInterceptorCMT.java:315)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(TxInterceptorCMT.java:148)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(SecurityInterceptor.java:120)
at org.jboss.ejb.plugins.LogInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(StatelessSessionContainer.java:331)
at org.jboss.ejb.Container.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(Container.java:723)
at COM.jrockit.reflect.NativeMethodInvoker.invoke0(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Native Method)
at COM.jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at COM.jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.mx.server.ReflectedDispatcher.dispatch([Ljava.lang.Object;)Ljava.lang.Object;(ReflectedDispatcher.java:60)
at org.jboss.mx.server.Invocation.dispatch([Ljava.lang.Object;)Ljava.lang.Object;(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch()Ljava.lang.Object;(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke()Ljava.lang.Object;(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(AbstractMBeanInvoker.java:185)
at org.jboss.mx.server.MBeanServerImpl.invoke(Ljavax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)Ljava.lang.Object;(MBeanServerImpl.java:473)
at org.jboss.invocation.local.LocalInvoker.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(LocalInvoker.java:97)
at org.jboss.invocation.InvokerInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(InvokerInterceptor.java:90)
at org.jboss.proxy.TransactionInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(Lorg.jboss.invocation.Invocation;)Ljava.lang.Object;(SecurityInterceptor.java:53)
19:45:35,864 ERROR [Engine] StandardWrapperValve[EventServlet]: Allocate exception for servlet EventServlet
javax.servlet.ServletException: Lookup of java:/comp/env/ failed
at com.yankeezulu.flightlog.web.EventServlet.init(Ljavax.servlet.ServletConfig;)V(EventServlet.java:59)
at org.apache.catalina.core.StandardWrapper.loadServlet()Ljavax.servlet.Servlet;(StandardWrapper.java:1019)
at org.apache.catalina.core.StandardWrapper.allocate()Ljavax.servlet.Servlet;(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Lorg.apache.catalina.Wrapper;Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(JBossSecurityMgrRealm.java:418)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;Lorg.apache.catalina.ValveContext;)V(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(Lorg.apache.catalina.Request;Lorg.apache.catalina.Response;)V(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(Lorg.apache.coyote.Request;Lorg.apache.coyote.Response;)V(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Ljava.io.InputStream;Ljava.io.OutputStream;)V(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Lorg.apache.tomcat.util.net.TcpConnection;[Ljava.lang.Object;)V(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt([Ljava.lang.Object;)V(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run()V(ThreadPool.java:683)
at java.lang.Thread.run()V(Unknown Source)
at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)
In conclusion:
I think I did everything right, I worked a LONG time on this, so please, if you have any suggestions, let me know.
I can email you my source directory and ear file if you like.
Thanks, very much!