-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow resource references in persistence xml datasource #24964
Allow resource references in persistence xml datasource #24964
Conversation
new File("src/main/resources/org/glassfish/main/test/app/synchronize/sample.json"), | ||
"resources/sample.json") | ||
.addAsWebResource(new File("src/main/resources/org/glassfish/main/test/app/synchronize/index.html")); | ||
.addAsWebInfResource(getTestResourceStatic("sample.json"), "resources/sample.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don§t need to create a method for that, you can even shorten it to the resource reference. It is also better if you want to filter the file by maven.
It is always wrong to touch src/main/resources from the test in runtime (also Eclipse uses different basedir than Maven).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got you. Tests should get resources from the classpath instead of from the source directory. I updated the code.
try { | ||
return referenceContainer.getResourceReferenceByName(dataSourceName.toString()).getJndiName(); | ||
} catch (IllegalArgumentException e) { | ||
return dataSourceName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to log the exception as a warning at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not here. This is a valid condition - if the datasource name is a proper JNDI and not a reference, just use it without any change. It would only pollute logs if it was a warning. I can add a debug logging.
The getResourceReferenceByName
gives an exception if resource not found. Ideally, I would rather use findResourceReferenceByName
, which returns a null
, but that one is protected
and only in WebBundleDescriptor
, so I rather used a method on the interface ResourceReferenceContainer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, debug/trace is good then. Sometimes I am hunting things around DOL and XML/annotations and any such log is useful.
Seems something is still missing:
|
Hm, obviously, the Derby DB is not running, it's not started by the test suite. I'll try to set up the defalt datasource to point to an embedded database. |
Some EJB test failed in CI with no info about it. @dmatej , can you please have a look and see what's wrong with it? |
It does seem " ejb_group_1 / ejb_group_1.ejb-ejb30-hello-session3. ejb-ejb30-hello-session3ID" fails structurally. @OndroMih did you try to run it locally? |
@arjantijms , I ran locally after merged from master, and I get 10 failed tests when I run From the
I'll try to look what's happening. It's weird that when I ran the test without merging master, all tests pass but there are only 110 tests. The latest Jenkins build for this PR reports 111 tests:
And the one that is failing is missing in the 110 tests when I run my branch. So, my branch is based on master, which only has 110 tests. The latest Jenkins run for this PR has 111 tests. And now the master branch has 113 tests. Were any tests added to the |
…resource reference
Log in case JPA DS is not a reference but real JNDI name
So that tests don't need a running external DB
4fb25d5
to
592fa1f
Compare
I got more familiar with how the tests are set up, and then I found the culprit. In the appclient context, there's a null value for context where I didn't expect null on server. |
Cleanup, added javadoc, moved a helper class to the test tools module
@dmatej , @arjantijms , please review. |
Looks good to me now! |
Allows to use a resource reference in persistence.xml, as in the provided test. This reference can be changed using resource-ref in
glassfish-web.xml
with alternative runtime descriptor or in a deployment plan during deployment.