[Security & JAAS/JBoss] - Help me about JBoss with JAAS !!
by changemylife
Hi all!
At present, I use EJB3. and use Eclipse to write and deploy my EJB project. I have a bean called CalculatorBean. My bean has two method: "add" and "sub" two number. On the client side, I write the class called MyLoginModule to authenticate user (it always return true). After call the method, I receive a Subject with some informations (ex:username, password, rolename...):
.....
lc.login();
Subject sub = lc.getSubject();
.... to here, I want use JNDI to send server a user that authenticated. So, how I continue? And inside EJB3.0, I need write login-config.xml and jboss.xml ?. (Because, when I read about EJB3.0's Orielly, I don't see two this file !!).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008273#4008273
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008273
19 years, 2 months
[JBoss Portal] - Howto, when user logs out, invalidate session & remove all e
by michaelsembwever
I'm having problems with my JBoss Portal Seam application.
I have two portlets, one for my application and the other to handle user
actions (eg my preferences and log out).
When the user logs out in one portlet my seam actions (and it's ejb3s) are
not passivated. When the session timeouts sometime later then they are
passivated.
This is not acceptable for us, for security and application reasons as
soon as the user logs out we need all ejb3s to be removed. If the logout
action was within the same application portlet it wouldn't be an issue,
but there appears to be no way to remove ejb3s from a different portlet.
I've tried to through the PolicyContext getting the HttpSession and calling
invalidate on it. But it throws an exception because the response has
already been committed.
I've searched for some way to trigger a EJB3 cache cleanup, presuming that
the EJB3s in my application portlet are otherwise ready to passivate but
that the cache just needs to see it, without finding any API to help.
The only way I can think of solving this is using MessageDrivenBeans that
the logout action sends a message and my application can listen to and
manually call remove on my ejb3s.
But I just can't believe this is the correct way to do something that
should be so simple.
Have I missed some really obvious way to invalidate my session and force
remove all my ejb3s?
Or does anyone have any other way to achieve this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008272#4008272
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008272
19 years, 2 months
[EJB 3.0] - jdbc Query Timeout ( Is This a Bug? )
by grdzeli_kaci
hi all,
i have one problem whole week, and could not resolve.
enviroment :
1. AS - Jboss Application Server 4.0.4 GA or Jboss Application Server 4.04 GA (i tryed both of them)
2.ThierdParty/Database - Oracle Timesten In Memory DataBase
3.EJB 3.0.EJB3 RC7 (for JBoss 4.0.4) EJB 3.0.EJB3 RC9 Patch 1 (For JBoss 4.0.5)
4.OS - Solaris, Suse Linux, Windows XP (I tryed on all of them)
5.ThierdParty/DataBase Driver - classes14.jar (1.5.0_04 (Sun Microsystems Inc.))
task : i need use named query search from session beans
my project snipets:
1. jboss Timesten Datasource Configuration :
| <datasources>
| <xa-datasource>
| <jndi-name>TimesTenXAClientDS</jndi-name>
| <xa-datasource-class>
| com.timesten.jdbc.xa.TimesTenXADataSource
| </xa-datasource-class>
| <xa-datasource-property name="Url">
| jdbc:timesten:client:Test34
| </xa-datasource-property>
| <user-name></user-name>
| <password></password>
| <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
| <!--pooling parameters-->
| <min-pool-size>5</min-pool-size>
| <max-pool-size>100</max-pool-size>
| <blocking-timeout-millis>5000</blocking-timeout-millis>
| <idle-timeout-minutes>15</idle-timeout-minutes>
| <prepared-statement-cache-size>32</prepared-statement-cache-size>
| <track-connection-by-tx/>
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
| <metadata>
| <type-mapping>TimesTen</type-mapping>
| </metadata>
| </xa-datasource>
| </datasources>
|
2. Database Table :
| create table "RT"."SUBSCRIBERS" ("SUBSCRIBERID" INTEGER not null,
| "CHARGINGPROFILEID" INTEGER not null, "STATUSID" INTEGER not null,
| "TSTAMP" BINARY(8), constraint "RT"."SUBSCRIBERS" primary key
| ("SUBSCRIBERID"))
|
3. Entity Bean :
| package com.magti.businesslayer.ejb3entity.oracle;
| import java.io.Serializable;
| import org.apache.commons.lang.builder.ToStringBuilder;
| import javax.persistence.*;
|
| @NamedQueries
| ({
| @NamedQuery(name="Subscriber.getSubscriber",query="select e from Subscriber e where e.subscriberid = :subsId")
| })
|
| @Entity()
| @Table(name="SUBSCRIBERS", schema="RT")
| public class Subscriber implements Serializable {
| //default serial version id, required for serializable classes.
| private static final long serialVersionUID = 1L;
| private Integer subscriberid;
| private int chargingprofileid;
| private int statusid;
| private byte [] tstamp;
|
| public Subscriber() {
| }
|
| @Id()
| @Column(name="SUBSCRIBERID", unique=true, nullable=false, precision=10)
| public Integer getSubscriberid() {
| return this.subscriberid;
| }
| public void setSubscriberid(Integer subscriberid) {
| this.subscriberid = subscriberid;
| }
|
| @Basic()
| @Column(name="CHARGINGPROFILEID", nullable=false, precision=10)
| public int getChargingprofileid() {
| return this.chargingprofileid;
| }
| public void setChargingprofileid(int chargingprofileid) {
| this.chargingprofileid = chargingprofileid;
| }
|
| @Basic()
| @Column(name="STATUSID", nullable=false, precision=10)
| public int getStatusid() {
| return this.statusid;
| }
| public void setStatusid(int statusid) {
| this.statusid = statusid;
| }
|
| public String toString() {
| return new ToStringBuilder(this)
| .append("subscriberid", getSubscriberid())
| .toString();
| }
| @Basic()
| @Column(name="TSTAMP", nullable=true)
| public byte[] getTstamp() {
| return tstamp;
| }
|
| public void setTstamp(byte[] tstamp) {
| this.tstamp = tstamp;
| }
| }
|
4. Remote Interface :
| package com.magti.businesslayer.ejb3entity.businesslayer;
| import javax.ejb.Remote;
| @Remote
| public interface SubscriberOperations {
| public void insertSubscriber() throws Exception;
| public void updateSubscriber() throws Exception;
| public void getSubscriber() throws Exception;
| }
|
4. Remote Interface Implementation (Session bean) :
| package com.magti.businesslayer.ejb3entity.businesslayer;
|
| import java.util.List;
|
| import javax.ejb.Remote;
| import javax.ejb.Stateful;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import com.magti.businesslayer.ejb3entity.businesslayer.SubscriberOperations;
| import com.magti.businesslayer.ejb3entity.oracle.Subscriber;
|
| @Remote(SubscriberOperations.class)
| @Stateful
| public class SubscriberOperationsBean implements SubscriberOperations {
|
| @PersistenceContext(unitName = "Blaaaaaaaaaaaaaaaaa")
| private EntityManager timeStenMan;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void insertSubscriber() throws Exception {
| try {
| System.out.println("Start Persisting");
| Subscriber subscriber = new Subscriber();
| subscriber.setTstamp(null);
| subscriber.setChargingprofileid(123123123);
| subscriber.setStatusid(123123123);
| timeStenMan.persist(subscriber);
| System.out.println("End Of Persisting");
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void updateSubscriber() throws Exception {
| try {
|
| System.out.println("Start Updateing");
| Subscriber subscriber = new Subscriber();
| subscriber.setSubscriberid(606244);
| subscriber.setTstamp(null);
| subscriber.setChargingprofileid(312312312);
| subscriber.setStatusid(312312312);
| timeStenMan.merge(subscriber);
| System.out.println("End Of Updateing");
|
| } catch (Exception e) {
| e.printStackTrace();
| }
|
| }
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void getSubscriber() throws Exception {
| try {
| System.out.println("Start Searching");
| List<Subscriber> subscribers = (List<Subscriber>) timeStenMan
| .createNamedQuery("Subscriber.getSubscriber").setParameter(
| "subsId", new Integer(606244)).getResultList();
| System.out.println("End Of Searching");
|
| System.out.println("List Size = " + subscribers.size());
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
| }
|
5. persistance.xml file :
| <?xml version="1.0" encoding="ISO-8859-1" ?>
| <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="Blaaaaaaaaaaaaaaaaa">
| <jta-data-source>java:/TimesTenXAClientDS</jta-data-source>
| <class>com.magti.businesslayer.ejb3entity.oracle.Subscriber</class>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
| <property name="hibernate.connection.driver_class" value="com.timesten.jdbc.xa.TimesTenXADataSource"/>
| <property name="hibernate.connection.url" value="jdbc:timesten:client:Test34"/>
| <property name="hibernate.connection.username" value=""/>
| <property name="hibernate.connection.password" value=""/>
| <property name="hibernate.default_schema" value="RT"/>
| <property name="hibernate.show_sql" value="true"/>
| <property name="hibernate.format_sql" value="true"/>
| </properties>
| </persistence-unit>
| </persistence>
|
6. and at last my test client :
| package com.magti.businesslayer.ejb3entity.oracle;
|
| import java.util.Properties;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
|
| import com.magti.businesslayer.ejb3entity.businesslayer.SubscriberOperations;
|
| public class TestMain {
| public static void main(String[] args) {
| try {
| Properties jndiProps = new Properties();
| jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| jndiProps.setProperty(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interface");
| jndiProps.setProperty(Context.PROVIDER_URL,
| "jnp://192.168.9.136:1099");
| InitialContext ctx = new InitialContext(jndiProps);
|
| SubscriberOperations ops = (SubscriberOperations) ctx
| .lookup("SubscriberOperationsBean/remote");
|
| // Test Searching
| ops.getSubscriber();
| // End Of Test Searching
|
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
| }
|
and i get an error like this :
| java.sql.SQLException: [TimesTen][TimesTen 6.0.4 CLIENT]Query Timeout must be numeric, greater than or equal to 0, and less than the Network Timeout
| at com.timesten.jdbc.JdbcOdbc.createSQLException(JdbcOdbc.java:7307)
| at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:7440)
| at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:7405)
| at com.timesten.jdbc.JdbcOdbc.SQLSetStmtOption(JdbcOdbc.java:6679)
| at com.timesten.jdbc.JdbcOdbcStatement.setStmtOption(JdbcOdbcStatement.java:1883)
| at com.timesten.jdbc.JdbcOdbcStatement.setQueryTimeout(JdbcOdbcStatement.java:720)
| at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.close(CachedPreparedStatement.java:339)
| at org.jboss.resource.adapter.jdbc.WrappedStatement.internalClose(WrappedStatement.java:588)
| at org.jboss.resource.adapter.jdbc.WrappedStatement.close(WrappedStatement.java:73)
| at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:526)
| at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:265)
| at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:281)
| at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:209)
| at org.hibernate.loader.Loader.doQuery(Loader.java:714)
| at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
| at org.hibernate.loader.Loader.doList(Loader.java:2145)
| at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
| at org.hibernate.loader.Loader.list(Loader.java:2024)
| at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:392)
| at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:333)
| at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
| at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
| at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
| at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:53)
| at com.magti.businesslayer.ejb3Fasade.srvprov.MobileServiceFasadeBean.test(MobileServiceFasadeBean.java:1467)
| 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.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:297)
| at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
| at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
| at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
| at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
| 30 Jan 07 12:31:23, DEBUG org.apache.commons.logging.impl.Log4JLogger:debug:84 about to open ResultSet (open ResultSets: 0, globally: 0)
| 30 Jan 07 12:31:23, WARN org.apache.commons.logging.impl.Log4JLogger:warn:104 SQL Error: 0, SQLState: S1000
| 30 Jan 07 12:31:23, DEBUG org.apache.commons.logging.impl.Log4JLogger:debug:84 result row:
| 30 Jan 07 12:31:23, ERROR org.apache.commons.logging.impl.Log4JLogger:error:114 [TimesTen][TimesTen 6.0.4 CLIENT]Query Timeout must be numeric, greater than or equal to 0, and less than the Network Timeout
| 30 Jan 07 12:31:23, DEBUG org.apache.commons.logging.impl.Log4JLogger:debug:84 about to close ResultSet (open ResultSets: 1, globally: 1)
| 30 Jan 07 12:31:23, DEBUG org.apache.commons.logging.impl.Log4JLogger:debug:84 about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 30 Jan 07 12:31:23, DEBUG org.apache.commons.logging.impl.Log4JLogger:debug:84 aggressively releasing JDBC connection
| 30 Jan 07 12:31:23, DEBUG org.apache.commons.logging.impl.Log4JLogger:debug:84 releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
|
|
i thougt that it mey be bug in timesten but when i tryed the same task without jboss and ejb 3 into stand alone client it works ....
is there any idea ? :(
i am nto sure but i think this bug into hibrnate or jboss.
if this is a bug can i report it in jira ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008271#4008271
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008271
19 years, 2 months
[JBoss jBPM] - jBPM and Seam - best way to create project in Eclipse
by damianharvey
Hi,
What is the best way to setup a project in Eclipse so that it uses both Seam and jBPM?
Currently, I am creating the project skeleton using Seam-gen (seam setup & seam new-project). My understanding is that the following are required in order to add jBPM to this project:
- jbpm.3.1.2.jar (included with Seam)
- jbpm.cfg.xml
- hibernate.cfg.xml
- components.xml pointing to jBPM component
1. I add all of these but get an error on deploy saying that org/jbpm/identity/User.hbm.xml could not be found (it is in jbpm-identity-3.1.1.jar). Even adding this to the buildpath doesn't resolve.
2. The other issue that I'm confused about is that all of the Seam examples have jBPM flows as flowname.jpdl.xml whereas the flows created by Eclipse (new -> JBoss jBPM -> Process Definition) are in a folder structure with a gpd.xml and processdefinition.xml. This seems inconsistent.
For the *.jpdl.xml it seems easy to set components.xml to <core:process-definitions><value>processName.jpdl.xml</value></core:process-definitions>
but what do you put when you have gpd.xml?
Sorry if these are obvious, I'm still new to this.
Thanks,
Damian.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008267#4008267
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008267
19 years, 2 months
[JBoss Seam] - Re: Seam + EJB3 performance
by fhh
Just to add some information from the db perspective:
anonymous wrote :
| Being impressed by long SQL statements generated by Hibernate and understanding that most of them are not required I decided that I need to try an idea of SFSB as backing bean. I annotated all the relations among entities as fetch=lazy. So all the requests that are generated during page rendering are single select without joins. Tree-related requests are generated only when expanding a node. Thus I don't think that Hibernate or DB is the cause.
|
This IS a database problem. A join can be an expensive database operation but that is what RDBMs are made for. A per-row subselect is even worse but if you do a single select for _every_ row you eventually want to fetch you will kill any database.
Why? First of all you have to parse the statements. This is very expensive if your database or JPA provider does not support PreparedStatements (Does Hibernate?).
Secondly the database will analyze the query to find out which is the most efficient way to fetch the data. If you send 500 single queries instead of one "big" query it will do that 500 times - and will get the wrong result anyway.
If you have a table with 50000 rows with an indexed pk that is fetched lazily in the way you describe then the database will look at the index and read the block which contains the the row indentified by the index for every single query. Each of this operation is fast but this will happen 50000 times. Since the blocks contains more than one row, blocks will have to be read again and again.
If you do this in one big select, it will just read all the blocks and send it to you. No index is needed and each block is only read once. This is way faster.
So the idea behind lazy loading Lazy loading is not to avoid joins but rather to avoid fetching unneccessary data. Imagine you have an entity relationship between an Entity called "country" which has a collection "citizens". Now your database has all 180 countries and 6,500,000,000 persons.
Now you want to list all countries. If "citizens" was fetched eagerly you would retrieve 6,500,000,000 rows from the database to display information about the 180 countries. This would be ridicolous. If you fetch lazily, you will only get 180 rows at the beginning. The records in the table holding the citizens are only retrieved if they are actually needed.
I hope this explains the concept behind lazy loading.
Regards
Felix
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008266#4008266
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008266
19 years, 2 months
[JBoss Portal] - Saving object in PortletSession
by herveminko
Hi guys,
I have a problem aving objects in a PortletSession. I want to save obejcts i nthe PortletSession of JBoss Portal 2.2.1 using the method setAttribute(key, Value, PortletSession.APPLICATION_SCOPE), because those attributes must be shared with other Portlers of the same Portlet Application. My java code looks like:
ArrayList myObjects = MYClass.getMyObjects();
session.setAttribute("obj", myObjects, PortletSession.APPLICATION_SCOPE);
After doing this, i want to retrieve my saved objects with the statement:
ArrayList myObjects2 = session.get("obj");
Unfortunately i get "null" as return value, because the key "obj" is not present in the PortletSession object. After investigating the cause of this strange behaviour, i found out that my obects are not stored with my choses kex "obj", but with the key "jbp19367721obj".
jbp19367721 seems to be the window ID of my portlet window. Is there a possibility to store objects in the application scope without using this window ID? Is it a particularity of JBoss Portal 2.2.1? It is very important for me to find a way to sidestep this window ID for saving my attributes in the PortletSession.
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008264#4008264
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008264
19 years, 2 months