-
Notifications
You must be signed in to change notification settings - Fork 304
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
Bean identifier index inconsistency after Hot re-deployment from NetBeans #300
Comments
Likely cause of the error is the following code:
This snippet is used inside a ServerAuthModule. I am trying to release the bean using |
How are you registering/deregistering the JASPIC SAM in your code? |
The JASPIC code/jar is copied to the glassfish/lib folder and registered as a MessageSecurity through the admin console. Instructions taken from here: https://www.ibm.com/developerworks/java/library/j-authenticroast/ (see section container configuration). The actual JASPIC code that is deployed deployed is here: https://github.com/ratcashdev/authenticroast Try to change the SampleOAuth.java class while it's deployed 2-3 times, and do BTW: Is there a more straightforward way to register the JASPIC code without messing inside the admin console? |
Take a look here for an example of how to register a SAM programmatically |
Tried with the code from the sample (JaspicUtils). Thank you for pointing me to this solution. Simplifies it a lot. However, it did not help with the exception I was getting in the OP. I have even tried to register a bean (as a JASPIC ServerAuthModule) that was injected by CDI into my |
Can you try removing the registration of the SAM module on undeploy? |
Unfortunately, even after a successful deregistration of the SAM module and redeploy the exception remains. Edit: I think I got closer: Edit2: eliminated all the ThreadLocals in the old code. The exception still remains. |
Tried replaced the weld-osgi-bundle jar with a newer version (2.2.10-2.2.12 Final), but it did not help. |
Hi Steve, is there anything else I can do to help replicate/solve this issue? |
We just need to try and replicate the issue. We haven't had a chance to replicate with your test application yet. I'll let you know. |
Hi I've tried to reproduce this but can't can you provide me step by step instructions? To access the application and I get a 401 UnAuthorized error and the server log is; I have then edited SampleOAuth and the application redeploys with server log Info: RegId = __311_HttpServletserver /JSR196OAuthLogin Severe: No valid EE environment for injection of com.ratcash.multilogin.authenticators.AppAuthModule I have done this multiple times but not received the IllegalStateException |
BTW I don't think you should put a scope annotation on an injection point |
@Inject: you're right. I misinterpreted some other sources on the internet. The definitive seems to be https://docs.oracle.com/javaee/6/tutorial/doc/gmgil.html |
As for the Sample app: commit #d386dc2a2f192f3d519f21f9ca12326c4ab48527 needs the jars in the lib folder of glassfish, however, current master doesn't (does the programmatic-registration) The third redeploy attempt always caused the exception. I will try it on a virgin installation of payara. |
OK thanks I will try deleting the jars from the lib directory and see what happens |
wrt to @Inject you need to create a producer method like; to get the non-CDI object injected |
behaves the same on a virgin installation of Payara 4.1.152.1 with the embedded domain 'domain1'. What's even more disturbing, that after some edits, back and forth, suddenly it works again, regardless of the file's actual content (i.e. whether it actually equals to the original content when deployed for the first time). |
I removed the jars from the lib directory and redeployed via NetBeans many times and can not reproduce the issue on Linux 64bit 1.8.0_45-b14 + NetBeans 8.0.2 + Payara 4.1.153-SNAPSHOT |
I'm afraid also can't reproduce on Payara 4.1.152.1 on Linux |
Strange. The only notable difference seems to be the OS, but I strongly doubt it could cause these kind of issues. What else do you suggest to try/check/eliminate? |
As a matter of fact, I can reproduce the issue on two different laptops with Windows 7. One DOES have an anti-virus, the other doesn't. Maybe some windows services (background shadow copy, defender, whatnot) are interfering? But in such a case a lot of ppl should have had similar issues. |
Got rid of the
So it seems this has a close relationship with #299 . |
Tested it on a plain old vanilla glassfish 4.1 from oracle. That version did not throw the inconsistency exception on the same machine(win 7 64 bit)/java(1.8.0_45) version, whereas payara 4.1.152.x and 4.1.151 did. |
Is it possible to somewhere disable the "distributed container"? |
Hi, I've tried to recreate this on a Windows environment, and I'm getting the same results as Steve. I did the following on 64 bit Windows:
|
The procedure seems to me right. I will try to remove EVERYTHING (incl. JAVA and MAVEN) from my windows machine and repeat the steps you outlined. The maven version is (note the paths):
JAVA home is visible from the output as well. |
Removed JAVA, Netbeans and maven. Reinstalled everything from scratch including a virgin payara distribution. Path still contained spaced. Result: Got the "inconsitency" exception. |
I just realized, that you're clicking on "RUN" multiple times. This is not what I am doing. I click RUN only the very first time (which in turn asks me which app server to use/start) and I tell Netbeans to remember my selection during the session.
If I click RUN after SAVE, the inconsistency exception is not thrown. |
OK I've managed to reproduce your error now, just clicking save does seem to make it appear after three times. We'll look into a bit more for you. Now that I know what to do, I'll see if I can reproduce it on Linux as well. |
I've managed to reproduce this error on Linux with Payara 4.1.152.1. The error doesn't seem to be present in 4.1.151 though, so I thought I'd check the GlassFish upstream, and the error does get thrown there as well. With that, it looks like it'll be something we've brought in from one of GlassFish upstream cherry-picks since 4.1.151. |
I just tried recreating it on clean install of 4.1.151 again on a different VM, and couldn't. |
I have just re-tested on 4.1.151 (downloaded from http://bit.ly/1CGCtI9 ) I could not reproduce the bug. So I guess I have to apologize for my former statement. |
No problem, I was just trying to determine if it was an upstream bug or something we'd put in ourselves. |
I was checking the issues labelled as "upstream" for Payara and the related commits. I am willing to do the bisection straight on Payara, if I could get access to the nighly builds. Are those reachable somewhere? Could not download them from your jenkins. |
OK, tracked it down. Plain Glassfish nightly glassfish-4.1-b13-03_26_2015 is OK, using Weld 2.2.2 (Final). The nighly glassfish-4.1-b13-03_27_2015 is bad, exhibits the problem described here. The changelog of the latter mentions a single thing: "Upgrade to Weld 2.2.10.Final" |
Downgrading to Weld 2.2.8 (Final) resolves the issue. 2.2.9 already throws the exception. Upgrading to 2.2.14 does not help. After reading the changelog of 2.2.9, it seems this behavior is not really a bug, but rather a feature:
|
OK thanks for the diagnostic. We can't revert Weld due to fixes we need in the later weld so we'll need to spend some time looking into this in more detail. In particular the new Weld functionality and why it causes problems with hot deployment via NetBeans and not on a full redeploy. |
https://issues.jboss.org/browse/WELD-1887 is interesting. It says it can be disabled somehow. |
I think this is related to the fact that I believe NetBeans uses keepState when using "deploy on save" which means it will attempt to retain the session state by serializing and deserializing the session objects. Can you try setting an explicit serialVersionUID on any classes you put into the Session. Also the property you refer to is org.jboss.weld.serialization.beanIdentifierIndexOptimization can you try setting that as a System property to false on the server NetBeans is deploying to. Although, at this stage, I don't know if setting a system property will be used by Weld. |
created a weld.properties file under /src/main/resources with the content This masked the apparent underlying problems and the exception was not thrown. Setting it to true caused the exception to appear again. The only code that is session scoped is the PrincipalHolder. Giving him a new serialVersionUID for every deployment also helps avoid the exception. |
OK I think this is the weld bug you refer to |
WELD-1887 is marked as resolved in 2.2.10 (and I also tried 2.2.14). I guess in our case it must be something else. |
It's resolved in that they have set a property to switch off the bean index optimisation. Not that they have fixed the problem with hot deploy and sessions. Which fixes the problem in your case as well. |
I see now. I also found the clarification in the Weld RefGuide. Pasting the link here for completeness. This means this ticket can be closed as resolved. |
We need to explicitly set the property org.jboss.weld.serialization.beanIdentifierIndexOptimization = false in Payara similar to the Weld Servlet. |
To my understanding, this new 'feature' of WELD only affects development installations. Is it actually desirable to disable this optimization in production environments? I have not tested this in a clustered setup... |
This also causes problems on redeploys with keep session state. |
Also causes problems in shared session with Payara Micro |
* removed repeated instance creation / removal to alleviate race conditions in HK2 and stabilize this test * restore delete instance command * removed hardcoded instance name * removed unnecessary code from the test * fixed member reference compilation error
Editing a CDI bean in netBeans and hitting save redeploys the application in GF.
After visiting a JAX-RS resoruce using the CDI bean we get the error below:
The text was updated successfully, but these errors were encountered: