[JBoss Seam] - eclipse and jBPM - how to add a process definition in Eclips
by wouterhartog
I have Eclipse Europa installed (v 3.3.1.1) with all the plugins downloaded from the JBoss Tools website (latest version as of Jan 14 2008).
When I want to add a process definition in this project, the only option I have in Eclipse under 'File -> New' is 'jBPM -> process' definition.
So I select that, but it always generates a file called 'processdefinition.xml' under a subdirectory with the name of the process definition.
Problem is that Seam assumes that the xml file with the process definition is placed under the 'resources' directory. When I move and rename the file to the Seam 'standard', the process definition xml file doesn't open in the jbpl editor.
This is somewhat cumbersome to have to keep copying and renaming the file every time I change the process definition.
Am I missing something, or is this the way it works with Eclipse?
Thank you,
Wouter
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120704#4120704
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120704
18 years, 5 months
[JBoss Seam] - Share my implementation of EntityQuery by Entity Example, an
by zjsun
Structure:
EntityQuery
ExampleEntityQuery + EntityQueryState
RestrictedExampleEntityQuery
Note:
ExampleEntityQuery used to generate dynamic ejbql at runtime according to the entity class and entity instance ...
EntityQueryState used to hold query state, include orderby info, page info, example entity...
RestrictedExampleEntityQuery used to control user permission on this query, by adding more restriction "where" ejbql
| public abstract class ExampleEntityQuery<E> extends EntityQuery {
|
| private static final long serialVersionUID = 4830838552107053677L;
|
| public static final Pattern FROM_PATTERN = Pattern.compile(
| "(^|\\s)(from)\\s", Pattern.CASE_INSENSITIVE);
|
| public static final Pattern ORDER_CLAUSE_PATTERN = Pattern
| .compile("^[\\w\\.,\\s]*$");
|
| public static final Pattern ORDER_PATTERN = Pattern.compile(
| "\\s(order)(\\s)+by\\s", Pattern.CASE_INSENSITIVE);
|
| public static final Pattern WHERE_PATTERN = Pattern.compile(
| "\\s(where)\\s", Pattern.CASE_INSENSITIVE);
|
| @Logger
| private Log log;
|
| // private EntityQueryState<E> state;
| public abstract void setState(EntityQueryState<E> state);
|
| public abstract EntityQueryState<E> getState();
|
| protected String buildCountEjbql() {
| // return super.getCountEjbql();
| String ejbql = getRenderedEjbql();
| boolean distincted = ejbql.startsWith("select distinct");
|
| Matcher fromMatcher = FROM_PATTERN.matcher(ejbql);
| if (!fromMatcher.find()) {
| throw new IllegalArgumentException("no from clause found in query");
| }
| int fromLoc = fromMatcher.start(2);
|
| Matcher orderMatcher = ORDER_PATTERN.matcher(ejbql);
| int orderLoc = orderMatcher.find() ? orderMatcher.start(1) : ejbql
| .length();
|
| String countQl = "select count(*) ";
| if (distincted) {
| Class entityClass = ReflectionsUtils.getClassParameterType(
| getClass(), 0);
| // String entityClassName = entityClass.getSimpleName();
| String entityAliasName = EntityUtils
| .getEntityAliasName(entityClass);
| countQl = "select count(distinct " + entityAliasName + ") ";
| }
| countQl += ejbql.substring(fromLoc, orderLoc);
|
| logQl("Seam ext (Query countEjbql) : " + countQl);
| return countQl;
| }
|
| protected String buildEjbql() {
| Class entityClass = ReflectionsUtils.getClassParameterType(getClass(),
| 0);
| String entityClassName = entityClass.getSimpleName();
| String entityAliasName = EntityUtils.getEntityAliasName(entityClass);
|
| StringBuffer joinBuilder = new StringBuffer();
| StringBuffer whereBuilder = new StringBuffer();
| boolean joined = false;
|
| if (getState() != null) {
| if (getState().getExample() != null) {
| for (PropertyDescriptor pd : PropertyUtils
| .getPropertyDescriptors(entityClass)) {
| if (ReflectionsUtils.isInstanceOf(pd.getPropertyType(),
| Collection.class.getName())) {
|
| Field field = ReflectionsUtils.getField(entityClass, pd
| .getName());
| Method fieldGetterMethod = ReflectionsUtils
| .getGetterMethod(entityClass, pd.getName());
| Collection fieldValue = null;
| try {
| fieldValue = (Collection) fieldGetterMethod.invoke(
| getState().getExample(), new Object[] {});
| } catch (Exception e) {
| e.printStackTrace();
| }
|
| if (fieldValue != null && fieldValue.size() > 0) {
| Class propertyEntityClass = ReflectionsUtils
| .getCollectionElementType(field
| .getGenericType());
| String propertyAliasName = EntityUtils
| .getEntityAliasName(propertyEntityClass);
| joinBuilder.append(" left join " + entityAliasName
| + "." + pd.getName() + " "
| + propertyAliasName);
|
| joined = true;
| }
| }
| }
| }
|
| // 妿æ¯é对å½åentityçä¸ä¸ªproperty说对åºçentityè¿è¡æ¥è¯¢
| if (getState().getQueryPropertyName() != null) {
| Field field = ReflectionsUtils.getField(entityClass, getState()
| .getQueryPropertyName());
| boolean bCollectionType = ReflectionsUtils.isInstanceOf(field
| .getType(), Collection.class.getName());
|
| Class propertyEntityClass = field.getType();
| if (bCollectionType) {
| propertyEntityClass = ReflectionsUtils
| .getCollectionElementType(field.getGenericType());
| }
|
| String propertyAliasName = EntityUtils
| .getEntityAliasName(propertyEntityClass);
|
| String joinItem = " join " + entityAliasName + "."
| + field.getName() + " " + propertyAliasName;
|
| // TODO:ææ¶ä½¿ç¨ç²ç³çæ£æµæ¯å¦åå¨
| if (joinBuilder.toString().indexOf(joinItem) == -1) {
| if (bCollectionType) {
| joinBuilder.append(" left").append(joinItem);
| } else {
| joinBuilder.append(joinItem);
| }
| whereBuilder.append(propertyAliasName + " is not null");
| joined = true;
| }
| }
| }
|
| StringBuffer selectBuilder = new StringBuffer();
| if (joined) {
| selectBuilder.append("select distinct ");
| } else {
| selectBuilder.append("select ");
| }
|
| if (getState() != null && getState().getQueryPropertyName() != null) {
| Field field = ReflectionsUtils.getField(entityClass, getState()
| .getQueryPropertyName());
| boolean bCollectionType = ReflectionsUtils.isInstanceOf(field
| .getType(), Collection.class.getName());
|
| Class propertyEntityClass = field.getType();
| if (bCollectionType) {
| propertyEntityClass = ReflectionsUtils
| .getCollectionElementType(field.getGenericType());
| }
|
| String propertyAliasName = EntityUtils
| .getEntityAliasName(propertyEntityClass);
| selectBuilder.append(propertyAliasName);
| } else {
| selectBuilder.append(entityAliasName);
| }
|
| selectBuilder.append(" from ").append(entityClassName).append(" ")
| .append(entityAliasName).append(joinBuilder);
| if (whereBuilder.length() > 0) {
| selectBuilder.append(" where ").append(whereBuilder);
| }
|
| logQl("Seam ext (Query ejbql) : " + selectBuilder.toString());
| return selectBuilder.toString();
| }
|
| protected List<QueryJoin> buildJoins() {
| List<QueryJoin> joins = new ArrayList<QueryJoin>();
| return joins;
| }
|
| protected List<String> buildRestrictions() {
| List<String> restrictions = new ArrayList<String>();
| if (getState() != null && getState().getExample() != null) {
| Class entityClass = ReflectionsUtils.getClassParameterType(
| getClass(), 0);
| // String entityClassName = entityClass.getSimpleName();
| String entityAliasName = EntityUtils
| .getEntityAliasName(entityClass);
| String queryComponentName = Seam.getComponentName(getClass());
|
| for (PropertyDescriptor pd : PropertyUtils
| .getPropertyDescriptors(entityClass)) {
| if (!ReflectionsUtils.isInstanceOf(pd.getPropertyType(),
| Class.class.getName())) {
| if (ReflectionsUtils.isInstanceOf(pd.getPropertyType(),
| String.class.getName())) {
| // 妿Stringç±»åï¼åä½¿ç¨ like æ¥è¯¢
| restrictions.add("lower(" + entityAliasName + "."
| + pd.getName() + ") like " + "lower('%'||#{"
| + queryComponentName + ".state.example."
| + pd.getName() + "}||'%')");
| } else if (ReflectionsUtils.isInstanceOf(pd
| .getPropertyType(), Collection.class.getName())) {
| // 妿æ¯Collectionï¼åé
ååé¢çleft join 使ç¨inåæ¥è¯¢æ¹å¼
| Field field = ReflectionsUtils.getField(entityClass, pd
| .getName());
|
| Method fieldGetterMethod = ReflectionsUtils
| .getGetterMethod(entityClass, pd.getName());
| Collection fieldValue = null;
| try {
| fieldValue = (Collection) fieldGetterMethod.invoke(
| getState().getExample(), new Object[] {});
| } catch (Exception e) {
| e.printStackTrace();
| }
|
| if (fieldValue != null && fieldValue.size() > 0) {
| Class propertyEntityClass = ReflectionsUtils
| .getCollectionElementType(field
| .getGenericType());
| String propertyAliasName = EntityUtils
| .getEntityAliasName(propertyEntityClass);
|
| restrictions.add(propertyAliasName + " in (select "
| + propertyAliasName + "_ from "
| + propertyEntityClass.getSimpleName() + " "
| + propertyAliasName + "_ where "
| + propertyAliasName + "_ in (#{"
| + queryComponentName + ".state.example."
| + pd.getName() + "}))");
| }
| } else {
| // å
¶ä½ç´æ¥è¿è¡ = æ¥è¯¢
| restrictions.add(entityAliasName + "." + pd.getName()
| + " = " + "#{" + queryComponentName
| + ".state.example." + pd.getName() + "}");
| }
| }
| }
| }
|
| return restrictions;
| }
|
| @Override
| public void validate() {
| super.validate();
| if (getState() == null) {
| // throw new IllegalStateException("state is null");
| }
| }
|
| @Override
| protected String getRenderedEjbql() {
| String ql = super.getRenderedEjbql();
| logQl("Seam ext (Query renderedEjbql) : " + ql);
| return ql;
| }
|
| @Override
| protected String getCountEjbql() {
| return buildCountEjbql();
| }
|
| @Override
| public Integer getFirstResult() {
| return getState() == null ? super.getFirstResult() : getState()
| .getCurrentPage();
| }
|
| @Override
| public Integer getMaxResults() {
| return getState() == null ? super.getMaxResults() : getState()
| .getPageSize();
| }
|
| @Override
| public String getOrder() {
| return getState() == null ? super.getOrder() : getState().getOrderBy();
| }
|
| @Override
| protected boolean isRestrictionParameterSet(Object parameterValue) {
| boolean bSet = super.isRestrictionParameterSet(parameterValue);
| if (bSet) {
| if (parameterValue != null && parameterValue instanceof Collection) {
| bSet = ((Collection) parameterValue).size() > 0;
| }
| }
| return bSet;
| }
|
| @Override
| public String getEjbql() {
| return buildEjbql();
| }
|
| @Override
| public List<String> getRestrictions() {
| return buildRestrictions();
| }
|
| public void refreshQuery() {
| // clear the parsed QL
| setEjbql(null);
| setRestrictions(null);
| super.refresh();
| }
|
| private void logQl(String ql) {
| log.info(ql);
| }
|
| }
|
|
| public class EntityQueryState<E> implements Serializable {
|
| private static final long serialVersionUID = 4999435737345385599L;
|
| private E example;
|
| private Integer pageSize;
|
| private Integer currentPage;
|
| private String orderBy;
|
| // ç¨äºæ è¯æ¯å¦æ¥è¯¢å½åEntityçæä¸ªpropertyï¼Entityç±»åï¼çList
| private String queryPropertyName;
|
| // TODO:how to implement?
| private List<QueryJoin> queryJoins = new ArrayList<QueryJoin>();
|
| public E getExample() {
| return example;
| }
|
| public void setExample(E entity) {
| this.example = entity;
| }
|
| public String getOrderBy() {
| return orderBy;
| }
|
| public void setOrderBy(String orderby) {
| this.orderBy = orderby;
| }
|
| public Integer getPageSize() {
| return pageSize;
| }
|
| public void setPageSize(Integer pageSize) {
| this.pageSize = pageSize;
| }
|
| public Integer getCurrentPage() {
| return currentPage;
| }
|
| public void setCurrentPage(Integer currentPage) {
| this.currentPage = currentPage;
| }
|
| public String getQueryPropertyName() {
| return queryPropertyName;
| }
|
| public void setQueryPropertyName(String propertyName) {
| this.queryPropertyName = propertyName;
| }
|
| public List<QueryJoin> getQueryJoins() {
| return queryJoins;
| }
|
| public void setQueryJoins(List<QueryJoin> queryJoins) {
| this.queryJoins = queryJoins;
| }
| }
|
|
| public abstract class RestrictedExampleEntityQuery<E> extends
| ExampleEntityQuery<E> {
|
| private static final long serialVersionUID = -5768415674705835414L;
|
| @Override
| protected String buildEjbql() {
| /**
| * ç±äºrestrictionæ¹å¼éé¢åªè½ä½¿ç¨åºå®ç»æçãä¸åªæ¯æä¸ä¸ªåæ°çãä¸ä¹é´æ¯andå
³ç³»ç QL
| * 忤éå¶ï¼æä¸å°è¡å®ä¾æ¡ä»¶è¡¨è¾¾å¼ä½ä¸ºä¸»QLçä¸é¨å
| */
| StringBuffer builder = new StringBuffer().append(super.buildEjbql());
| if (WHERE_PATTERN.matcher(builder).find()) {
| builder.append(" and ");
| } else {
| builder.append(" where ");
| }
| builder.append(getRestrictedQl());
| return builder.toString();
| }
|
| protected String getRestrictedQl() {
| return EntityQuerySecurityRestriction.getRestrictionQl(ReflectionsUtils
| .getClassParameterType(getClass(), 0));
| }
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120699#4120699
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120699
18 years, 5 months
[Security & JAAS/JBoss] - Authentication issue usin jmsxa connection factory
by schndr
Hi,
Iam using jmsxa connectionfactory.Getting authentication error 'User guest is not authenticated' I beleive this is already discussed in so many places.But still Iam not finding any solution.
Below is the login config file
<application-policy name = "jbossmq">
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag = "required">
<module-option name = "unauthenticatedIdentity">guest</module-option>
<module-option name = "dsJndiName">java:/DefaultDS</module-option>
<module-option name = "principalsQuery">SELECT PASSWD FROM JMS_USERS WHERE USERID=?</module-option>
<module-option name = "rolesQuery">SELECT ROLEID, 'Roles' FROM JMS_ROLES WHERE USERID=?</module-option>
</login-module>
</application-policy>
<application-policy name = "JmsXARealm">
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag = "required">
<module-option name = "principal">guest</module-option>
<module-option name = "userName">guest</module-option>
<module-option name = "password">guest</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXA</module-option>
</login-module>
</application-policy>
And the provider url and the connection factory info are:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1100
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
connection.factory=java:/JmsXA
And in the jbossmq-service.xml I have the following entry
java:/jaas/jbossmq
<depends optional-attribute-name="NextInterceptor">
jboss.mq:service=DestinationManager
Iam using all server config for clustering.All the jms files are under deploy-hasingleton.
I have followed the instructions to use deply-hasingleton.
while server is coming up Iam getting the following error for all the listeners
listener.DefaultMessageListenerContainer | Setup of JMS message listener invoker failed - trying to recover
javax.jms.JMSException: Could not create a session: javax.resource.spi.CommException: javax.jms.JMSSecurityException: User: guest is NOT authenticated
at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.allocateConnection(JmsSessionFactoryImpl.java:392)
at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.createSession(JmsSessionFactoryImpl.java:358)
at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:200)
Can you please help?
Thanks in advance,
schndr
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120696#4120696
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120696
18 years, 5 months
[EJB 3.0] - Is this a JBoss bug?
by mrducnguyen
I'm try to create an EJB3, hosted with JBoss. This is the steps that I have been taking by now:
JBoss 4.2.2 GA
J2EE 5 U3 with JDK 1.6
MyEclipse 5.5
MS SQL 2005 Express
Step 1: Create a new EJB Project AdminEJB with MyEclipse, Choose J2EE 5.0, setup connection driver and schema
Step 2: Use MyEclipse Derby to browse the database
Step 3: Use EJB3 Reverse Engineering to generate Beans from a table Admin [Username nvarchar(20) Pk, Password nvarchar(20)] (see the generated class)
/*****************************
| * Admin Entity bean
| ******************************/
|
| /**
| * Admin generated by MyEclipse Persistence Tools
| */
| @Entity
| @Table(name = "Admin", schema = "dbo", catalog = "TungaRestaurant", uniqueConstraints = {})
| public class Admin implements java.io.Serializable {
|
| private String username;
| private String password;
|
| /** default constructor */
| public Admin() {
| }
|
| /** full constructor */
| public Admin(String username, String password) {
| this.username = username;
| this.password = password;
| }
|
| // Property accessors
| @Id
| @Column(name = "Username", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
| public String getUsername() {
| return this.username;
| }
|
| public void setUsername(String username) {
| this.username = username;
| }
|
| @Column(name = "Password", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
| public String getPassword() {
| return this.password;
| }
|
| public void setPassword(String password) {
| this.password = password;
| }
|
| }
|
| /*****************************
| * Admin Facade
| ******************************/
|
| /**
| * Facade for entity Admin.
| */
| @Stateless
| public class AdminFacade implements AdminFacadeLocal, AdminFacadeRemote {
| // property constants
| public static final String PASSWORD = "password";
|
| @PersistenceContext
| private EntityManager entityManager;
|
| public void save(Admin transientInstance) {
| EntityManagerHelper.log("saving Admin instance", Level.INFO, null);
| try {
| entityManager.persist(transientInstance);
| EntityManagerHelper.log("save successful", Level.INFO, null);
| } catch (RuntimeException re) {
| EntityManagerHelper.log("save failed", Level.SEVERE, re);
| throw re;
| }
| }
|
| public void delete(Admin persistentInstance) {
| EntityManagerHelper.log("deleting Admin instance", Level.INFO, null);
| try {
| entityManager.remove(persistentInstance);
| EntityManagerHelper.log("delete successful", Level.INFO, null);
| } catch (RuntimeException re) {
| EntityManagerHelper.log("delete failed", Level.SEVERE, re);
| throw re;
| }
| }
|
| public Admin update(Admin detachedInstance) {
| EntityManagerHelper.log("updating Admin instance", Level.INFO, null);
| try {
| Admin result = entityManager.merge(detachedInstance);
| EntityManagerHelper.log("update successful", Level.INFO, null);
| return result;
| } catch (RuntimeException re) {
| EntityManagerHelper.log("update failed", Level.SEVERE, re);
| throw re;
| }
| }
|
| public Admin findById(String id) {
| EntityManagerHelper.log("finding Admin instance with id: " + id,
| Level.INFO, null);
| try {
| Admin instance = entityManager.find(Admin.class, id);
| return instance;
| } catch (RuntimeException re) {
| EntityManagerHelper.log("find failed", Level.SEVERE, re);
| throw re;
| }
| }
|
| @SuppressWarnings("unchecked")
| public List<Admin> findByProperty(String propertyName, Object value) {
| EntityManagerHelper.log("finding Admin instance with property: "
| + propertyName + ", value: " + value, Level.INFO, null);
| try {
| String queryString = "select model from Admin model where model."
| + propertyName + "= :propertyValue";
| return entityManager.createQuery(queryString).setParameter(
| "propertyValue", value).getResultList();
| } catch (RuntimeException re) {
| EntityManagerHelper.log("find by property name failed",
| Level.SEVERE, re);
| throw re;
| }
| }
|
| public List<Admin> findByPassword(Object password) {
| return findByProperty(PASSWORD, password);
| }
|
| @SuppressWarnings("unchecked")
| public List<Admin> findAll() {
| EntityManagerHelper
| .log("finding all Admin instances", Level.INFO, null);
| try {
| String queryString = "select model from Admin model";
| return entityManager.createQuery(queryString).getResultList();
| } catch (RuntimeException re) {
| EntityManagerHelper.log("find all failed", Level.SEVERE, re);
| throw re;
| }
| }
| }
|
| /*****************************
| * Local and Remote interfaces
| ******************************/
|
| @Local
| public interface AdminFacadeLocal {
| public void save(Admin transientInstance);
| public void delete(Admin persistentInstance);
| public Admin update(Admin detachedInstance);
| public Admin findById(String id);
| public List findByProperty(String propertyName, Object value);
| public List findByPassword(Object password);
| }
|
| @Remote
| public interface AdminFacadeRemote {
| public void save(Admin transientInstance);
| public void delete(Admin persistentInstance);
| public Admin update(Admin detachedInstance);
| public Admin findById(String id);
| public List findByProperty(String propertyName, Object value);
| public List findByPassword(Object password);
| }
Step 3.1: Create persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
| <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="AdminEJB" transaction-type="JTA">
| <jta-data-source>java:/MyDB</jta-data-source>
| </persistence-unit>
|
| </persistence>
Step 4: Config Application Server JBoss 4.x
Step 4.1: copy sqljdbc.jar to server/default/lib
Step 4.2: Create datasource file: mssql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
|
| <datasources>
| <local-tx-datasource>
|
| <jndi-name>MyDB</jndi-name>
|
| <connection-url>jdbc:sqlserver://DUCNGUYEN-PC\\SQLEXPRESS:49378;database=AdventureWorks;</connection-url>
|
| <!-- The driver class -->
| <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
|
| <!-- The login and password -->
| <user-name>sa</user-name>
| <password></password>
|
| </local-tx-datasource>
| </datasources>
Step 5: Deloy AdminEJB within JBoss, start server (Everything is ok)
Step 6: Create a new Java Project with MyEclipse
referenced build path all the jar file in JBOSS_HOME\client
reference the deploy jar file con server/default/deploy
Step 7: Create jndi.properties in src folder with the following content:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099
Step 8: Create log4j.properties in src folder with the following content
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
Step 9: create TestClient.java
public class TestClient {
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| Context context;
| try
| {
| context = new InitialContext();
|
| AdminFacadeRemote adminMan = (AdminFacadeRemote)context.lookup(AdminFacade.RemoteJNDIName);
|
| Admin admin = new Admin("admin","123");
| adminMan.save(admin);
|
| } catch (NamingException e)
| {
| e.printStackTrace();
| }
|
| }
| }
Step 10: Run the client, this is when the funny thing happened, the first time when client runs, it gets java.lang.ExceptionInInitializerError
Please look at the stack trace
Exception in thread "main" javax.ejb.EJBException: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| 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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 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:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
| Caused by: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:174)
| 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.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:191)
| 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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 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:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
| at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
| at org.jboss.remoting.Client.invoke(Client.java:1550)
| at org.jboss.remoting.Client.invoke(Client.java:530)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
| at $Proxy0.save(Unknown Source)
| at com.tungadb.testclient.TestClient.main(TestClient.java:26)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
| at $Proxy0.save(Unknown Source)
| at com.tungadb.testclient.TestClient.main(TestClient.java:26)
| Caused by: java.lang.ExceptionInInitializerError
| at com.tungadb.admin.AdminFacade.save(AdminFacade.java:27)
| 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.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.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:191)
| 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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 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:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
| Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
| at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
| at com.tungadb.admin.EntityManagerHelper.<clinit>(EntityManagerHelper.java:20)
| ... 34 more
| Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
| at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:329)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
| ... 38 more
|
Step 11: do nothing, just try to run the client again, it gets java.lang.NoClassDefFoundError
Please look at the stack trace
Exception in thread "main" javax.ejb.EJBException: java.lang.RuntimeException: java.lang.NoClassDefFoundError
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| 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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 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:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
| Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:174)
| 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.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:191)
| 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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 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:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
| at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
| at org.jboss.remoting.Client.invoke(Client.java:1550)
| at org.jboss.remoting.Client.invoke(Client.java:530)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
| at $Proxy0.save(Unknown Source)
| at com.tungadb.testclient.TestClient.main(TestClient.java:25)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 09:34:06,184 DEBUG InvokerRegistry:595 - removed SocketClientInvoker[1d86fd3, socket://127.0.0.1:3873] from registry
| 09:34:06,185 DEBUG MicroSocketClientInvoker:277 - SocketClientInvoker[1d86fd3, socket://127.0.0.1:3873] disconnecting ...
| 09:34:06,186 DEBUG SocketWrapper:123 - ClientSocketWrapper[Socket[addr=/127.0.0.1,port=3873,localport=50336].476128] closing
| at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
| at $Proxy0.save(Unknown Source)
| at com.tungadb.testclient.TestClient.main(TestClient.java:25)
| Caused by: java.lang.NoClassDefFoundError
| at com.tungadb.admin.AdminFacade.save(AdminFacade.java:27)
| 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.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.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:191)
| 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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 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.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 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:734)
| at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
|
Anyone, please help
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120693#4120693
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120693
18 years, 5 months
[EJB 3.0] - How to save entities with PrimaryKeyJoinColumn?
by drathnow
Could someone give me some insight into the correct way to save entities that are joined over their primary key?
I have two entities: Field and FieldAccess. They both share the same primary key and have a relation over their primary key:
class Field {
@OneToOne (mappedBy = "field")
protected FieldAccess fieldAccess;
}
class FieldAccess {
@OneToOne
@PrimaryKeyJoinColumn(name = "fieldid", referencedColumnName = "fieldid")
protected Field field;
}
I'm using Oracle Sequences to generate primary keys.
When saving a new entity, how does the primary key get propagated from one entity to the other? I've tried the following but the primary keys never end up being the same:
FieldAccess fieldAccess = new FieldAccess();
entityManager.persist(fieldAccess);
Field field = new Field();
field.setFieldAccess(fieldAccess);
fieldAccess.setField(field);
entityManager.persist(field);
What am I missing?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120689#4120689
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120689
18 years, 5 months