2

I have a package of many JAX-WS web services that run in WebSphere 7 where I had configured a data-source to a DB2 database including the JAAS authentication under an alias.

Now, i just want to test the logic of my DAOs, where -of course- I have an entity manager. So, I created an application client project, partially guided by this tutorial http://www.ibm.com/developerworks/rational/library/08/0219_jadhav/, where I have :

  1. an application-client.xml

     <?xml version="1.0" encoding="UTF-8"?>
     <application-client version="5"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_5.xsd" metadata-complete="false">
    
    <display-name>ServiciosAcademicoTests</display-name>
    
    <resource-ref>
        <res-ref-name>ServiciosAcademicoTests</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Application</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    

  2. a ibm-application-client-bnd.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <application-client-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-client-bnd_1_0.xsd"   version="1.0">
    
        <resource-ref name="ServiciosAcademicoTests" binding-name="java:comp/env/jdbc/MyDB">
        </resource-ref>
    
    </application-client-bnd>
    

When I run my test, it returns the following error "Null userid is not supported." :

 <openjpa-1.2.1- (...) fatal general error> org.apache.openjpa.persistence.PersistenceException: **Null userid is not supported.** ERRORCODE=-4461

I tried specifying and authentication in the ibm-application-client-bnd.xml but I'm still getting the same error :

<?xml version="1.0" encoding="UTF-8"?>
<application-client-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-client-bnd_1_0.xsd"
version="1.0">

<resource-ref name="ServiciosAcademicoTests" binding-name="java:comp/env/jdbc/MyDB">
    <authentication-alias name="dmfloresNode01/XXX "/>
</resource-ref>

Just in case, my unit test is this :

public class CursosTest extends TestCase {

ICursoDAO cursoDAO; // From another project

Integer idAlumno = 123456;

String usuarioPortal = "xxx";

public void testCursosLlevados() throws Exception {

    cursoDAO = new CursoDAO(); 

    List<CursoLlevadoVO> lstCursos = cursoDAO
            .obtenerCursosLlevadosPorAlumno(idAlumno, usuarioPortal);

    if (lstCursos != null) {
        for (CursoLlevadoVO cursoLlevadoVO : lstCursos) {
            System.out.println(cursoLlevadoVO.getNombre());
        }
    }

    assertNotNull(lstCursos);
}

}

I detected that the problem happen when the entitymanager is created :

entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
entityManager = entityManagerFactory.createEntityManager(); // <-- here

Could you help me, please ? two days looking for a solution :( .

UPDATE :

I think that my application-client even isn't querying the data source, because I changed the jdbc/MyDB to jdbc/XXX and the problem is the same (http://www-01.ibm.com/support/docview.wss?uid=swg21596108 , I'm not getting the "Could not lookup datasource named" message but it could be a cause). Also I tried to deactivate the authentication to the data source in the administrative console of Websphere, but I'm getting same results.

This is my persistence.xml file on the project of webservices (that runs fine, the problem is my application-client that is using a DAO class just for testing purposes, not for testing webservice just in case) :

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
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">

<persistence-unit name="ServiciosAcademico">
    <jta-data-source>jdbc/MyDB</jta-data-source>
    <class>...</class>
    <properties>
        <property name="openjpa.jdbc.Schema" value="XXX"/>
    </properties>
    </persistence-unit>

. This is my data source on websphere, it's under a certain scope :

enter image description here enter image description here

Day 3 :

Probably, when I remove the alias for the data source I get the same message, so the application-client could be ok about connecting to the data source, but this isn't using any authorization method.

enter image description here

Thanks for your help. I'm a novice of WebSphere.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Daniel Flores
  • 770
  • 3
  • 12
  • 31

0 Answers0