[JBoss Seam] - testng unit tests not working with testng eclipse plugin sin
by knuwu
I had well working testng test in version 1.2.0 sp1, i could execute from ant or inside eclipse with the testng pugling.
Since 1.2.1 GA i get the following error message when i execute my login tests:
| "[RuleBasedIdentity] no security rule base available - please install a RuleBase with the name 'securityRules' if permission checks are required."
|
Full stack trace:
| [Parser] Running:
| C:\seat\workspace\aldebaran\src\test\com\swisscom\seat\services\security\test\testngServiceSecurityTest.xml
|
| 14:47:08,821 INFO [Scanner] scanning: /C:/seat/workspace/aldebaran/lib/jboss-seam.jar
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/security, package: org.jboss.seam.security, prefix: org.jboss.seam.security
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/drools, package: org.jboss.seam.drools, prefix: org.jboss.seam.drools
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/mail, package: org.jboss.seam.mail, prefix: org.jboss.seam.mail
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/web, package: org.jboss.seam.web, prefix: org.jboss.seam.web
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/theme, package: org.jboss.seam.theme, prefix: org.jboss.seam.theme
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/core, package: org.jboss.seam.core, prefix: org.jboss.seam.core
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/jms, package: org.jboss.seam.jms, prefix: org.jboss.seam.jms
| 14:47:08,837 INFO [Initialization] Namespace: http://jboss.com/products/seam/framework, package: org.jboss.seam.framework, prefix: org.jboss.seam.core.framework
| 14:47:08,837 INFO [Scanner] scanning: /C:/seat/workspace/aldebaran/lib/jboss-seam-debug.jar
| 14:47:08,837 INFO [Scanner] scanning: /C:/seat/workspace/aldebaran/lib/jboss-seam-ui.jar
| 14:47:08,853 INFO [Initialization] reading jar:file:/C:/seat/workspace/aldebaran/lib/jboss-seam.jar!/META-INF/components.xml
| 14:47:08,962 INFO [Initialization] reading properties from: /seam.properties
| 14:47:08,962 INFO [Initialization] reading properties from: /jndi.properties
| 14:47:08,962 INFO [Initialization] initializing Seam
| 14:47:08,993 INFO [Scanner] scanning: /C:/seat/workspace/aldebaran/lib/jboss-seam-debug.jar
| 14:47:09,071 INFO [Scanner] scanning: /C:/seat/workspace/aldebaran/lib/jboss-seam-ui.jar
| 14:47:09,274 INFO [Scanner] scanning: /C:/seat/workspace/aldebaran/lib/jboss-seam.jar
| 14:47:10,257 INFO [Initialization] two components with same name, higher precedence wins: org.jboss.seam.persistence.persistenceProvider
| 14:47:10,273 INFO [Initialization] two components with same name, higher precedence wins: org.jboss.seam.security.identity
| 14:47:10,304 INFO [Component] Component: org.jboss.seam.core.init, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Init
| 14:47:10,351 INFO [Initialization] Installing components...
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.applicationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ApplicationContext
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.businessProcessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.BusinessProcessContext
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.conversation, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Conversation
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.conversationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationContext
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.conversationEntries, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationEntries
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.conversationList, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationList
| 14:47:10,367 INFO [Component] Component: org.jboss.seam.core.conversationStack, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationStack
| 14:47:10,382 INFO [Component] Component: org.jboss.seam.core.eventContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.EventContext
| 14:47:10,382 INFO [Component] Component: org.jboss.seam.core.events, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Events
| 14:47:10,382 INFO [Component] Component: org.jboss.seam.core.exceptions, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Exceptions
| 14:47:10,382 INFO [Component] Component: org.jboss.seam.core.expressions, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Expressions
| 14:47:10,382 INFO [Component] Component: org.jboss.seam.core.facesContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesContext
| 14:47:10,382 INFO [Component] Component: org.jboss.seam.core.facesMessages, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesMessages
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.facesPage, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.FacesPage
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.httpError, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.HttpError
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.image, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Image
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.interpolator, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Interpolator
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.isUserInRole, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.IsUserInRole
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.locale, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Locale
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.localeSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.LocaleSelector
| 14:47:10,398 INFO [Component] Component: org.jboss.seam.core.manager, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.core.Manager
| 14:47:10,413 INFO [Component] Component: org.jboss.seam.core.messages, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.Messages
| 14:47:10,413 INFO [Component] Component: org.jboss.seam.core.methodContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.MethodContext
| 14:47:10,413 INFO [Component] Component: org.jboss.seam.core.pageContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.PageContext
| 14:47:10,413 INFO [Component] Component: org.jboss.seam.core.pages, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Pages
| 14:47:10,429 INFO [Component] Component: org.jboss.seam.core.persistenceContexts, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.PersistenceContexts
| 14:47:10,460 INFO [Component] Component: org.jboss.seam.core.pojoCache, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.PojoCache
| 14:47:10,460 INFO [Component] Component: org.jboss.seam.core.redirect, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Redirect
| 14:47:10,460 INFO [Component] Component: org.jboss.seam.core.renderer, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.ui.facelet.FaceletsRenderer
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.resourceBundle, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.ResourceBundle
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.safeActions, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.SafeActions
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.sessionContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.SessionContext
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.switcher, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.Switcher
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.uiComponent, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.UiComponent
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.userPrincipal, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.UserPrincipal
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.validation, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.core.Validation
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.core.validators, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Validators
| 14:47:10,476 INFO [Component] Component: org.jboss.seam.framework.currentDate, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.framework.CurrentDate
| 14:47:10,507 INFO [Component] Component: org.jboss.seam.framework.currentDatetime, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.framework.CurrentDatetime
| 14:47:10,507 INFO [Component] Component: org.jboss.seam.framework.currentTime, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.framework.CurrentTime
| 14:47:10,507 INFO [Component] Component: org.jboss.seam.security.configuration, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.security.Configuration
| 14:47:10,507 INFO [Component] Component: org.jboss.seam.security.identity, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.security.RuleBasedIdentity
| 14:47:10,507 INFO [Component] Component: org.jboss.seam.servlet.exceptionFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.ExceptionFilter
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.servlet.multipartFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.MultipartFilter
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.servlet.redirectFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.RedirectFilter
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.theme.theme, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.theme.Theme
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.theme.themeSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.theme.ThemeSelector
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.ui.entityConverter, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.ui.EntityConverter
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.ui.entityConverterStore, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.ui.EntityConverterStore
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.ui.graphicImage.dynamicImageResource, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.ui.graphicImage.DynamicImageResource
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.ui.graphicImage.dynamicImageStore, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.ui.graphicImage.DynamicImageStore
| 14:47:10,523 INFO [Component] Component: org.jboss.seam.ui.resource.webResource, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.ui.resource.WebResource
| 14:47:10,538 INFO [Lifecycle] starting up: org.jboss.seam.servlet.exceptionFilter
| 14:47:10,538 INFO [Lifecycle] starting up: org.jboss.seam.ui.graphicImage.dynamicImageResource
| 14:47:10,538 INFO [Lifecycle] starting up: org.jboss.seam.servlet.multipartFilter
| 14:47:10,538 INFO [Lifecycle] starting up: org.jboss.seam.ui.resource.webResource
| 14:47:10,538 INFO [Lifecycle] starting up: org.jboss.seam.servlet.redirectFilter
| 14:47:10,538 INFO [Initialization] done initializing Seam
| 14:47:10,679 WARN [RuleBasedIdentity] no security rule base available - please install a RuleBase with the name 'securityRules' if permission checks are required.
| 14:47:10,710 ERROR [SeamLoginModule] Error invoking login method
| java.lang.NullPointerException
| 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:36)
| 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.swisscom.seat.services.security.test.LoginTest$2.invokeApplication(LoginTest.java:39)
| at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
| at com.swisscom.seat.services.security.test.LoginTest.loginTest(LoginTest.java:50)
| 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.remote.RemoteTestNG.run(RemoteTestNG.java:73)
| at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
| FAILED: loginTest("tsggora1", "test")
| javax.el.PropertyNotFoundException: ELResolver cannot handle a null base Object with identifier 'currentUser'
| at com.sun.el.lang.ELSupport.throwUnhandled(ELSupport.java:52)
| at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:75)
| at com.sun.el.parser.AstValue.getValue(AstValue.java:114)
| at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:195)
| at org.jboss.seam.util.UnifiedELValueBinding.getValue(UnifiedELValueBinding.java:34)
| at org.jboss.seam.mock.SeamTest$Request.getValue(SeamTest.java:366)
| at com.swisscom.seat.services.security.test.LoginTest$2.renderResponse(LoginTest.java:44)
| at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:521)
| at com.swisscom.seat.services.security.test.LoginTest.loginTest(LoginTest.java:50)
| ... Removed 21 stack frames
|
| ===============================================
| Security Tests
| Tests run: 1, Failures: 1, Skips: 0
| ===============================================
|
|
| ===============================================
| Security Tests
| Total tests run: 1, Failures: 1, Skips: 0
| ===============================================
|
The test class is looking like that:
| package com.swisscom.seat.services.security.test;
|
| import java.util.List;
|
| import org.jboss.seam.Seam;
| import org.jboss.seam.core.Manager;
| import org.jboss.seam.mock.SeamTest;
| import org.testng.annotations.Parameters;
| import org.testng.annotations.Test;
|
| public class LoginTest extends SeamTest {
|
| @Parameters( { "userid", "password" })
| @Test( groups = {"functional"} )
| public void loginTest(final String userid, final String password)
| 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}", userid);
| setValue("#{identity.password}", password);
| }
|
| @Override
| protected void invokeApplication() {
| invokeMethod("#{identity.login}");
| }
|
| @Override
| protected void renderResponse() {
| assert getValue("#{currentUser.userid}").equals(userid);
| assert !Manager.instance().isLongRunningConversation();
| assert ((List) getValue("#{currentUser.roles}")).size() > 0;
| 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();
|
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034533#4034533
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034533
19 years
[JBoss Seam] - rule based security - hard wired names in ant project
by knuwu
I'm a little bit unhappy with some hard wired dependencies, in case you are using the seam-gen generated ant eclipse project for deploying the application.
If you are looking to the components.xml Konfiguration you might get the feeling, that you are free to name and position your xxx.drl rule file.
| <security:identity authenticate-method="#{authenticator.authenticate}"
| security-rules="#{securityRules}" />
|
| <drools:rule-base name="securityRules">
| <drools:rule-files>
| <value>/security.drl</value>
| </drools:rule-files>
| </drools:rule-base>
|
But if you looking to the ant build.xml you see:
| <target name="ear" description="Build the EAR">
| <copy todir="${ear.dir}">
| <fileset dir="${basedir}/resources">
| <include name="*jpdl.xml" />
| <include name="hibernate.cfg.xml" />
| <include name="jbpm.cfg.xml" />
| <include name="security.drl" />
| </fileset>
| ....
|
Even worst - if you take a look to class org.jboss.seam.security.RuleBasedIdentity you see:
| protected void initSecurityContext()
| {
| if (securityRules==null)
| {
| securityRules = (RuleBase) Component.getInstance(RULES_COMPONENT_NAME, true);
| }
|
| if (securityRules != null)
| {
| securityContext = securityRules.newWorkingMemory(false);
| }
|
| if (securityContext == null)
| {
| log.warn("no security rule base available - please install a RuleBase with the name '" +
| RULES_COMPONENT_NAME + "' if permission checks are required.");
| }
| }
|
where RULES_COMPONENT_NAME has the value "securityRules" which fixes the name of your rule base.
If you take a look in the manual, you find this example:
| <drools:rule-base name="securityRules">
| <drools:rule-files>
| <value>/META-INF/security.drl</value>
| </drools:rule-files>
| </drools:rule-base>
|
This simply does not work since the seam-gen generated build.xml ant project only deploys a file called security.drl position in the /resources directory.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034528#4034528
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034528
19 years
[JBoss jBPM] - Re: Errors with global transactions on oracle
by kukeltje
I hope the DBA does not make the decisions:
Product Obsolescence / Desupport Information:
Oracle Corporation announces the end of Error Correction Support for Oracle Database version(s) 8.1.7 (8i) & 8.1.7.x (8i) on the following platform(s): Microsoft Windows XP, Microsoft Windows 2000, Linux x86, HP-UX PA-RISC, IBM OS/390 (z/OS) version(s) ALL - OSDI, excluding MPM, Microsoft Windows 98, HP Tru64 UNIX, HP Alpha OpenVMS, Solaris Operating System (x86), IBM AIX-Based Systems version(s) 5L, Fujitsu-Siemens BS2000/OSD, Solaris Operating System (SPARC), Microsoft Windows NT for Intel, effective 31-DEC-2004.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034527#4034527
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034527
19 years
[JBoss Seam] - Re: entityManager.persist(Object) not working?
by argonist
I think I have a similar problem like that post. That's why, I join that post.
Suse 10.2 JBOSS 4.0.5.GA EJB 3.0
I tried to get a data from mysql using manager.createQuery(); But entityManager is not working.
Bean
| @Stateless
| public class ContentBean implements ContentInterface
| {
| @PersistenceContext(unitName="ponte")
| EntityManager manager;
|
| public String getContent(long id) {
| Query query = manager.createQuery(
| "select content.content from HTML_CONTENT content where content.id = :id");
| query.setParameter("id", id);
| try{
| String result = (String) query.getSingleResult();
| System.out.println("id = " + id);
| System.out.println("result");
| return result;
| }catch(Exception e){
| System.out.println("Error");
| return "<NULL>";
| }
| }
| }
|
Data
| @Entity
| @Table(name="HTML_CONTENT")
| public class HtmlContent implements Serializable{
|
| private static final long serialVersionUID = 1L;
|
| @Id
| @Column(name="ID")
| private long id;
|
| @Column(name="CONTENT")
| private String content;
|
| public void setId(long id) {
| this.id = id;
| }
|
| public long getId() {
| return id;
| }
|
| public void setContent(String content) {
| this.content = content;
| }
|
| public String getContent() {
| return content;
| }
| }
|
persistence.xml
| <?xml version="1.0" encoding="UTF-8"?>
|
| <persistence>
| <persistence-unit name="ponte">
| <jta-data-source>java:/MySqlDS</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="none" />
| <property name="hibernate.dialect"
| value="org.hibernate.dialect.MySQLInnoDBDialect" />
| </properties>
| </persistence-unit>
| </persistence>
|
I tried to add @TransactionAttribut annotation, but it is still not working.
Konsole Output after invoking this methode getContent() :
anonymous wrote :
| 13:39:47,670 INFO [STDOUT] [Ljava.lang.StackTraceElement;@503cb2
|
Can someone tell me, what is wrong, or? Thanks
regards
Manu
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034516#4034516
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034516
19 years