Skip to main content

Problem to send or retrieve an entity ( Rest module > EJB module )

2 replies [Last post]
davidl.
Offline
Joined: 2013-08-22
Points: 0

Hello folks,

I have 2 componentes that are deployed in my GF4:
- application-server.ear: contains 2 ejb modules and a java module that contains my entities...i have a persistence.xml inside /META-INF/ and another in jar that contains entities...
- application-rest.war: web services, lookup on EJBs...in pom.xml i have a dependency to entities jar..

persistence.xml from ejb

<?xml version="1.0" encoding="UTF-8"?></p>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"<br />
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence<br />
   http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"<br />
	version="2.0"><br />
<persistence-unit name="Weee_PU">
		<jta-data-source>jdbc/Weee</jta-data-source><br />
		<jar-file>lib/entities.jar</jar-file></p>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
		</properties>
	</persistence-unit>
</persistence>

persistence.xml from entities.jar

<?xml version="1.0" encoding="UTF-8"?></p>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"<br />
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence<br />
   http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"<br />
	version="2.0"><br />
<persistence-unit name="Weee_PU">
		<jta-data-source>jdbc/Weee</jta-data-source><br />
		<class>...</class></p>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
		</properties>
	</persistence-unit>
</persistence>

My deploy structure (glassfish_home/glassfish/domains/domain1/autodeploy) :

   - application-server.ear
          - user-ejb-module.jar
          - folder called 'lib'
                  - entities.jar

  - application-rest.ear
          - web-inf
              - lib
                   - entities.jar

The problem is when i call a webservice and try to send an object ( like User.java that is annotated with @Entity ) throgh EJBs method.

When EJB receives my entity object, all attributes are null and if i try to retrieve a entity, when REST class receives object from EJB, all fields are null.

Any ideas what's going on?

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Yser
Offline
Joined: 2013-09-09
Points: 0

Hey,

i had the same problem and i solved it like this:

try to disable weaving ;) if u use eclipselink (and i think thats the case) this will look like this:

<property name="eclipselink.weaving" value="false" />

in your persistence.xml (the one with <jar-file> attribute i guess)

if that works for you but you want weaving enabled read further information about static weaving.

Eclipselink Weaving:
http://www.eclipse.org/eclipselink/documentation/2.4/concepts/app_dev007...

codeprince
Offline
Joined: 2007-05-10
Points: 0

Pl. attaching a whole sample here, otherwise, it is difficult for me and others to re-produce and analyze the issue.

Thanks
Tang