You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 23 Members of 4546 |
| Forum: Seam Users |
05. Jun 2008, 15:05 CET | Link |
Hello:-)
I use SEAM 2.1.
I want to register a new User:
@Stateless
@Name("register")
public class Register implements RegisterLocal {
...
@In(required = false) @Out
private Users users;
//@PersistenceContext(unitName="vONE")
@In
private EntityManager entityManager;
@In
private Identity identity;
@In
private IdentityManager identityManager;
public void registerUser() {
Identity.setSecurityEnabled(false);
identityManager.createUser("pw","me","do","od");
// entityManager.persist(users);
}
I put the values for createUser(pw
,me
,do
,od
) directly, only for demonstrating that the failure is independent from any view or database.
In the components.xml
I have:
...
<identity-management:jpa-identity-store user-class="com.boewe.object.Users"/>
<!-- role-class="com.boewe.object.Groups"-->
...
The role-class is deactivated. (Is this the problem?)
My Entity-Bean:
@Name("person")
public class Person implements Serializable{
@Id
@GeneratedValue
private int idUser;
@UserPrincipal
private String login;
@UserFirstName
private String firstname;
@UserLastName
private String lastname;
@UserPassword(hash = "MD5")
private String password;
...
}
A snip from the Stacktrace:
13:00:08,510 INFO [Contexts] starting up: org.jboss.seam.security.ruleBasedPermissionResolver 13:00:08,510 INFO [Contexts] starting up: org.jboss.seam.security.identity 13:00:08,510 INFO [Contexts] starting up: org.jboss.seam.web.session 13:00:13,886 FATAL [application] javax.ejb.EJBTransactionRolledbackException: Could not create account javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: Could not create account at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91) at javax.faces.component.UICommand.broadcast(UICommand.java:383) at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:317) ..... javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77) ... 47 more Caused by: org.jboss.seam.security.management.IdentityManagementException: Could not create account at org.jboss.seam.security.management.JpaIdentityStore.createUser(JpaIdentityStore.java:205) at org.jboss.seam.security.management.IdentityManager.createUser(IdentityManager.java:98) at .... ... ... 121 more
If I would be able to edit my first writing...
the 'components.xml' is:
... <identity-management:jpa-identity-store user-class="com.entity.Person"/> <!-- role-class="com.entity.Groups"--> ...but the failure is still alive:-)
That stack trace doesn't show a root cause, is there more of it?
Yes:-)
(but I have to truncated it cos of the limitation of the upload space..)
root-cause...hmm...My stacktrace begins with that:
the
points to this:
pwmedood
Do you need more info?
(another question: Is there a possibility in this forum to EDIT a topic in this forum?)
The answer is in the stack trace - it can't find an entity manager. You need to configure a Seam managed persistence context and call it entityManager. I also recommend you check out the latest version from SVN, what you have seems outdated.
so far so good..I have installed the latest version of and configured the Seam managed persistence context (in despite of the example of 'seamspace'..).
My 'components.xml' now:
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:security="http://jboss.com/products/seam/security" xmlns:identity-management="http://jboss.com/products/seam/security/management" xmlns:permission-management="http://jboss.com/products/seam/security/permission" xmlns:drools="http://jboss.com/products/seam/drools" xmlns:captcha="http://jboss.com/products/seam/captcha" xmlns:web="http://jboss.com/products/seam/web" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/security/management http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd http://jboss.com/products/seam/captcha http://jboss.com/products/seam/captcha-2.1.xsd"> <core:init jndi-pattern="@jndiPattern@" debug="true"/> <core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid" parent-conversation-id-parameter="pid"/> <!-- I do not use this: --> <!-- <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myEntityManagerFactory"/> --> <!-- I use SEAM MANAGED PERSISTENCE --> <core:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myEntityManagerFactory"/> <!-- and I use this: --> <identity-management:jpa-identity-store user-class="com.model.Persons"/> ... </components>by deploying, this stacktrace occurs:
08:46:00,414 INFO [Initialization] reading /WEB-INF/components.xml 08:46:00,414 ERROR [[/myProject]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.RuntimeException: error while reading /WEB-INF/components.xml at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:158) at org.jboss.seam.init.Initialization.create(Initialization.java:108) at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296) at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296) at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301) at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104) at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375) at org.jboss.web.WebModule.startModule(WebModule.java:83) at org.jboss.web.WebModule.startService(WebModule.java:61) at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978) at $Proxy0.start(Unknown Source) at org.jboss.system.ServiceController.start(ServiceController.java:417) at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy44.start(Unknown Source) at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97) at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238) at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87) at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188) at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy45.start(Unknown Source) at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025) at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy9.deploy(Unknown Source) at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421) at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225) Caused by: java.lang.NullPointerException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.jboss.seam.util.Reflections.classForName(Reflections.java:165) at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:245) at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:154) ... 92 more 08:46:00,414 ERROR [StandardContext] Error listenerStart 08:46:00,414 ERROR [StandardContext] Context [/myProject] startup failed due to previous errors 08:46:00,554 WARN [ServiceController] Problem starting service jboss.web.deployment:war=vONE.war,id=1520512553 org.jboss.deployment.DeploymentException: URL file:/C:/ApplicationServer/jboss-4.2.2.GA/server/default/tmp/deploy/tmp41725myProject.ear-contents/vONE-exp.war/ deployment failed at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:379) at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104) at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375) ....The deployment works without failure, only when I delete the following two tags in 'components.xml'
this:
and that:
<core:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/vONEEntityManagerFactory"/>and add this:
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myEntityManagerFactory"/>When I add this in combining with the 'persistence:managed-persistence-context' :
the same stacktrace as above occurs:
08:52:00,219 INFO [Initialization] reading /WEB-INF/components.xml 08:52:00,235 ERROR [[/myProject]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.RuntimeException: error while reading /WEB-INF/components.xml at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:158) at org.jboss.seam.init.Initialization.create(Initialization.java:108) ....With the latest SEAM-Version (jboss-seam-2.1.0-SNAPSHOT) there is no need (and no possibility!?) to add this to 'faces-config.xml':
My Project was set up from the actual seam-gen as an EAR.
Hmm..where lies the problem?
(I only wanna use this new-nice IdentityManagement in an ordinary manner :-)
This caught my attention
Caused by: java.lang.NullPointerException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.jboss.seam.util.Reflections.classForName(Reflections.java:165)It might be that the Person class in
is not visible from the Correct Location(tm)
If a man speaks in the forest and there is no woman around to hear him, is he still wrong?
I am sure, that the Person class in 'com.model.Persons' exists and the the ear is right packaged.
Well, the problem can not lie here, cos when I delete that
and use only this
<core:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myProjectEntityManagerFactory"/>then the same stacktrace occurs!
That means the installing of 'core:managed-persistence-context' was not successfully.
When I use 'persistence:managed-persistence-context' instead of 'core:managed-persistence-context', this problem dissapears with no failure.
But I need the 'core:managed-persistence-context'. hmm...
I suggest you compare your components.xml to the one in the SeamSpace example.
<security:jpa-identity-store user-class="org.jboss.seam.example.seamspace.MemberAccount" role-class="org.jboss.seam.example.seamspace.MemberRole"/> <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-ame="java:/seamspaceEntityManagerFactory"/>Ensure that your namespaces are correct. I.e. The namespace for the identity management components is now http://jboss.com/products/seam/security.
I adapted the 'components.xml' from the one in seamspace-example:
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:security="http://jboss.com/products/seam/security" xmlns:identity-management="http://jboss.com/products/seam/security/management" xmlns:permission-management="http://jboss.com/products/seam/security/permission" xmlns:drools="http://jboss.com/products/seam/drools" xmlns:captcha="http://jboss.com/products/seam/captcha" xmlns:web="http://jboss.com/products/seam/web" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/security/management http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd http://jboss.com/products/seam/captcha http://jboss.com/products/seam/captcha-2.1.xsd"> <core:init jndi-pattern="@jndiPattern@" debug="false"/> <core:manager conversation-timeout="120000" concurrent-request-timeout="500" conversation-id-parameter="cid"/> <identity-management:jpa-identity-store user-class="com.model.Persons" role-class="com.model.Roles" /> <!--this is not a seam-management-persistence but is adapted from seamspace-example --> <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myEntityManagerFactory"/> <event type="org.jboss.seam.security.notLoggedIn"> <action execute="#{redirect.captureCurrentView}"/> </event> <event type="org.jboss.seam.security.loginSuccessful"> <action execute="#{redirect.returnToCapturedView}"/> </event> </components>but without success. The same failure (stacktrace) occurs:
I use (Seam nightly Build Nr. 222).
The EAR-deployment succeed ONLY when I do this:
I delete the tag:
<identity-management:jpa-identity-store user-class="com.model.Persons" role-class="com.model.Roles" />When I substitute this
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myEntityManagerFactory"/>with that
then the SAME failure-stacktrace as above occurs, even if I have no 'identity-management:jpa-identity-store' tag inserted. hmm...
I don't know which nightly build you have, but it seems to be way out of date. I recommmend you check out the latest version from SVN trunk and try that.
I had the same problem, and it's a problem in the seamspace example too, from my nightly after June 2. Shane mentioned the fix here:
So, instead of using the xmlns's from seamspace, use something like this:
<components xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:security="http://jboss.com/products/seam/security" xmlns:identity-management="http://jboss.com/products/seam/security" xmlns:permission-management="http://jboss.com/products/seam/security" xmlns:transaction="http://jboss.com/products/seam/transaction" xmlns:framework="http://jboss.com/products/seam/framework" xmlns:drools="http://jboss.com/products/seam/drools" xmlns:bpm="http://jboss.com/products/seam/bpm" xmlns:mail="http://jboss.com/products/seam/mail" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.1.xsd">Can a committer update seamspace, if you all haven't already?
My apologies, I thought this file was committed. I've checked it in now.
just a hint:
I don't know if it should be serializable.
greets Lars