Win a copy of Spring Boot in Practice this week in the Spring forum!

Rob Ivan

Greenhorn
+ Follow
since Jan 07, 2010
Rob likes ...
Hibernate Spring Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rob Ivan

For the authors of "The Java Performance Companion":
Thank you for participating in the forum and best wishes on the success of your book.

What are some of performance differences and trade-offs between the four types of Java Garbage Collectors?
6 years ago
Welcome. We're glad you are here.
9 years ago
Thank you, Chris.
9 years ago
Hi, Nilanjan Raychaudhuri.

I attended DevNexus last week, and a number of the presentations that talked to concurrent (i.e., thread safe) programming used Scala for their code demos and slides. Can you provide a high-level summary of the Scala language features that simplify concurrent programming over conventional Java?

Thank you.
9 years ago
Thank you for the responses. I already had the second solution in place (Spring managed Singleton), and it got refactored. I was looking for some "independent validation" that it was not very Spring-like to inject into a class with static utilities.
9 years ago
Hi, J and Ashish.

A colleague of mine was trying to use @Inject to inject a runtime String value (the name of the host where the application is running) into a class that had no constructor and only contains static utility methods. The value came up empty, of course. That started a discussion about how one could annotate this class (such as @Component) in order to ensure that Spring instantiated it, or if it should be added to the application context. But that begs the question, why would you want to do that?

So, the question for you guys is: are there any situations you have found where it made sense to have the Spring application context manage a bean that provided only static methods?

Thank you.
9 years ago
Thanks for that response, Ken. I am eager the see what you have put together on this topic and will keep an eye out for your future post.
10 years ago
Hi, Srini.

Thank you for responding. I was working on a web UI navigation based workflow like Spring WebFlow framework. I wanted to walk a UI user through a specific set of steps to build up an advertisement or flyer that they could then print out.
10 years ago
I used an early version of Roo and found that it was not very flexible with regards to creating a workflow application. Roo seemed biased towards giving access to all fields of all objects and creation order was not crucial or even controllable. Does the latest version of Roo provide any features that are geared towards creating workflows?
10 years ago
Hi, Craig. Thank you for answering some questions here.

My question is, when is it recommended to perform dependency injection using Autowire, and are there any specific situations where autowiring is not recommended?
11 years ago
Issue: Application running Apache CXF webservices handles response.sendError() differently when running in Jetty 6.1.21 than in Tomcat 6.0.29 or SpringSource tc Runtime 2.1.0.RELEASE, where as the Jetty response has a status code of HTTP 403 Forbidden and Tomcat has a status code of HTTP 500 Internal Server Error. My client is GWT, and I am trying to detect the HTTP 403 status, which works with the server application running on Jetty but not on Tomcat or SpringSource tc.

Questions: Is this a configuration issue for Tomcat? Do I need to write my own ErrorReportValve implementation?

I have searched various forums (here, and via Google search) for a solution, to no avail. I have tried setting " errorReportValveClass = "" in Tomcat server.xml, and I still get HTTP 500 but with a blank page. I have also tried various settings for cfx.xml to propogate the response status, but that did not work either. I know these are not "Tomcat" changes per se, but I did not want to cross post and Tomcat forum seemed to be the right place to start.

Note: responses captured using Chrome Poster 1.4 running on Google Chrome 8.0.552.224

My application (Spring 3) is generating the following in a Spring Security Filter Bean (extends org.springframework.web.filter.GenericFilterBean):

response.sendError(403, "System Lockout");
throw new WebApplicationException();

Additional configuration details:

web.xml
-------
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/secure/*</url-pattern>
</servlet-mapping>

<!-- The following two tags configure Spring security. -->
<filter>
<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>
</filter-mapping>

applicationContext-resource.xml
-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<jaxrs:server id="user" address="/">
<jaxrs:serviceBeans>
<ref bean="userResource" />
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
</jaxrs:server>

</beans>



Jetty 6.1.21 Response:

status: 403 System Lockout
Content-Length: 1393
Server: Jetty(6.1.21)
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 403 System Lockout</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /agency/secure/user. Reason:
<pre> System Lockout</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>;
</body>
</html>

SpringSource tc Runtime 2.1.0.RELEASE Response (please note that this is about the same response I get from Tomcat, except for the error page--it is still seen as HTTP 500 instead of HTTP 403):

status: 500 Internal Server Error
Date: Fri, 31 Dec 2010 15:48:36 GMT
Content-Encoding: gzip
Connection: close
Content-Length: 793
Vary: Accept-Encoding
Content-Type: text/html;charset=utf-8

<html><head><title>SpringSource tc Runtime 2.1.0.RELEASE/6.0.29.B.RELEASE - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.ws.rs.WebApplicationException
net.dds.commons.security.PidCidAuthenticationFilter.doFilter(PidCidAuthenticationFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the SpringSource tc Runtime 2.1.0.RELEASE/6.0.29.B.RELEASE logs.</u></p><HR size="1" noshade="noshade"><h3>SpringSource tc Runtime 2.1.0.RELEASE/6.0.29.B.RELEASE</h3></body></html>
11 years ago
Thank you, Bill. I look forward to reading your book.
Are the SQL antipatterns to be avoided mostly for performance reasons, or are there other considerations (e.g., inaccurate results)?
Hi, Srinivas Guruzu.

Does the Hibernate Recipes book go into much detail on debugging methods and approaches? I am using a combination of Spring component scanning and JPA/Hibernate annotations to generate my Hibernate classes at run-time. Even though I am able to capture all HQL statements in a console, I miss the ability to review the Hibernate generated mappings XML documents. Is there a way to view the generated Hibernate mappings when using this auto-wire approach?
What about wan princes--can't leave them out!