This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 190237 - RESTful WS from entity classes do not deploy on WebLogic
Summary: RESTful WS from entity classes do not deploy on WebLogic
Status: VERIFIED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.0
Hardware: PC All
: P2 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-08 13:43 UTC by Jeffrey Rubinoff
Modified: 2019-07-10 07:43 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stacktrace (6.49 KB, text/plain)
2010-11-11 12:06 UTC, Denis Anisimov
Details
Error in the server log on service access (6.59 KB, text/plain)
2010-11-16 18:48 UTC, Petr Jiricka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Rubinoff 2010-09-08 13:43:04 UTC
When you create a RESTful web service from entity classes, whether directly from the classes or from the RESTful WS from Database wizard, the application fails to deploy to WebLogic. The error message is that "Cannot bind null object to jndi with name UserTransactionJNDI" The application deploys to GlassFish, and an application with entity classes but without RESTful WS deploys to WebLogic.
Comment 1 Jeffrey Rubinoff 2010-09-08 14:01:52 UTC
The service works if you
1. Comment out the resource-ref element in the web.xml DD
<resource-ref>
<res-ref-name>UserTransaction</res-ref-name>
<res-type>javax.transaction.UserTransaction</res-type>
<res-auth>Container</res-auth>
</resource-ref>

2. Change the PersistenceService class so that it explicitly calls javax.transaction.UserTransaction. In other words, replace 
   this.utx = (UserTransaction) new  
           InitialContext().lookup("java:comp/UserTransaction");
with
   this.utx = (UserTransaction) new 
           InitialContext().lookup("javax.transaction.UserTransaction");
Comment 2 Jeffrey Rubinoff 2010-09-09 14:58:45 UTC
The workaround for this issue triggers an analogous exception when the service is deployed to GF 3.1 On GF 3.1, testing a RESTful WS with the workaround throws:
java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'javax.transaction.UserTransaction' in SerialContext  [Root exception is javax.naming.NameNotFoundException: javax.transaction.UserTransaction not found]
Comment 3 Petr Jiricka 2010-10-06 15:52:04 UTC
-> P2.
Comment 4 David Konecny 2010-10-07 02:13:32 UTC
EE specification (from version 5 at least) mandates "java:comp/UserTransaction", for example see "EE.6.7" in EE 5 spec ("Java Transaction API (JTA) 1.1 Requirements"):

"JTA defines the UserTransaction interface that is used by applications to start, and commit or abort transactions. Application components get a UserTransaction object through a JNDI lookup using the name java:comp/UserTransaction or by requesting injection of a UserTransaction object."

(In reply to comment #1)
> The service works if you
> 1. Comment out the resource-ref element in the web.xml DD
> <resource-ref>
> <res-ref-name>UserTransaction</res-ref-name>
> <res-type>javax.transaction.UserTransaction</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>

I would believe that this should not be needed in any case - even in EE 5 apps. If UserTransaction can be injected then it can be also found in JNDI without any entry in web.xml.

> 2. Change the PersistenceService class so that it explicitly calls
> javax.transaction.UserTransaction. In other words, replace 
>    this.utx = (UserTransaction) new  
>            InitialContext().lookup("java:comp/UserTransaction");
> with
>    this.utx = (UserTransaction) new 
>            InitialContext().lookup("javax.transaction.UserTransaction");

"javax.transaction.UserTransaction" sounds like implementation specific name used by Weblogic. Do not use it.

If this does not really work then we should consult Weblogic team.
Comment 5 Denis Anisimov 2010-10-26 11:22:36 UTC
There is no information from WebLogic about this problem.
According to David's comment JNDI name in the generated source code conform with 
Java EE specification.

But WebLogic wants another JNDI name. So the option could be different JNDI names
respectively target J2EE server. But it is bad approach because user could 
change target J2EE server after code is already generated. 

So we still need to consult with WL developers about this issue. Probably this 
is the problem of WL runtime.
Comment 6 Petr Jiricka 2010-11-01 09:04:58 UTC
> According to David's comment JNDI name in the generated source code conform
> with Java EE specification.

I think JNDI names were standardized in Java EE 6; prior to that, they were server-specific.

> So the option could be different JNDI names
> respectively target J2EE server. But it is bad approach because user could 
> change target J2EE server after code is already generated. 

Yes, changing the server will break the code, but switching the server does not work very reliably anyway - I don't think this is a big issue, we can just say this is unsupported.

> Probably this is the problem of WL runtime.

I would not call this a problem - just different conventions.
Comment 7 David Konecny 2010-11-02 19:26:39 UTC
(In reply to comment #6)
> > According to David's comment JNDI name in the generated source code conform
> > with Java EE specification.
> 
> I think JNDI names were standardized in Java EE 6; prior to that, they were
> server-specific.

See my comment #4 - it is mandated since EE 5.
Comment 8 Denis Anisimov 2010-11-11 08:37:52 UTC
I'm able to reproduce this issue with WL both 10.3.3 and 10.3.4 versions.
Comment 9 Denis Anisimov 2010-11-11 12:06:09 UTC
I'm able to deploy war after commenting out UserTransaction "resource-ref" 
element in web.xml 

But access to webservice lead to runtime exception ( see attached stacktrace ).
I have no idea what is the reason.
Comment 10 Denis Anisimov 2010-11-11 12:06:37 UTC
Created attachment 102904 [details]
stacktrace
Comment 11 Denis Anisimov 2010-11-11 12:12:39 UTC
Please note that Exception has been thrown on lines :
      utx.begin();
  --->em.joinTransaction();

em.joinTransaction() is on line 70 of PersistenceService :
at service.PersistenceService.beginTx(PersistenceService.java:70)

It means that utx which is instance of UserTransaction is no null and was 
successfully found in the context via lookup.

So the problem of exception in my case is entity manager and it relates 
to jdbc drivers and datasurce problems.
Comment 12 Petr Jiricka 2010-11-11 12:22:22 UTC
How about if you change the default persistence provider to TopLink in WebLogic's admin console? Will it help?
Comment 13 Jeffrey Rubinoff 2010-11-11 12:25:27 UTC
I changed the WL default persistence provider to TopLink before even I first tried this out and reported the bug.
Comment 14 Sergey Petrov 2010-11-11 12:31:51 UTC
Last exception says about missed properties for openjpa, it may be an issue with pu creation if this property is required.
Comment 15 Denis Anisimov 2010-11-11 13:04:59 UTC
The same thing with TopLink provider.
Other exception with datasource jndi name resolution problem on the line 70.
Again user transaction access has no problem .
Comment 16 Denis Anisimov 2010-11-12 15:29:18 UTC
Jeff, could you please confirm/disclaim that commenting out of "resource-ref"
element for UserTransaction doesn't solve the problem?
Is it really necessarily to change jndi name to get working project on WL ?

It could be possible that the problem is only "resource-ref" element in web.xml
file which is really not needed by David's comment.

If there is still an error could you please describe this error with more details.
This error shouldn't at deployment time because I'm able to deploy 
project on WL without any problem without ""resource-ref" element.

I can't check it by myself because any JPA provider generates error on 
entity manager access ( as mentioned in my previous comments ).
Comment 17 Jeffrey Rubinoff 2010-11-13 14:56:28 UTC
Commenting out resource-ref works, in so far as it allows the application to be deployed.
The NB RESTful service tester does not produce results for the deployed service. I do not know what the problem is or whether the tester should work. WebLogic takes up all the memory of my computer and it is very difficult for me to experiment very much with the deployed service.
Comment 18 Petr Jiricka 2010-11-16 18:48:05 UTC
Created attachment 103016 [details]
Error in the server log on service access

I am getting the attached error in the server log after:
- changing JPA provider to EclipseLink
- commenting out the resource-ref element in web.xml
- deploying (deployment itself succeeds)
- accessing the resource from the Web service test UI

Looks related to JPA 2.0? Why is it looking for the JPA canonical metamodel, which is not available in JPA 1.0?
Comment 19 Sergey Petrov 2010-11-16 18:53:01 UTC
I remember the issue with accessing canonical metamodel but itt was fixed. It may be another use-case. Also this exception looks different from all above.
Comment 20 Sergey Petrov 2010-11-16 18:55:15 UTC
It was http://netbeans.org/bugzilla/show_bug.cgi?id=189626 if I remember right.
Comment 21 Petr Jiricka 2010-11-18 17:54:17 UTC
I am looking at that issue, and now I am thinking - could this be related to deploy on save? I was able to make the whole scenario work using the following steps:

1. Create Java EE web project with WebLogic target
2. Turn off deploy on save on this project
3. Create entity classes
4. Create RESTful web service from entity classes
5. Remove the <resource-ref> element generated in web.xml
6. Apply workaround for bug 192126 by manually editing setup/datasource-1-jdbc.xml
7. Deploy the application
8. Use Test RESTful Web Services action
9. When you get the data, it works well
Comment 22 Denis Anisimov 2010-11-18 18:23:24 UTC
Thank you very much Petr!

Probably you have found the issue why I haven't been able to deploy datasource 
to WL.

So resolution for this issue :
do not add "<resource-ref>" for UserTransaction into deployment descriptor.
( this is not required by Java EE specification either ).

All other problems with project deployment which are discovered here :
1) issue #192126 
2) probably deploy on save feature ( which could a consequence of first item ).
And they doesn't relate to WS functionality.
Comment 23 Denis Anisimov 2010-11-19 09:13:02 UTC
changeset:   182682:e6370ad30971
user:        Denis Anisimov <ads@netbeans.org>
date:        Fri Nov 19 12:08:38 2010 +0300
summary:     Fix for BZ#190237 -  RESTful WS from entity classes do not deploy on WebLogic
Comment 24 Petr Jiricka 2010-11-19 10:20:17 UTC
So do we also need a separate bug for the Deploy on Save problem?
Comment 25 Denis Anisimov 2010-11-19 15:32:17 UTC
>So do we also need a separate bug for the Deploy on Save problem?
I suppose so. If it really exist. 
I just want to say that switch off of deploy on save is required for 
datasource file correction as I understand.
Probably originally correct datasource xml file will allows to work 
deploy on save correctly.
I think Petr Hejl is owner of this functionality. May be mention of the problem 
with deploy on save could be just added into issue #192126 ( with reference to
current bug ).
Comment 26 Quality Engineering 2010-11-20 06:12:46 UTC
Integrated into 'main-golden', will be available in build *201011200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/e6370ad30971
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#190237 -  RESTful WS from entity classes do not deploy on WebLogic
Comment 27 Petr Jiricka 2010-11-22 14:56:40 UTC
I filed a separate bug 192285 for the Deploy on Save (internal parsing infrastructure) problem.
Comment 28 Jeffrey Rubinoff 2011-09-21 19:05:38 UTC
Sorry, fixed ages ago
Comment 29 ankei 2019-07-10 07:43:35 UTC
Now you can solve here for your latest unscrambler scrabble word finder    https://scrabblewordfinder.me . This is main thing where we can find the simple ways for the clear lots fo concepts.