[EJB 3.0] - CMP type mapping for String with Postgres
by mcgrathl
I switched my DefaultDS to PostgreSQL using directions similar to this: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3951811
I edited the datasource-mapping element of standardjbosscmp-jdbc.xml so that it looks like the one below. The mapping below seems to specify that objects of type java.lang.String should be stored in columns of type TEXT (which are variable in length with no limit), however, columns of type varchar(255) (which are variable in length with limit of 255) are getting created in my database for Strings. Do I understand this correctly? Could I be missing something?
(Another possibly related thing I noticed since switching this file is that it's almost almost seems like the reserved-words portion of this file is being ignored. I had an entity bean named User that never caused problems when hsqldb was the defaultds, but now it errors when trying to create a table named User.)
Thanks
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE jbosscmp-jdbc PUBLIC
| "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
| "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
|
| <!-- ===================================================================== -->
| <!-- -->
| <!-- Standard JBossCMP-JDBC Configuration -->
| <!-- -->
| <!-- ===================================================================== -->
|
| <!-- $Id: standardjbosscmp-jdbc.xml,v 1.84.2.8 2006/03/06 14:38:05 aloubyansky Exp $ -->
|
| <jbosscmp-jdbc>
|
| <defaults>
| <datasource>java:/DefaultDS</datasource>
| <datasource-mapping>PostgreSQL</datasource-mapping>
|
| <create-table>true</create-table>
| <remove-table>false</remove-table>
| <read-only>false</read-only>
| <read-time-out>300000</read-time-out>
| <row-locking>false</row-locking>
| <pk-constraint>true</pk-constraint>
| <fk-constraint>false</fk-constraint>
| <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
| <read-ahead>
| <strategy>on-load</strategy>
| <page-size>1000</page-size>
| <eager-load-group>*</eager-load-group>
| </read-ahead>
| <list-cache-max>1000</list-cache-max>
| <clean-read-ahead-on-load>false</clean-read-ahead-on-load>
|
| <unknown-pk>
| <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory>
| <unknown-pk-class>java.lang.String</unknown-pk-class>
| <jdbc-type>VARCHAR</jdbc-type>
| <sql-type>VARCHAR(32)</sql-type>
| </unknown-pk>
|
| <entity-command name="default"/>
| <ql-compiler>org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLCompiler</ql-compiler>
| <throw-runtime-exceptions>false</throw-runtime-exceptions>
| </defaults>
|
| <type-mappings>
|
| (snip)-----------------------------------------
|
| <type-mapping>
| <name>PostgreSQL</name>
| <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 ORDER BY ?4 FOR UPDATE</row-locking-template>
| <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
| <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
| <auto-increment-template>?1</auto-increment-template>
| <alias-header-prefix>t</alias-header-prefix>
| <alias-header-suffix>_</alias-header-suffix>
| <alias-max-length>32</alias-max-length>
| <subquery-supported>true</subquery-supported>
| <true-mapping>TRUE</true-mapping>
| <false-mapping>FALSE</false-mapping>
|
| <function-mapping>
| <function-name>concat</function-name>
| <function-sql>(?1 || ?2)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>substring</function-name>
| <function-sql>substring(?1 FROM ?2 FOR ?3)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>lcase</function-name>
| <function-sql>lower(?1)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>length</function-name>
| <function-sql>length(?1)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>locate</function-name>
| <function-sql>(CASE position(?1 in substring(?2 from ?3)) WHEN 0 THEN 0 ELSE position(?1 in substring(?2 from ?3)) + ?3 - 1 END)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>abs</function-name>
| <function-sql>abs(?1)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>sqrt</function-name>
| <function-sql>sqrt(CAST(?1 AS double precision))</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>ucase</function-name>
| <function-sql>upper(?1)</function-sql>
| </function-mapping>
| <function-mapping>
| <function-name>count</function-name>
| <function-sql>count(?1)</function-sql>
| </function-mapping>
|
| <mapping>
| <java-type>java.lang.Boolean</java-type>
| <jdbc-type>CHAR</jdbc-type>
| <sql-type>BOOLEAN</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Byte</java-type>
| <jdbc-type>TINYINT</jdbc-type>
| <sql-type>INT2</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Short</java-type>
| <jdbc-type>SMALLINT</jdbc-type>
| <sql-type>INT2</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Integer</java-type>
| <jdbc-type>INTEGER</jdbc-type>
| <sql-type>INT4</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Long</java-type>
| <jdbc-type>BIGINT</jdbc-type>
| <sql-type>INT8</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Float</java-type>
| <jdbc-type>FLOAT</jdbc-type>
| <sql-type>FLOAT(7)</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Double</java-type>
| <jdbc-type>DOUBLE</jdbc-type>
| <sql-type>FLOAT8</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Character</java-type>
| <jdbc-type>CHAR</jdbc-type>
| <sql-type>CHAR(1)</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.String</java-type>
| <jdbc-type>VARCHAR</jdbc-type>
| <sql-type>TEXT</sql-type>
| </mapping>
| <mapping>
| <java-type>java.util.Date</java-type>
| <jdbc-type>TIMESTAMP</jdbc-type>
| <sql-type>TIMESTAMP with time zone</sql-type>
| </mapping>
| <mapping>
| <java-type>java.sql.Date</java-type>
| <jdbc-type>DATE</jdbc-type>
| <sql-type>DATE</sql-type>
| </mapping>
| <mapping>
| <java-type>java.sql.Time</java-type>
| <jdbc-type>TIME</jdbc-type>
| <sql-type>TIME</sql-type>
| </mapping>
| <mapping>
| <java-type>java.sql.Timestamp</java-type>
| <jdbc-type>TIMESTAMP</jdbc-type>
| <sql-type>TIMESTAMP with time zone</sql-type>
| </mapping>
| <mapping>
| <java-type>java.math.BigDecimal</java-type>
| <jdbc-type>NUMERIC</jdbc-type>
| <sql-type>NUMERIC</sql-type>
| </mapping>
| <mapping>
| <java-type>java.lang.Object</java-type>
| <jdbc-type>VARBINARY</jdbc-type>
| <sql-type>BYTEA</sql-type>
| </mapping>
| </type-mapping>
|
| (snip)-------------------------------------------------
|
| <!-- reserved words that should not be used as table names -->
| <!-- JBoss will escape them by prepending a 'X' -->
| <reserved-words>
| <word>alias</word>
| <word>alter</word>
| <word>between</word>
| <word>char</word>
| <word>column</word>
| <word>commit</word>
| <word>create</word>
| <word>date</word>
| <word>default</word>
| <word>delete</word>
| <word>drop</word>
| <word>file</word>
| <word>from</word>
| <word>grant</word>
| <word>group</word>
| <word>index</word>
| <word>integer</word>
| <word>join</word>
| <word>number</word>
| <word>on</word>
| <word>order</word>
| <word>primary</word>
| <word>public</word>
| <word>revoke</word>
| <word>rollback</word>
| <word>row</word>
| <word>select</word>
| <word>set</word>
| <word>session</word>
| <word>size</word>
| <word>table</word>
| <word>trigger</word>
| <word>update</word>
| <word>unique</word>
| <word>user</word>
| <word>varchar</word>
| <word>view</word>
| </reserved-words>
| </jbosscmp-jdbc>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957594#3957594
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957594
19 years, 9 months
[EJB 3.0] - Problem with containment interacting with inheritance?
by knaveofhearts
I posted the following yesterday to the "O'Reilly EJB 3.0 Workbook." I chose that forum because the question was motivated by the book, but there is obviously more activity here, and the post has gotten no replies there. I still don't see what is wrong with what I did. The database is HSQLDB, configured as in the workbook examples.
-----------------------------------
I am missing something fundamental about transactions and the discussion of entity relationships in ch. 7 combined with inheritence, as in ch. 8. There are a client, a stateless session bean, and 3 entities: GeopolUnit, Planet, and Country. Planet and Country both inherit from GeopolUnit. Planet is supposed to contain a list of countries, in a one-to-many unidirectional relationship. In the client, I can create a planet and a country separately. But when I try to create the planet already containing a country by un-commenting the "planet.add(country);" line in the client code listing below, I get the error. I have tried various combinations of putting methods into transactions and flushing things, but so far have been unsuccessful. (I think I ought to be able to omit the "createCountry" call in the client because of the cascade PERSIST constraint, but I get the same kind of error regardless of whether that call is in or out.)
Any help is appreciated.
K/H
[java] Exception in thread "main" java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[Forma tId=257, GlobalId=mulder.vorticityCorp.com/24, BranchQual=, localId=24] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceEx ception: org.hibernate.TransientObjectException: com.ejbWB.geopolUnit.Country)
| [java] at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:198)
| [java] at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:180)
| [java] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
| [java] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
| [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
| [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
| [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
| [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
| [java] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
| [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
| [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
| [java] Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=mulder.vorticityCorp.com/2 4, BranchQual=, localId=24] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.persistence.PersistenceException: org.hibernate.TransientObjectExcept ion: com.ejbWB.geopolUnit.Country)
| [java] at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
| [java] at org.jboss.tm.TxManager.commit(TxManager.java:240)
| [java] at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
| [java] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
| [java] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
| [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
| [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
| [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
| [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
| [java] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
| [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
| [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
| [java] at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
| [java] at org.jboss.remoting.Client.invoke(Client.java:525)
| [java] at org.jboss.remoting.Client.invoke(Client.java:488)
| [java] at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
| [java] at $Proxy0.createPlanet(Unknown Source)
| [java] at com.ejbWB.clients.Client.main(Client.java:22)
| [java] Caused by: javax.persistence.PersistenceException: org.hibernate.TransientObjectException: com.ejbWB.geopolUnit.Country
| [java] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
| [java] at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:484)
| [java] at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
| [java] at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
| [java] at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
| [java] at org.jboss.tm.TxManager.commit(TxManager.java:240)
| [java] at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:175)
| [java] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
| [java] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| [java] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| [java] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
| [java] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
| [java] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
| [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
| [java] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
| [java] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
| [java] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
| [java] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
| [java] Caused by: org.hibernate.TransientObjectException: com.ejbWB.geopolUnit.Country
| [java] at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
| [java] at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
| [java] at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
| [java] at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:732)
| [java] at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1080)
| [java] at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
| [java] at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
| [java] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
| [java] at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
| [java] at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
| [java] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
| [java] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
| [java] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
| [java] at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:475)
|
The client:
| package com.ejbWB.clients;
|
| import com.ejbWB.admin.AdminRemote;
| import com.ejbWB.geopolUnit.*;
| import javax.naming.*;
| import javax.rmi.PortableRemoteObject;
|
| public class Client
| {
| public static void main(String [] args) {
| try {
| Context jndiContext = getInitialContext();
| Object ref = jndiContext.lookup("AdminBean/remote");
| AdminRemote admin = (AdminRemote)ref;
| Planet planet = new Planet();
| Country country = new Country("Italy");
| long c_id = admin.createCountry(country);
| System.out.println("country id=" + c_id);
| //planet.add(country);
| long p_id = admin.createPlanet(planet);
| System.out.println("planet id=" + p_id);
| }
| catch (javax.naming.NamingException ne) {
| ne.printStackTrace();
| }
| }
| public static Context getInitialContext()
| throws javax.naming.NamingException {
| return new javax.naming.InitialContext();
| }
| }
The session bean:
| package com.ejbWB.admin;
| import javax.ejb.*;
| import javax.persistence.*;
| import java.util.*;
| import com.ejbWB.geopolUnit.*;
|
| @Stateless
| public class AdminBean implements AdminRemote
| {
| @PersistenceContext(unitName="ejbWB") private EntityManager manager;
|
| public long createPlanet(Planet planet) {
| manager.persist(planet);
| return planet.getId();
| }
| public long createCountry(Country country) {
| manager.persist(country);
| return country.getId();
| }
| /* I WOULD LIKE TO BE ABLE TO HAVE THIS METHOD WORK
| public Planet findPlanet(long pKey) {
| Planet planet = manager.find(Planet.class, pKey);
| List<Country> countries = planet.getCountries();
| Iterator iter = countries.iterator();
| while (iter.hasNext()) {
| Country c = (Country)iter.next();
| String name = c.getName();
| }
| return planet;
| }
| */
| }[size]
The remote interface is obvious and is omitted.
The three entities:
package com.ejbWB.geopolUnit;
| import javax.persistence.*;
|
| @Entity
| @Inheritance(strategy=InheritanceType.JOINED)
| public abstract class GeopolUnit implements java.io.Serializable {
| public GeopolUnit(String name) { setName(name); }
|
| @Id
| @GeneratedValue
| public long getId() { return id; }
| public void setId(long id) { this.id = id; }
|
| @Column(nullable=false)
| public String getName() { return name; }
| public void setName(String name) { this.name = new String(name); }
|
| private String name;
| private long id;
| }
| //--------------
| package com.ejbWB.geopolUnit;
| import javax.persistence.*;
| import java.util.List;
| import java.util.LinkedList;
|
| @Entity
| public class Planet extends GeopolUnit implements java.io.Serializable {
| public Planet() { super("Earth"); }
| public void add(Country country) { countries.add(country); }
|
| @OneToMany(cascade={CascadeType.PERSIST})
| @OrderBy("name ASC")
| public List<Country> getCountries() { return countries; }
| public void setCountries(List<Country> countries) { this.countries = countries; }
|
| private List<Country> countries = new LinkedList<Country>();
| }
| //--------------
| package com.ejbWB.geopolUnit;
| import javax.persistence.*;
|
| @Entity
| public class Country extends GeopolUnit implements java.io.Serializable {
| public Country(String name) { super(name); }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957593#3957593
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957593
19 years, 9 months
[Security & JAAS/JBoss] - Re: auth-method Form and Subject access
by warrenc6
You cant really, as it is dicarded in the process, sorry. You get null because in the executing context no subject is set. =)
The authentication does not affect the Java systems level security layer.
The JASS login Realm will have authenticated using the tomcat callbackhandler and returned the subject.getPrincipal to the Form Authenticator which has stuffed it in the request session.
>From experience in web servers you need to do something called a access context switch. After looking at the code in tomcat this seems impossible.
If later versions 5.05 or perhaps the Jboss version, you would need to write or find a Filter or Valve which gets the subject out of the session and calls Subject.doAs(session.getAttribute("sum_random_subject_key" , PA{ run { chain.forward
You could write a logincontext which trusts you (the caller) and returns a Subject
Then the code actually runs as who it is logged in as. I have had to write a security context switcher for jetty and tomcat in the past.
I don't know if this is now standard in the later releases. Good luck.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957591#3957591
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957591
19 years, 9 months
[JBoss Portal] - Re: ERROR IN org.jboss.portal.core.CoreController Object Not
by AlAtaKe
Hi, Roy, thanks for your help.
My ini.ini file is empty, and not exist the my.cfg.
The tables exist in mysql database, but http://localhost:808/portal/ or http://localhost:808/portal/index.html only show error page:
HTTP Status 404 -
--------------------------------------------------------------------------------
type Status report
message
description The requested resource () is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.17
I have a file with all console JBOSS output, but i understand this file, but i see errors, i need post this file??
This file contents many WARNS and Errors like this
line 61.
18:55:20,833 WARN [ServiceController] Problem starting service portal:policy=PortalPolicyConfigStore,type=Component
line 195.
18:55:28,036 ERROR [LocaleUtils] Locale name null or empty, ignoring
lines 809 to 826
18:55:43,848 WARN [ObjectDeployment] Cannot create portal object Portal[default] because the parent '' that the deployment descriptor references does not exist
18:55:43,848 WARN [ObjectDeployment] Cannot create portal object Page[CMS Manager] because the parent 'default' that the deployment descriptor references does not exist
18:55:43,864 WARN [ObjectDeployment] Cannot create portal object Page[management] because the parent 'default' that the deployment descriptor references does not exist
18:55:43,864 WARN [ObjectDeployment] Cannot create portal object Page[Secure Policy Config] because the parent 'default.default' that the deployment descriptor references does not exist
18:55:43,864 WARN [ObjectDeployment] Cannot create portal object Window[CatalogPortletWindow] because the parent 'default.CMS Manager' that the deployment descriptor references does not exist
18:55:44,067 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
18:55:44,458 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: portal:policy=PortalPolicyConfigStore,type=Component
State: FAILED
Reason: java.lang.IllegalArgumentException: No transaction manager provided
I Depend On:
portal:policy=JaccPortalPolicyConfigurator
portal:service=TreeCacheProvider,type=transient
portal:policy=PortalPolicyConfigService
Depends On Me:
portal:deploymentFactory=PortletApp
I can't startup a JBOSS Portal, can you help me??
Thanks again.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957586#3957586
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957586
19 years, 9 months