1

WebLogic 12c ( OpenJPA 2.1.0を使用) で Web サービスを実行する際に問題があります。Web サービスの応答は、特定のエンティティのリストを持つ DTO です。サービスを実行した後、その応答を生成できませんでした (エラーまたは例外なし)。MOXy の応答エンティティのアンマーシャリング操作中に問題があると思います (MOXy を使用しないため、WebLogic 11 では問題はありませんでした)。この問題と解決策についてどう思いますか?

ありがとう

この Web サービスは、GlassFish 3.1.2 でうまく機能します。

これが私のコードです:

個人エンティティ

@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;

個人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;
}

ダオ

@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>

ウェブサービス

@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;
}

リストのサイズは 3 ですが、応答はありません。

4

2 に答える 2

0

UPDATE

The problem appears to be that OpenJPA is populating properties of type java.util.Date with a subclass of java.util.Date. I have opened the following EclipseLink bug that you can use to track our progress on this issue:

I have posted a way to work around this problem in an answer I gave to related question here:

To get an official patch you should submit a WebLogic bug. If you cite the EclipseLink bug I gave above it will help move everything along faster.


EclipseLink JAXB (MOXy) did become the default JAXB provider in WebLogic 12.1.1 (see EclipseLink MOXy is the JAXB Provider in WebLogic Server 12c), but that does not appear to be the cause of your issue.

PersonServiceImpl

I simplified your service to remove as much that wasn't related to MOXy as possible. By removing the @Stateless annotation, I am able to get the service to work. I would recommend contacting Oracle support regarding the difference in behaviour between WebLogic 12.1.1 and GlassFish 3.1.2.

package forum10967587;

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

import javax.ejb.*;
import javax.jws.WebMethod;
import javax.jws.WebService;

//@Stateless
@WebService
public class PersonServiceImpl implements IPersonService {

    @WebMethod
    public PersonDto allPersons() {
        PersonDto result = new PersonDto();
        List<Person> fList = new ArrayList<Person>(3);

        Person p1 = new Person();
        p1.setBirthDate(new Date());
        p1.setId(1L);
        p1.setName("Jane");
        fList.add(p1);

        Person p2 = new Person();
        p2.setBirthDate(new Date());
        p2.setId(2L);
        p2.setName("John");
        fList.add(p2);

        result.setPersons(fList);
        return result;
    }

}

Test Client Result

Below is the output I received when running the built in test client from the WebLogic Admin Console.

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
    <ns0:allPersonsResponse xmlns:ns0="http://forum10967587/">
      <return>
        <persons>
          <id>1</id>
          <birthDate>2012-06-19T13:56:38.579</birthDate>
          <name>Jane</name>
        </persons>
        <persons>
          <id>2</id>
          <birthDate>2012-06-19T13:56:38.579</birthDate>
          <name>John</name>
        </persons>
      </return>
    </ns0:allPersonsResponse>
  </S:Body>
</S:Envelope>
于 2012-06-18T19:49:10.447 に答える
0

最後に、JAXB の実装を Moxy から Metro に変更することで、私の問題は一時的に解決されました。2 つの jar ファイル javax-xml-bind.jar、javax-xml-ws.jar を Weblogic サーバーの「/weblogic_home/wlserver/endorsed」のパスに追加し、次のプロパティを setDomainEnv ファイルの java_properties 部分に追加する必要があります。

    -Dcom.sun.xml.ws.spi.db.BindingContextFactory=com.sun.xml.ws.db.
glassfish.JAXBRIContextFactory 

-Djavax.xml.bind.JAXBContext=org.eclipse.persistence.jaxb.JAXBContextFactory
于 2015-04-13T12:03:28.677 に答える