Skip to content
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

JAX-WS and SpringBeanAutowiringSupport don't work on Tomcat 7 [SPR-9786] #14419

Closed
spring-issuemaster opened this issue Sep 11, 2012 · 11 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 11, 2012

Jurica Krizanic opened SPR-9786 and commented

Hi,
I am having the problem with SpringBeanAutowiringSupport, I think it is the same as the issue #10323 which is marked as resolved.

I am getting the message below in the log file, and dependencies of AdminWS are not injected, so I am getting NullPointerException. I am using @Autowired annotation to incject the dependecies.

2012-09-11 14:32:46,248 DEBUG SpringBeanAutowiringSupport:89 - Current WebApplicationContext is not available for processing of AdminWS: Make sure this class gets constructed in a Spring web application. Proceeding without injection.

It won't work with combination Spring 3.1.2 + Tomcat 7.0.30.

It works fine with Tomcat 6.0.35.

Can anyone provide help?

Thank you in advance!

Best regards,
Jurica Krizanic


Affects: 3.1.2

6 votes, 15 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 19, 2012

Albert Reyes commented

I'm having this same issue on GlassFish 3.1

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 5, 2012

Andrzej Łach commented

Also the same issue with Jboss 7.1.1 + Spring 3.0.6
It will work when you add following method to the service class:

@PostConstruct
public void init() {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
}
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 23, 2013

Jarek Krochmalski commented

the same with Spring 3.2.2.RELEASE and Tomcat 7.0.29 and Tomcat 7.0.39
works fine with Spring 3.2.2.RELEASE and Tomcat 7.0.25.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 21, 2013

jiri kulhanek commented

Same issue with Tomcat 7.0.42 and Spring 3.2.3.Release
However the workaround with

 
@PostConstruct
public void init() {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
} 

does not work for me. The @PostConstruct method gets called before the Application Context is available by method ```
ContextLoader.getCurrentWebApplicationContext() == null


Does any other workaround exists?

If I call the processInjectionBasedOnCurrentContext when @WebMethod is called on WebService instance, it works. But I'd have to call it for each WebMethod - in such case is better to remove autowiring completely .
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 26, 2014

yongkangliu commented

Another workaround is to call SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this) before use the autowired member.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 17, 2014

Jan Ferko commented

I've been trying to solve this for last couple of days. It looks like this is problem in JAX-WS reference implementation and servlet 3.0. New version of jaxws-ri implements ServletContainerInitializer in WSServletContainerInitializer to setup web services for application. Basically it registers context listener on startup.
Problem is that ServletContainerInitializer.onStartup is executed before execution of any registered ContextListeners, in this case org.springframework.web.context.ContextLoaderListener, so spring beans aren't created at time of web service creation.

Here is issue I found on JAX-WS issue tracker JAX_WS-1060.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Mar 18, 2015

Amra Smajic commented

Hi
I had the same problem.....
I'm using Tomcat 7.0.57 and Spring 3.1.0.RELEASE
I solved it with adding <absolute-ordering /> in my web.xml

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 25, 2015

Kazuki Shimizu commented

I cannot solve a this problem ...

Environment are :

  • Java 8.0.45
  • Tomcat 8.0.22 (Servlet 3.1)
  • Metro(JAX-WS reference implementation) 2.3.1
  • Spring 4.1.4.RELEASE

I want know a best practice for this issue.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 11, 2015

Vanderlei Matos Andre commented

Same issue with Spring 4.0.5.RELEASE and JBoss AS 7.1.

SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this); works for me!!

Thanks for support

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Mar 20, 2016

Peadar O'Maoileoin commented

This is an issue for me with Spring 4.2.5-RELEASE, tomcat 8.0.30, tomcat 8.0.32, tomcat 7.0.67 with jdk 1.7.

The @PostConstruct call to processInjectionBasedOnCurrentContext() did not work for me but if I do a null check inside my web method and then call processInjectionBasedOnCurrentContext(this) then it will work.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.