[EJB/JBoss] - MVC application with EJB 2.1
by ThePretender
Hello!
I'm trying to build an MVC application using EJB to access a database. But I've met an unexpected problem: in my servlet (C-part of MVC) i want to use my EJB to get data through it. And that's why I must have EJB's interfaces imported into my servlet. Otherwise it won't compile. But then I'll get ClassCastException trying to do
| InitialContext init = new InitialContext();
|
| Object objref = init.lookup("TheNews");
|
| NewsHome home = (NewsHome)PortableRemoteObject.narrow(objref, NewsHome.class);
|
Because interface NewsHome and objref are loaded with different ClassLoaders.
How should I pack my ear-file and how to organize access to EJB functions: from servlet(how?) or somewhere else?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083834#4083834
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083834
18 years, 9 months
[JBoss jBPM] - Re: required variables
by kukeltje
hmmmm.... yes, afaik, an exception should be thrown. I'll check the code cause now I'm getting worried. I hop it is not some kind of regression.
In org.jbpm.taskmgmt.exe..Taskinstance.submitVariables(), org.jbpm.taskmgmt.def.TaskControler.submitParameters() is called which has a nice loop:
if (variableAccesses!=null) {
| String missingTaskVariables = null;
| Iterator iter = variableAccesses.iterator();
| while (iter.hasNext()) {
| VariableAccess variableAccess = (VariableAccess) iter.next();
| String mappedName = variableAccess.getMappedName();
| // first check if the required variableInstances are present
| if ( (variableAccess.isRequired())
| && (! taskInstance.hasVariableLocally(mappedName))
| ) {
| if (missingTaskVariables==null) {
| missingTaskVariables = mappedName;
| } else {
| missingTaskVariables += ", "+mappedName;
| }
| }
| }
|
| // if there are missing, required parameters, throw an IllegalArgumentException
| if (missingTaskVariables!=null) {
| throw new IllegalArgumentException("missing task variables: "+missingTaskVariables);
| }
|
Strange thing is that I cannot find a test for this. I'm almost sure I've seen them in the past
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083829#4083829
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083829
18 years, 9 months
[JBoss Seam] - LazyInitializationExceptions are staying
by michel.christianen
I use the following combination of tools:
Seam 1.2 GA
Apache MyFaces
EJB3
hibernate-commons-annotations 3.3.0.ga
hibernate-validator3.0.0.ga
com.sun.facelets 1.1.12
org.ajax4jsf 1.1.1
org.richfaces 3.0.1
jboss-ejb3-all 3.0.0
hibernate 3.0.0
I want to make use of Seam-managed persistence context with JPA; the problem I get is that lazy loading (FetchType.LAZY) isn't working ; if I use FetchType.EAGER everything works correctly.
I get the following error:
org.hibernate.LazyInitializationException: failed to lazily intialize a collection of role: .....
I followed the tutorial within the SEAM tutorial
I have the following configuration of a project including 2 subprojects, which are packed in seperate jars.
Jars/wars in total ear project:
----------------------------------
1. JAR ejb project containing the domain objects, service layer (stateless ejb3 beans) and controller layer (statefull ejb3 beans); in this jar the persistence.xml is located in the META-INF directory
2. JAR commons project containing helper classes (in this jar the entitymanager is injected using
@PersistenceContext(type=PersistenceContextType.EXTENDED)
private EntityManager entityManager
3. WAR web project
Overview of configuration files:
------------------------------------
persistence.xml (located in META-INF directory van ejb jar)
==========
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="atinvestorDb">
org.hibernate.ejb.HibernatePersistence
<jta-data-source>java:/AtInvestorMySqlDS</jta-data-source>
<!-- These are the default for JBoss EJB3, but not for HEM: -->
<!-- Put the EntityManagerFactory into JNDI so we can use it manually in tests -->
<!--property name="jboss.entity.manager.jndi.name" value="java:/atinvestorEntityManager"/-->
</persistence-unit>
components.xml (located in WEB-INF of web WAR)
===========
...
<core:managed-persistence-context name="entityManager"
auto-create="true"
persistence-unit-jndi-name="java:/atinvestorEntityManagerFactory" />
...
faces-config.xml (located in WEB-INF of web WAR)
===========
...
<phase-listener>org.jboss.seam.jsf.TransactionalSeamPhaseListener</phase-listener>
...
Can someon help me why I don't get lazy loading to work with this configuration.
- Can it be that the problem is in the fact that the injection of the EntityManager is within another JAR then where the persistency unit residence (and therefore the persistence.xml file is located) ?
Thanks beforehand.
Michel
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083822#4083822
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083822
18 years, 9 months