Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » MOXy + Tomcat6 + Maven(Howto use moxy with maven and tomcat6)
icon5.gif  MOXy + Tomcat6 + Maven [message #898370] Thu, 26 July 2012 09:34 Go to next message
jeremie drouet is currently offline jeremie drouetFriend
Messages: 1
Registered: July 2012
Junior Member
Hi

I'm trying to make a web application which will handle Web Services. To do this I've 3 project on eclipse :

- Core : project with classes and interfaces
- Client : project which depends of the Core (Maven trick)
- Server : project which depends of the core too

I'm trying to set up Moxy in order to remove a cyclic graph error.

This problem comes from 2 classes :

(/src/main/java/core/object/BasicObject)
(/src/main/java/core/object/BasicRefObject)
/src/main/java/core/application/Voltage
/src/main/java/core/application/VoltageValue

package core.object.application;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.eclipse.persistence.oxm.annotations.XmlInverseReference;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import core.object.BasicRefObject;
import core.object.system.User;

@Entity
@Table(name = "Voltage")
@XmlRootElement()
public class Voltage extends BasicRefObject {
	private static final long serialVersionUID = -7590340638662303349L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", nullable = false)
	private long id;

	@ManyToOne
	@JoinColumn(name = "creator", nullable = false)
	private User creator;

	@Column(name = "creationDate", nullable = false)
	private Date creationDate;

	@Column(name = "reference", nullable = false, unique = true)
	private String reference;

	@Column(name = "description", nullable = false)
	private String description;

	@LazyCollection(LazyCollectionOption.FALSE)
	@OneToMany(mappedBy = "voltage")
	@XmlInverseReference(mappedBy = "voltage")
	private List<VoltageValue> voltageValueList;

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the creator
	 */
	public User getCreator() {
		return creator;
	}

	/**
	 * @param creator the creator to set
	 */
	public void setCreator(User creator) {
		this.creator = creator;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param creationDate the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @return the reference
	 */
	public String getReference() {
		return reference;
	}

	/**
	 * @param reference the reference to set
	 */
	public void setReference(String reference) {
		this.reference = reference;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the voltageValueList
	 */
	public List<VoltageValue> getVoltageValueList() {
		return voltageValueList;
	}

	/**
	 * @param voltageValueList the voltageValueList to set
	 */
	public void setVoltageValueList(List<VoltageValue> voltageValueList) {
		this.voltageValueList = voltageValueList;
	}

}


package core.object.application;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import core.object.BasicObject;
import core.object.system.User;

@Entity
@Table(name = "VoltageValue")
@XmlRootElement()
public class VoltageValue extends BasicObject {
	private static final long serialVersionUID = 5563489030736775097L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", nullable = false)
	private long id;

	@ManyToOne
	@JoinColumn(name = "creator", nullable = false)
	private User creator;

	@Column(name = "creationDate", nullable = false)
	private Date creationDate;

	@ManyToOne
	@JoinColumn(name = "voltage", nullable = false)
	private Voltage voltage;

	@ManyToOne
	@JoinColumn(name = "torque", nullable = false)
	private Torque torque;

	@ManyToOne
	@JoinColumn(name = "typeOfVoltageValue", nullable = false)
	private TypeOfVoltageValue typeOfVoltageValue;

	@Column(name = "frequency", nullable = false)
	private double frequency;

	@Column(name = "value", nullable = false)
	private double value;

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the creator
	 */
	public User getCreator() {
		return creator;
	}

	/**
	 * @param creator the creator to set
	 */
	public void setCreator(User creator) {
		this.creator = creator;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param creationDate the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @return the voltage
	 */
	public Voltage getVoltage() {
		return voltage;
	}

	/**
	 * @param voltage the voltage to set
	 */
	public void setVoltage(Voltage voltage) {
		this.voltage = voltage;
	}

	/**
	 * @return the torque
	 */
	public Torque getTorque() {
		return torque;
	}

	/**
	 * @param torque the torque to set
	 */
	public void setTorque(Torque torque) {
		this.torque = torque;
	}

	/**
	 * @return the typeOfVoltageValue
	 */
	public TypeOfVoltageValue getTypeOfVoltageValue() {
		return typeOfVoltageValue;
	}

	/**
	 * @param typeOfVoltageValue the typeOfVoltageValue to set
	 */
	public void setTypeOfVoltageValue(TypeOfVoltageValue typeOfVoltageValue) {
		this.typeOfVoltageValue = typeOfVoltageValue;
	}

	/**
	 * @return the frequency
	 */
	public double getFrequency() {
		return frequency;
	}

	/**
	 * @param frequency the frequency to set
	 */
	public void setFrequency(double frequency) {
		this.frequency = frequency;
	}

	/**
	 * @return the value
	 */
	public double getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(double value) {
		this.value = value;
	}

}


And set up Moxy, I put a jaxb.properties in /src/main/resources and I put this in the pom.xml of the Core

<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.5</version>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}\target\classes\core\object\application\</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}\src\main\resources\</directory>
									<includes>
										<include>jaxb.properties</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>


But it doesn't work.
So I tried to put this on my web.xml (Server)

    <env-entry>
    	<env-entry-name>javax.xml.bind.JAXBContext</env-entry-name>
    	<env-entry-type>java.lang.String</env-entry-type>
    	<env-entry-value>org.eclipse.persistence.jaxb.JAXBContextFactory</env-entry-value>
    </env-entry>
    <env-entry>
    	<env-entry-name>javax.xml.bind.context.factory</env-entry-name>
    	<env-entry-type>java.lang.String</env-entry-type>
    	<env-entry-value>org.eclipse.persistence.jaxb.JAXBContextFactory</env-entry-value>
    </env-entry>


But it doesn't work anymore...

What's the best way make it work ?

Regards
Re: MOXy + Tomcat6 + Maven [message #898817 is a reply to message #898370] Fri, 27 July 2012 18:33 Go to previous message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

Hello Jeremie,

Is your question essentially how to get the jaxb.properties file in the correct location (same package as the model classes) in the deployment archive?

-Blaise
Previous Topic:@MappedSuperclass with Generic types
Next Topic:Search Query Error
Goto Forum:
  


Current Time: Fri Nov 28 08:55:15 GMT 2014

Powered by FUDForum. Page generated in 0.01718 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software