how can I change the order of the classes handed to AnnotationConfiguration
by Heping Zhang
hi, I've got a NullPointerException at
org.hibernate.cfg.OneToOneSecondPass.doSecondPass when deplor my ejb3 app.
And I searched on the web and find out that changing the order of the
classes handed to AnnotationConfiguration may work around the problem. But
I don't know how to do it? could anyone give me some help? thanks!
18 years, 11 months
[Installation, Configuration & Deployment] - Problem With Embedded EJB Server and XML
by jfrosch
I'm trying to get started with a JUnit4 test of a simple Entity bean and SLSB. I'm using JARs from the JBoss AS 4.20, Seam 1.2.1, Hibernate 3.2, Hibernate Annotations 3.3.0, and the Microcontainer 1.02.
Everything works okay when I use the class level sequence generator annotation on the EB. However, I then tried making an orm.xml file to declare the sequence generator as an application level sequence. I've had nothing but trouble with the XML parsing being done when EJB3StandaloneBootstrap.deployXmlResource() is invoked, like this:
| EJB3StandaloneBootstrap.boot(null);
| EJB3StandaloneBootstrap.deployXmlResource("META-INF/orm.xml");
| EJB3StandaloneBootstrap.scanClasspath("production/EJB");
|
If the XML file looks like this:
| <?xml version="1.0" encoding="UTF-8"?>
| <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| version="1.0">
| <sequence-generator name="app_sequence" sequence-name="APP_SEQ"/>
| </entity-mappings>
|
I get the following RuntimeException when deployXmlResource is called:
| java.lang.RuntimeException: org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/E:/data/.../classes/production/EJB/META-INF/orm.xml@6,68
|
I tried using a non-XSD form of the XML like I've seen in many examples:
| <?xml version="1.0" encoding="UTF-8"?>
| <entity-mappings>
| <sequence-generator name="app_sequence" sequence-name="APP_SEQ"/>
| </entity-mappings>
|
But I get the same RuntimeException when deployXmlResource is called.
The XML is just so simple, I'm amazed there's a problem with it. I'm hoping someone can point me to the right path to look for the cause of the problem and possible workarounds.
TIA
--
jack
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046970#4046970
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046970
18 years, 11 months
[JBoss Seam] - LazyInitializationException on SeamTest
by fernando_jmt
Hi.
Somebody knows how to deal with LazyInitializationException when using Seam integration test?
I got this exception: org.hibernate.LazyInitializationException.
The simple test:
| public class LoginTest extends SeamTest {
|
| @Test
| public void testLogin() throws Exception {
|
| new FacesRequest() {
|
| @Override
| protected void invokeApplication() {
| assert !isSessionInvalid();
| assert getValue("#{identity.loggedIn}").equals(false);
| }
|
| }.run();
|
| new FacesRequest() {
|
| @Override
| protected void updateModelValues() throws Exception {
| assert !isSessionInvalid();
| setValue("#{identity.username}", "fer");
| setValue("#{identity.password}", "fernando");
| }
|
| @Override
| protected void invokeApplication() {
| invokeMethod("#{identity.login}");
| }
|
| @Override
| protected void renderResponse() {
| assert getValue("#{identity.username}").equals("fer");
| assert !Manager.instance().isLongRunningConversation();
| assert getValue("#{identity.loggedIn}").equals(true);
| }
|
| }.run();
|
| new FacesRequest() {
|
| @Override
| protected void invokeApplication() {
| assert !isSessionInvalid();
| assert getValue("#{identity.loggedIn}").equals(true);
| }
|
| }.run();
|
| new FacesRequest() {
|
| @Override
| protected void invokeApplication() {
| assert !Manager.instance().isLongRunningConversation();
| assert !isSessionInvalid();
| invokeMethod("#{identity.logout}");
| assert Seam.isSessionInvalid();
| }
|
| @Override
| protected void renderResponse() {
| assert getValue("#{identity.loggedIn}").equals(false);
| assert Seam.isSessionInvalid();
| }
|
| }.run();
|
| }
|
| }
|
The authenticator class:
|
| @Name("authenticator")
| public class AuthenticatorAction implements Serializable {
|
| private static final long serialVersionUID = -3938569313203918047L;
|
| @Logger
| private Log log;
|
| @In(create = true)
| private UserManager userManager;
|
|
| @In
| private Identity identity;
|
| public boolean authenticate() {
|
| try {
| User currentUser = userManager.findByUsernameAndPassword(identity.getUsername(),
| Hash.instance().hash(identity.getPassword()));
| if (currentUser.getRoles() != null) {
| for (Role role : currentUser.getRoles()) {
| identity.addRole(role.getName());
| }
| }
|
| return true;
|
| } catch (EntryNotFoundException e) {
| return false;
| }
| }
|
| p
| }
|
The user entity (fragment)
|
| @Entity
| @Table(name = "users")
| @Name("user")
| public class User implements Serializable {
| ...
| @ManyToMany(fetch = FetchType.LAZY)
| @OrderBy("name asc")
| private List<Role> roles;
| ...
| }
|
Any help will be appreciated.
Thanks in advance.
The stacktrace:
| 21:39:54,515 ERROR [LazyInitializationException] failed to lazily initialize a collection of role: com.jtp.app.domain.User.roles, no session or session was closed
| org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.jtp.app.domain.User.roles, no session or session was closed
| at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
| at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
| at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
| at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
| at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:246)
| at com.jtp.app.action.AuthenticatorAction.authenticate(AuthenticatorAction.java:45)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:61)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
| at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
| at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
| at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
| at com.jtp.app.action.AuthenticatorAction_$$_javassist_0.authenticate(AuthenticatorAction_$$_javassist_0.java)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
| at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:71)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
| at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
| at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:104)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
| at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
| at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
| at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
| at org.jboss.seam.security.Identity.authenticate(Identity.java:247)
| at org.jboss.seam.security.Identity.authenticate(Identity.java:240)
| at org.jboss.seam.security.Identity.login(Identity.java:170)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
| at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:71)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
| at org.jboss.seam.mock.SeamTest$Request.invokeMethod(SeamTest.java:401)
| at com.jtp.app.test.LoginTest$2.invokeApplication(LoginTest.java:40)
| at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
| at com.jtp.app.test.LoginTest.testLogin(LoginTest.java:29)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:645)
| at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:479)
| at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:715)
| at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
| at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
| at org.testng.TestRunner.runWorkers(TestRunner.java:673)
| at org.testng.TestRunner.privateRun(TestRunner.java:620)
| at org.testng.TestRunner.run(TestRunner.java:480)
| at org.testng.SuiteRunner.runTest(SuiteRunner.java:278)
| at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:273)
| at org.testng.SuiteRunner.privateRun(SuiteRunner.java:253)
| at org.testng.SuiteRunner.run(SuiteRunner.java:168)
| at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987)
| at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
| at org.testng.TestNG.run(TestNG.java:719)
| at org.testng.TestNG.privateMain(TestNG.java:1019)
| at org.testng.TestNG.main(TestNG.java:997)
| 21:39:54,531 ERROR [SeamLoginModule] Error invoking login method
| javax.el.ELException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.jtp.app.domain.User.roles, no session or session was closed
| at com.sun.el.parser.AstValue.invoke(AstValue.java:178)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
| at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:71)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
| at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
| at org.jboss.seam.security.jaas.SeamLoginModule.login(SeamLoginModule.java:104)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
| at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
| at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
| at java.security.AccessController.doPrivileged(Native Method)
| at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
| at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
| at org.jboss.seam.security.Identity.authenticate(Identity.java:247)
| at org.jboss.seam.security.Identity.authenticate(Identity.java:240)
| at org.jboss.seam.security.Identity.login(Identity.java:170)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
| at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:71)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
| at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
| at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
| at org.jboss.seam.mock.SeamTest$Request.invokeMethod(SeamTest.java:401)
| at com.jtp.app.test.LoginTest$2.invokeApplication(LoginTest.java:40)
| at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
| at com.jtp.app.test.LoginTest.testLogin(LoginTest.java:29)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:645)
| at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:479)
| at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:715)
| at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
| at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
| at org.testng.TestRunner.runWorkers(TestRunner.java:673)
| at org.testng.TestRunner.privateRun(TestRunner.java:620)
| at org.testng.TestRunner.run(TestRunner.java:480)
| at org.testng.SuiteRunner.runTest(SuiteRunner.java:278)
| at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:273)
| at org.testng.SuiteRunner.privateRun(SuiteRunner.java:253)
| at org.testng.SuiteRunner.run(SuiteRunner.java:168)
| at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987)
| at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
| at org.testng.TestNG.run(TestNG.java:719)
| at org.testng.TestNG.privateMain(TestNG.java:1019)
| at org.testng.TestNG.main(TestNG.java:997)
| Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.jtp.app.domain.User.roles, no session or session was closed
| at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
| at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
| at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
| at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
| at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:246)
| at com.jtp.app.action.AuthenticatorAction.authenticate(AuthenticatorAction.java:45)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:61)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
| at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
| at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
| at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
| at com.jtp.app.action.AuthenticatorAction_$$_javassist_0.authenticate(AuthenticatorAction_$$_javassist_0.java)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
| ... 55 more
| 21:39:54,593 INFO [Ejb] stopping the embedded EJB container
| 21:39:54,609 INFO [SessionFactoryImpl] closing
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046969#4046969
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046969
18 years, 11 months