Rectangle 27 1

Two problems in your AcmeService.class.

1)You imported com.acme.data.AcmeDao but you are referencing com.acme.service.AcmeDao in the context.xml.

2)You are setting com.acme.service.AcmeDao reference in AcmeService bean definition in context.xml

If you want to reference com.acme.service.AcmeDao, change import to com.acme.service.AcmeDao. Then, remove @Autowired annotation as you are already referencing this in context.xml.

Thanks for the suggestion Prasad, but needed Autowired. Got it to work by adding @Repository in AcmeDao. Not sure why. Also, temporarily added constructor in AcmeService to debug and make sure the class was instantiated. I saw other posting suggesting to use <context:component-scan base-package=... but it turned out it wasn't necessary.

@westcoastmilt Since acmeDao is specified both in xml config and annotation, I said annotation is not required as xml config will take precedence.

Weblogic 10.3.6 Spring 3.2 @Autowired doesn't work - Stack Overflow

spring weblogic
Rectangle 27 36

I was able to resolve this with help from the Spring Security team. I have updated the Gist to reflect a working configuration. I had to follow the steps given below in order to get everything to work as expected.

Add a MultipartFilter to web.xml as described by @holmis83 in the answer above, ensuring that it is added before the Spring Security configuration:

<filter>
    <display-name>springMultipartFilter</display-name>
    <filter-name>springMultipartFilter</filter-name>
    <filter-class>org.springframework.web.multipart.support.MultipartFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>springMultipartFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
    <display-name>springSecurityFilterChain</display-name>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>ERROR</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
</filter-mapping>
filterMultipartResolver

in the root Spring application context

make sure that the Multipart Resolver is declared in the root Spring Context

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath*:springWebMultipartContext.xml
    </param-value>
</context-param>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="filterMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="100000000" />
    </bean>
</beans>

Make sure that the bean is called filterMultipartResolver as any other bean name is not picked up by MultipartFilter configured in web.xml. My initial configuration was not working because this bean was named multipartResolver. I even tried passing the bean name to MultipartFilter using web.xml init-param but that did not work either.

Tomcat 7.0+ has in-built multipart support, but it has to be explicitly enabled. Either change the global Tomcat context.xml file as follows or include a local context.xml file in your WAR file for this support to work without making any other changes to your application.

<Context allowCasualMultipartParsing="true">
    ...
</Context>

After these changes using Apache Commons Multipart Resolver our application is working so far on Tomcat, Jetty and Weblogic.

Upvoting for "Make sure that the bean is called filterMultipartResolver as any other bean name is not picked up by MultipartFilter configured in web.xml". It also applies to annotation configuration, bean method name should be filterMultipartResolver. Example: @Bean public MultipartResolver filterMultipartResolver() {...} Before doing this, I was getting the error: ** java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided**.

Thanks, the docs didn't help me get the issue resolved. I had to add Apache Commons File Upload to my pom.xml to get everything working.

I would like to make more evident that the multipart resolver bean named filterMultipartResolver must stay in the ROOT Spring application context as opposed to the one that is used in a (non-CSRF) setup without filter, that must be named multipartResolver and can stay in the WEB Spring application context

I second the thought of @jpganz18 as I'm too getting empty uploaded file and my multipart filter cannot find the parts in the request. Any thoughts on this ??

Spring Security 3.2 CSRF support for multipart requests - Stack Overfl...

spring spring-mvc spring-security csrf
Rectangle 27 4

JBoss and Glassfish are basically full Java EE Application Server whereas Tomcat is only a Servlet container. The main difference between JBoss, Glassfish but also WebSphere, WebLogic and so on respect to Tomcat but also Jetty, was in the functionality that an full app server offer. When you had a full stack Java EE app server you can benefit of all the implementation of the vendor of your choice, and you can benefit of EJB, JTA, CDI(JAVA EE 6+), JPA, JSF, JSP/Servlet of course and so on. With Tomcat on the other hands you can benefit only of JSP/Servlet. However to day with advanced Framework such as Spring and Guice, many of the main advantage of using an a full stack application server can be mitigate, and with the assumption of a one of this framework manly with Spring Ecosystem, you can benefit of many sub project that in the my work experience let me to left the use of a full stack app server in favour of lightweight app server like tomcat.

java - What is the difference between Tomcat, JBoss and Glassfish? - S...

java tomcat jboss glassfish enterprise
Rectangle 27 0

I'm not really an expert on this topic but the way I figured it out was that the session was possibly being created by both the container and spring security. My container authentication is handled by WebLogic. There were a bunch of google results that show how to write a custom filter for preauth but it still never seemed to work right until I changed spring security to be stateless.

<http auto-config="false" use-expressions="true" disable-url-rewriting="true"
    create-session="stateless" entry-point-ref="http403EntryPoint">

java - Spring Security + Container Managed Authentication issue - Stac...

java spring java-ee spring-security
Rectangle 27 0

The name of the context-param is I think wrong, it should be contextInitializerClasses not contextInitializerClass , that could be the reason why your ApplicationContextInitializer is not getting picked up

Also you seem to be missing the entry for ContextLoaderListener in your web.xml file, try adding that too:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

This is the one which loads up the bean configuration xml file specified in the contextConfigLocation tag

Well that is embarrassing, you are correct about the name, it needs to be *Classes. Thanks for the help.

java - Spring 3.1 contextInitializerClasses not Working on WebLogic 10...

java mongodb spring-mvc weblogic weblogic-10.x
Rectangle 27 0

The "right" JEE approach is not caring about these low-level details in code. After finding out which DataSource doesn't work, troubleshooting problems involves only application server logs and application server configuration tweaks.

  • you aren't supposed to lose track of what abstract data sources you are using; using more than one DataSource (in fact, more than one Connection) in the same class is extremely unusual.
  • permanent data source configurations have been defined by you in your application server configuration, they are not secret or hidden.
  • transient data source state, on the other hand, is accessible through application server tools and logs.
  • on the third hand, data source implementations are proprietary and need to be freely optimized; expecting them to provide useful information is unreasonable.
  • your application is unlikely to be able to fix a troublesome data source; if it could, it would be able to mess with other applications in the same application server.
  • "replacing" a data source with another doesn't make any sense.
  • any scenario in which you want the definition of data source to vary according to circumstances should be dealt with by other means, mostly close to the DBMS (for example, if DBMS processes or machines are subject to shutdowns and restarts you could configure the servers as a cluster sharing the same IP address; relatively easy with Oracle).

java - How to determine info about WebLogic datasource from datasource...

java spring weblogic datasource
Rectangle 27 0

you can try using TimerManager (Job Scheduler in a clustered environment) from WebLogic as TaskScheduler implementation (TimerManagerTaskScheduler). It should work in a clustered environment.

spring - Run @Scheduled task only on one WebLogic cluster node? - Stac...

spring weblogic scheduled-tasks cluster-computing
Rectangle 27 0

Take a closer look at the full stack trace. Spring stack traces are very verbose and can be difficult to interpret if you don't pay attention. In particular, you may get an exception saying that an injection failed when the root cause is in fact that the bean to be injected could not be created.

This will be specified in the stack trace, but a little bit further down. In this case, for instance, one possible cause could be that the data source cannot be created, e.g. if the JNDI name is incorrect.

Weblogic 10.3.6 Spring 3.2 @Autowired doesn't work - Stack Overflow

spring weblogic
Rectangle 27 0

I would guess that the problem is with the context root mapping.

Try to add a WebLogic specific deployment descriptor and add the context-root stance.

spring - EAR not working in Weblogic 10.3.6 - Stack Overflow

spring spring-mvc weblogic thymeleaf ear
Rectangle 27 0

It's much simpler to test and work with Apache's BasicDatasource from your IDE, since you only need the datasource jar file in your classpath. It's not necessary to deploy to an application container.

com.mchange.v2.c3p0.ComboPooledDataSource

The BasicDatasource and the ComboPooledDataSource also gives you the ability to use the same datasource in all environments and it's not coupled to the application container.

And at least the datasource that's bundled with the tcServer is supported by SpringSource.

The ComboPooledDataSource and the Spring alternative are also easy to manage and monitor with JMX.

On the other side, if you're using XA transactions and Weblogic's JTA transaction manager, then you should also use WebLogic's datasource.

java - BasicDataSource configured in spring vs Weblogic datasource - S...

java spring weblogic datasource
Rectangle 27 0

Take a closer look at the full stack trace. Spring stack traces are very verbose and can be difficult to interpret if you don't pay attention. In particular, you may get an exception saying that an injection failed when the root cause is in fact that the bean to be injected could not be created.

This will be specified in the stack trace, but a little bit further down. In this case, for instance, one possible cause could be that the data source cannot be created, e.g. if the JNDI name is incorrect.

Weblogic 10.3.6 Spring 3.2 @Autowired doesn't work - Stack Overflow

spring weblogic
Rectangle 27 0

I couldn't find an answer, and resorted to putting the necessary JAR file in the server's lib directory (user_projects/domains/{mydomain}/lib/*.jar). It seems to work, but it's a kludge of a fix. Couln't find anything better yet.

Edit: In this question, I posted a somewhat better kludge, involving setting PRE_CLASSPATH in the server startup script. Still a kludge, but the solution above broke something else on my system.

java - ClassNotFoundException deploying Spring context in exploded ear...

java spring java-ee weblogic
Rectangle 27 0

Two problems in your AcmeService.class.

1)You imported com.acme.data.AcmeDao but you are referencing com.acme.service.AcmeDao in the context.xml.

2)You are setting com.acme.service.AcmeDao reference in AcmeService bean definition in context.xml

If you want to reference com.acme.service.AcmeDao, change import to com.acme.service.AcmeDao. Then, remove @Autowired annotation as you are already referencing this in context.xml.

Thanks for the suggestion Prasad, but needed Autowired. Got it to work by adding @Repository in AcmeDao. Not sure why. Also, temporarily added constructor in AcmeService to debug and make sure the class was instantiated. I saw other posting suggesting to use <context:component-scan base-package=... but it turned out it wasn't necessary.

@westcoastmilt Since acmeDao is specified both in xml config and annotation, I said annotation is not required as xml config will take precedence.

Weblogic 10.3.6 Spring 3.2 @Autowired doesn't work - Stack Overflow

spring weblogic
Rectangle 27 0

HttpServletResponse#getStatus is only added in Servlet 3.0. The issue is caused by an older Servlet implementation supplied by your application server. Check the version of Weblogic then see whether it implements Servlet 3.

Update : According to the information provided, the version of Weblogic you are using is 10.3.6. Looking at this Servlet version support table, you should atleast use Weblogic 12c in order to work with Servlet 3.

There is no way to force a non Servlet 3 compliant app server to use Servlet 3. You have to remove your application code's dependencies to Servlet 3.

Mhh thanks, and where can I find this dependencies? Project settings? Some xml? On Java code (maybe because I used annotation?)?

Identify which class under which artifact is throwing the exception. Once identified, google for the version of the arifact that is designed to work on Servlet 2.5.

I added the entire stacktrace. If I call the webpage, It's correctly loaded (except the image). I get the error only when on the image I select from the browser "open in a new window".

spring - EAR not working in Weblogic 10.3.6 - Stack Overflow

spring spring-mvc weblogic thymeleaf ear
Rectangle 27 0

I couldn't find an answer, and resorted to putting the necessary JAR file in the server's lib directory (user_projects/domains/{mydomain}/lib/*.jar). It seems to work, but it's a kludge of a fix. Couln't find anything better yet.

Edit: In this question, I posted a somewhat better kludge, involving setting PRE_CLASSPATH in the server startup script. Still a kludge, but the solution above broke something else on my system.

java - ClassNotFoundException deploying Spring context in exploded ear...

java spring java-ee weblogic
Rectangle 27 0

Your logs show that you have Spring 2.0.3 on your classpath, you need to have atleast Spring 3.0.6 to work with Spring Security 3.1.x. So try cleaning your classpath or check if the jar is being included from other projects.

at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1114) ~[spring-2.0.3.jar:2.0.3]

Hi, Ravi. Thx for your response (and it was fast too). I've tried to fix the version in my pom file, unfortunately we already used spring-3.1.0.RELEASE and I see nothing about including spring 2.0.3 to our project. Should I include spring 3.1.0 manually to overwrite spring 2.0.3?

Oh, forgot to tell you that Yes, there is spring 2.0.3 in our dependency files, but I don't think it come from pom file since we don't include it.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

Deployment Failed Spring 3.1 on Weblogic Server 10.3.4 - Stack Overflo...

spring spring-security weblogic-10.x spring-3
Rectangle 27 0

JBoss and Glassfish are basically full Java EE Application Server whereas Tomcat is only a Servlet container. The main difference between JBoss, Glassfish but also WebSphere, WebLogic and so on respect to Tomcat but also Jetty, was in the functionality that an full app server offer. When you had a full stack Java EE app server you can benefit of all the implementation of the vendor of your choice, and you can benefit of EJB, JTA, CDI(JAVA EE 6+), JPA, JSF, JSP/Servlet of course and so on. With Tomcat on the other hands you can benefit only of JSP/Servlet. However to day with advanced Framework such as Spring and Guice, many of the main advantage of using an a full stack application server can be mitigate, and with the assumption of a one of this framework manly with Spring Ecosystem, you can benefit of many sub project that in the my work experience let me to left the use of a full stack app server in favour of lightweight app server like tomcat.

java - What is the difference between Tomcat, JBoss and Glassfish? - S...

java tomcat jboss glassfish enterprise
Rectangle 27 0

I assume it has something to do with the leading slash. Have you tried simply home/index.html instead of /home/index.html.

I tried home/index.html instead of /home/index.html. It did not work.

spring - welcome-file does not work in WebLogic - Stack Overflow

spring weblogic