Search code examples
javaweblogiceclipselinkmoxyweblogic12c

MOXy unmarshalling in Weblogic 12


I have a problem with running my web service in WebLogic 12c (with OpenJPA 2.1.0). The response of the web service is a DTO which has list of specific entities. After executing the service, its response could not be generated (without any error or exception). I think there is a problem during MOXy’s unmarshalling operation of response entity (I haven’t had any problem in WebLogic 11, because it don’t use MOXy). What do you think about this problem and solution?

Thanks

The web service works well in GlassFish 3.1.2.

Here is my code:

Person entity

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "person")
@Entity
@Table(name = "PERSON")

public class Person {

@Id
@Column(name = "ID")
@XmlElement(required = false)
private Long id;

@Column(name = "BIRTHDATE")
@XmlElement(required = false)
@Temporal(TemporalType.DATE)
private Date birthDate;

@Transient
private String name;

Person DTO

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "personDto")
public class PersonDto implements Serializable{

@XmlElement(required = false)
List<Person> persons;

/**
 * list of person
 *
 * @return
 */
public List<Person> getPersons() {
    if (persons == null)
        persons = new LinkedList<Person>();

    return persons;
}

public void setpersons(List<Person> persons) {
    this.persons = persons;
}

DAO

@Stateless
public class PersonDaoImpl implements PersonDao{

@PersistenceContext(unitName = "pu-test")
private EntityManager em;

public List<Person> findAll() {
    List<Person> personList = null;
    Query query =  em.createNamedQuery("person.findAll");
    List<Person> results = (List<Person>)query.getResultList();
    return results;     
}

orm.xml

<named-query name="person.findAll">
    <query>select p from Person p</query>
</named-query>

WebService

@Stateless
@WebService
public class PersonServiceImpl implements IPersonService {

@EJB
private PersonDao personDao;


public PersonDto allPersons()  {
    PersonDto result = new PersonDto();
    List<Person> fList = personDao.findAll();       
    result.setPersons(fList);
    return result;
}

The list's size is 3, but there is no response.


Solution

  • Finally, by changing JAXB implementation from Moxy to Metro, my problem has been resolved temporary. Two jar files javax-xml-bind.jar, javax-xml-ws.jar should be added in the path of "/weblogic_home/wlserver/endorsed" in Weblogic server and also add following properties into java_properties part of setDomainEnv file:

        -Dcom.sun.xml.ws.spi.db.BindingContextFactory=com.sun.xml.ws.db.
    glassfish.JAXBRIContextFactory 
    
    -Djavax.xml.bind.JAXBContext=org.eclipse.persistence.jaxb.JAXBContextFactory