javaee7-samples icon indicating copy to clipboard operation
javaee7-samples copied to clipboard

Test native-sql-resultset-mapping fail in Weblogic 12.1.3

Open joedayz opened this issue 9 years ago • 7 comments

Hi, I am trying it first test with web logic 12.1.3.

Step 1: My profile was updated like this:

weblogic-remote-arquillian
        <properties>
            <!-- Default username/password that instructions in README.md ask to use 
                when starting up WebLogic for the first time. Note that WebLogic does not 
                have any default username/password of its own. -->
            <weblogicRemoteArquillian_adminUserName>weblogic</weblogicRemoteArquillian_adminUserName>
            <weblogicRemoteArquillian_adminPassword>welcome1</weblogicRemoteArquillian_adminPassword>

            <!-- Default host and port when running WLS locally -->
            <weblogicRemoteArquillian_adminUrl>t3://localhost:7001</weblogicRemoteArquillian_adminUrl>

            <!-- Default target after having installed developer zip distribution for 
                WebLogic -->
            <weblogicRemoteArquillian_target>myserver</weblogicRemoteArquillian_target>
        </properties>

        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-wls-remote-12.1.2</artifactId>
                <version>1.0.0.Alpha3</version>
                <scope>test</scope>
            </dependency>
        </dependencies>

Step 2: Start Weblogic

Step 3: mvn test -Pweblogic-remote-arquillian -DweblogicRemoteArquillian_wlHome=/Users/josediaz/Tools/wl12210

Error Test:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.295 sec <<< FAILURE! testJpaNativeSqlResultSetMapping(org.javaee7.jpa.nativesql.resultset.mapping.JpaNativeSqlResultSetMappingTest) Time elapsed: 0.329 sec <<< ERROR! java.lang.NullPointerException at org.javaee7.jpa.nativesql.resultset.mapping.JpaNativeSqlResultSetMappingTest.testJpaNativeSqlResultSetMapping(JpaNativeSqlResultSetMappingTest.java:67)

Error Weblogic:

INFO: BeanManager not found. <Feb 26, 2016 2:21:26 PM PET> <Warning> <EclipseLink> <BEA-2005000> <2016-02-26 14:21:26.705--ServerSession(664831661)--Failed to find MBean Server: javax.naming.NameNotFoundException: remaining name: comp/env/jmx/runtime> <Feb 26, 2016 2:21:26 PM PET> <Warning> <EclipseLink> <BEA-2005000> <2016-02-26 14:21:26.705--ServerSession(664831661)--Unable to unregister MBean [null] because the MBeanServer is null. Verify that your ServerPlatform is JMX enabled.> <Feb 26, 2016 2:21:26 PM PET> <Notice> <EclipseLink> <BEA-2005000> <2016-02-26 14:21:26.706--ServerSession(664831661)--909fa198-0844-4514-b4f9-3df023d60c83file:/Users/josediaz/Tools/wls12130/user_projects/domains/mydomain/servers/myserver/tmp/_WL_user/909fa198-0844-4514-b4f9-3df023d60c83/mh2r7b/war/WEB-INF/lib/_wl_cls_gen.jar_MyPU logout successful>

Jose

joedayz avatar Feb 26 '16 19:02 joedayz

Not every sample runs on every server.

In general if a sample doesn't run on one server but does run on other ones, it's likely a bug in that server. This is actually the intend of these samples, to point out bugs in servers.

If you think there's something specifically faulty in the test it can be looked at of course.

arjantijms avatar Feb 26 '16 21:02 arjantijms

Yes. The problem was solved adding a META-INF/beans.xml and a DefaultDataSource (I had to create one datasource with similar JNDI name) in persistence.xml.

I will continue testing in weblogic.

Jose

joedayz avatar Feb 26 '16 21:02 joedayz

DefaultDataSource (I had to create one datasource with similar JNDI name) in persistence.xml.

Oh, of course. I forgot to mention that WebLogic 12.1.3 is a Java EE 6 server. The samples require Java EE 7 (WebLogic 12.2.1+). Sorry for that.

The default data source is a new feature in Java EE 7, so that's indeed not available in Java EE 6. The idea there is that there's already a basic/simple data source available without you having to configure anything.

arjantijms avatar Feb 26 '16 21:02 arjantijms

In theory, weblogic 12.2.1 has a datasource by default. I downloaded the weblogic 12.2.1 yesterday , I created a new domain with basic wls template and my surprise was that it does not have datasources.

This was my first error and when added , the next error was BeanManager null. For this reason, I added beans.xml

Maybe exists some domain template that should install for have a default datasource.

joedayz avatar Feb 26 '16 21:02 joedayz

By the spec, a Java EE 7 should provide you with a default datasource. That's why the samples don't create one and just expect it to be there.

radcortez avatar Feb 27 '16 03:02 radcortez

@radcortez Indeed, there are unfortunately a few caveats along the lines of that the datasource itself has to be there (in the correct JNDI namespace or, in case of e.g. JPA, by not specifying any namespace), but the database to which that datasource is connected doesn't necessarily have to be there by default.

This is a really odd omission in the spec. I tried to address it a couple of times but no success yet.

That said, the release notes of WebLogic explicitly state support for the default datasource. See

  • https://docs.oracle.com/middleware/1221/wls/NOTES/whatsnew.htm#NOTES379
  • https://docs.oracle.com/middleware/1221/wls/JDBCA/default_datasource.htm#JDBCA729

arjantijms avatar Feb 27 '16 12:02 arjantijms

@arjantijms

I was looking for the spec section about Default Datasources and found this:

EE.5.19 Default Data Source The Java EE Platform requires that a Java EE Product Provider provide a database in the operational environment (see Section EE.2.6, “Database”). The Java EE Product Provider must also provide a preconfigured, default data source for use by the application in accessing this database. The Java EE Product Provider must make the default data source accessible to the application under the JNDI name java:comp/DefaultDataSource. The Application Component Provider or Deployer may explicitly bind a DataSource resource reference to the default data source using the lookup element of the Resource annotation or the lookup-name element of the resource-ref deployment descriptor element. For example, @Resource(lookup="java:comp/DefaultDataSource") DataSource myDS; In the absence of such a binding, the mapping of the reference will default to the product's default data source. For example, the following will map to a preconfigured data source for the product's default database: @Resource DataSource myDS;

My understanding of the spec is that both ways should work, by stating explicitly the JNDI name or by omitting it. This works fine with other servers.

Apparently by reading https://docs.oracle.com/middleware/1221/wls/JDBCA/default_datasource.htm#JDBCA729, seems that WebLogic only supports the Default Datasource by stating explicitly the JNDI name. I'm inclined to say that it's a bug on the WebLogic side and they should also support injection without the JNDI name.

radcortez avatar Feb 29 '16 07:02 radcortez