spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » SPRING » Page 1
Display data from related entities to avoid the lazy initialization exception with setting up @BatchSize
The quickest and easiest solution would be to fetch the data after you execute the main query. Try something like this page.content = query.offset(pageNumber*pageSize).limit(pageSize).list(ao); for (Content cont : page.content) { Hibernate.initialize(cont.getEntities_4()); }

Categories : Spring

spring boot mvc: failed after following the sample
The following java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/UserDataHelper means that you're lacking a tomcat-july.jar. The following, however, Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) means that you have a corrupted dependency. My bet would be that the embedded tomcat dependencies did not got downloaded properly. If I were you, I would back-u

Categories : Spring

Apache Camel iterate over List
you are right with splitter and aggregator, the "Split aggregate request/reply sample" from http://camel.apache.org/splitter.html shows what you need. Do you need a "converted" list of objects after the splitter? If yes, the point "Using a List in AggregationStrategy" from http://camel.apache.org/aggregator2.html looks right for your needs. kind regards, soilworker

Categories : Spring

Can I move entire web.xml to spring code base configuration? (WebApplicationInitializer)
Generally, yes, you should be able to get Java Config equivalents of all elements that you can set in the web.xml. In terms of converting individual elements, if you can give specifics, then we could find the JavaConfig equivalents. Note that it's not always a 1-to-1 mapping. For example, with Spring Security, you have to define the "delegatingFilterProxy" filter in web.xml but the JavaConfig equ

Categories : Spring

Autowired Object is coming out null for a web project
I am pretty new to spring but generally find that when I have null pointers for Autowired properties it is because the component scan is failing. Perhaps have a look at this question Spring Boot MVC and check if anything helps? One I always forget about is @EnableAutoConfiguration.

Categories : Spring

@Autowired on setter function does not look at the property name (like autowired in XML does)
When @Autowired is used on a setter and there are multiple matching types, the container will look at the parameter name to find the bean to inject. In your case, the parameter is My my, so the my bean will be injected. You can change the parameter to My my2, or use @Qualifier("my2") to inject the my2 bean. If you want to use the field name, place @Autowired on the field itself to use field-injec

Categories : Spring

Cannot inject beans in servlet context to Controller
(This post was once deleted because I found the solution myself. However I think it isgood to post my answer here for reference, as seems that I am not the only one faced similar problem) My understandings in the relationship between app contexts and beans, are in fact correct: There is a root context Dispatcher servlet context is a child context under the root context Controllers and Jaxb2Mar

Categories : Spring

Serving outside web-app static files using spring MVC
You are able to serve file that reside outside of the webapp root. In fact, you do it just as you guessed in your comment: so <mvc:resources mapping="/mydocs/**" location="file:/opt/mydocs/css/" /> in SpringMVC the prefix inside the location instructs the lookup strategy, and there are four types classpath: - resources loaded from the classpath. file: - resources loaded as a URL, from

Categories : Spring

jsf: Calling a method in managedbean giving exception
You cannot inject a Spring bean by using @Autowired inside JSF managed bean. You should change to @ManagedProperty(value="#{something}") private LoginService loginServiceImpl; // getter and setter. See also: Null pointer when autowiring the bean into JSF Managed bean

Categories : Spring

How to have a SAML request/response signed using Spring Security SAML extension
HTTP-Redirect binding requires that any ds:Signature element present on the SAML message itself is removed before sending of the message: Any signature on the SAML protocol message, including the XML element itself, MUST be removed. Note that if the content of the message includes another signature, such as a signed SAML assertion, this embedded signature is not removed. However, the le

Categories : Spring

Autowiring issues with a class in Spring data Mongo repository
Try removing the @Repository annotation? Worked for me. This was an issue in Github as well.

Categories : Spring

Internal Exception: java.sql.SQLNonTransientConnectionException: Could not send query: Software caused connection abort: socket write error
I resolved this issue by increasing the values set to server system variables below: max_allowed_packet = 500M net_read_timeout=900 net_write_timeout=900 connect_timeout=900 Out of the above the main culprit was the first one which is "max_allowed_packet". For more details please refer https://mariadb.com/kb/en/mariadb/documentation/optimization-and-tuning/system-variables/server-system-varia

Categories : Spring

How to save spring integration message header into database
To be honest, there is no such a solution, because with RDBMS we have schema bottleneck. Even if we could do something like this: insert into headers value (:headers) We have to specify any new column in the target DB table. That's why any NOSQL DB is better for that case. E.g. MongoDb can simply accepts whole Message and stores it to the Document with all headers. Even if we can Spring Integ

Categories : Spring

serving files from a spring boot war file
Files in src/main/resources/static are served from / so you don't need static in the path. You CSS file should be available from http://localhost:8080/css/main.css

Categories : Spring

Spring Data + QueryDSL empty predicate + Predicate chaining
You can return null for non matching predicates in byWhateverId and bySomethingElseId and combine the predicate via ExpressionUtils.allOf() In your case Predicate where = ExpressionUtils.allOf(byWhateverId(someParam), bySomethingElseId(1)); someRepository.findAll(where);

Categories : Spring

thymeleaf spring standard dialect: using template
So if i understand correctly, you want to inject that fragment which is called pageContent into some other html page (lets call it main.html for sake of it. First thing to do is change the div in list to the following: <div th:fragment="pageContent"> <p>LIST</p> </div> then in your main.html you would call the fragment via: <div th:include="list::pageContent"&

Categories : Spring

spring-tool: the package of 3.6.2 is not useful on linux
I was able to download and unzip that file with no problem. This is the URL I used to download the file: http://download.springsource.com/release/STS/3.6.2/dist/e4.4/spring-tool-suite-3.6.2.RELEASE-e4.4.1-linux-gtk-x86_64.tar.gz The md5 hash for my file is: $ md5sum spring-tool-suite-3.6.2.RELEASE-e4.4.1-linux-gtk-x86_64.tar.gz d2ee324ab22bdafef934276967a0dbf8 spring-tool-suite-3.6.2.RELEASE-e4

Categories : Spring

Disable SSLv3 using Spring-Boot and embedded Tomcat
If your goal is to disable SSLv3, the easiest option is to use Tomcat 7.0.57 which disables it by default. Assuming you're using Maven, all you need to do is set the tomcat.version property to 7.0.57 in your pom. The forthcoming Spring Boot 1.1.10 release uses 7.0.57 by default so, once it's been released, you'll no longer need to set the Tomcat version.

Categories : Spring

The annotation @EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?
It looks like configuration classes that extend WebMvcConfigurationSupport directly suffer from SPR-10565. The solution, at least for me, is to extend from DelegatingWebMvcConfiguration instead. If you're overriding individual callbacks in your configuration class you'll likely want to call the superclass' implementation of the callback as well to ensure it's all handled correctly.

Categories : Spring

Gradle ivy service MetaDataParseException
Not sure what does it have to do with ivy. The problem is that one of the dependencies, namely: org.socialsignin:spring-data-dynamodb:1.0.1-SNAPSHOT depends transitively (via org.hibernate:hibernate-validator:4.2.0.Final) on javax.validation:validation-api:1.1.0.FINAL which is incorrectly specified, should be (which is visible in output log): javax.validation:validation-api:1.1.0.Final (tak

Categories : Spring

mocking a method with parameter as LIST type
At the Class level, all List interfaces are the same regardless of the generic type, due to type erasure; they are only different at compile time. So it's just List.class in place of ??. That is, Easymock.expect(MockClassObject.ToBeMocked(Cinput.class, Coutput.class, List.class)). andReturn(true); In the scope of mocking, you should really be specifying the objects that you expect to be pa

Categories : Spring

Can I use spring thymeleaf with layoutdialect?
Adding the layoutdialect to the templateengine should be enough to get it working. Don't use setDialect. You should have an addDialect or setAdditionalDialects method or something like that. (I use the xml config so i don't know the exact names) UPDATE: added xml config <beans:bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine"> <beans:property name="template

Categories : Spring

Playframework2 like reverse routing in spring
This is the general flow in spring framework. Whenever user makes a request, it will first go to Spring's DispatcherServlet. The DispatcherServlet job is to send the request to spring mvc controller (custom controller) You can define your custom controller like this: Controller: (code snippet) package nl.springexamples.mvc; import org.springframework.stereotype.Controller; import org.spr

Categories : Spring

How can i send a parameter in a spring webflow event?
in this case, all you need is to add a hidden input with requestParam name and set its value to the current row's id. like this : <input type="hidden" id="dbId" name="dbId" th:value="${databaseIterator.id}"/>

Categories : Spring

Deploying spring boot to elasticbeanstalk and setting system properties
Have a look at how we set the properties for deploying on Heroku, it probably works the same: https://github.com/jhipster/generator-jhipster/blob/master/heroku/templates/Procfile BTW, I would love to have also a Beanstalk sub-generator, so if you succeed can you share it? You could add a ticket explaining what you did at https://github.com/jhipster/generator-jhipster/issues

Categories : Spring

Jackson and unmarshalling Spring HATEOAS references
In this situation, I like to use a separate DTO that's passed into my controller methods, rather than trying to reuse the JPA entity. In this scenario I'd create a ProductInput class with three properties: class ProductInput { private String description; private String price; private URI vatRate; } The vatRate property is a URI as it's referencing an existing VAT rate resource and,

Categories : Spring

problems with Native AspectJ with Spring
Your Gradle build uses the Java compiler to build the project. How about actually using the AspectJ compiler? That would help a lot if you want to use AspectJ. ;-) You can use the Gradle AspectJ plugin.

Categories : Spring

Split the query results into more jsp pages
You could use the Query String, resp. the query parameters to specify, which resultpage you want to display: http://www.example.com/users?page=1 Where page is the so called query parameter. Query parameters are appended to a URL via ? for the first one and & for each consecutive: http://www.example.com/users?firstName=John&lastName=Doe&page=1 The advantage of this technique: you

Categories : Spring

Jms connection is timing out in spring batch remote partitoning on the master side
Either the network or your broker is timing out the connection. Consult your broker documentation to enable some kind of heartbeats/timeouts to keep the connection open. Or, it would be better to reduce your partition sizes (increase the number of partitions) so they complete in a reasonable time. EDIT: Also, configure the outbound gateway with a <reply-listener/> and use a fixed, named

Categories : Spring

Spring Security don't allow resouce
It's normal. Spring tries patterns in sequence and stops at the first that matches. As your first pattern is /** it catches all and next patterns are not even analyzed. You should always put the catchall as last pattern : http.csrf().disable(); http.authorizeRequests() .antMatchers("/shutdown").permitAll() .antMatchers("/**").authenticated()

Categories : Spring

Spring Batch - late binding of commit interval not working with skip policy
It's a known bug of spring-batch from the class org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean : https://jira.spring.io/browse/BATCH-2096. It has been corrected in version 2.2.2. So the best solution is to upgrade to v2.2.2 of spring-batch (which is the same as 2.2.0 with some bug corrections). If -like me- you really can't upgrade, then the best way is to copy the c

Categories : Spring

Spring MVC Interceptor does not execute for resource handler URLs
I think the configured interceptors aren't mappped on the resource handler, but on the one handling @RequestMapping requests. Maybe try this instead? @EnableWebMvc //equivalent to mvc:annotation-driven @Configuration @PropertySource("classpath:configuration.properties") public class WebConfig extends WebMvcConfigurerAdapter { @Inject private TimingInterceptor timingInterceptor; @

Categories : Spring

Spring Boot NoUniqueBeanDefinitionException
There were some issues with autowiring the beans with generics in 4.0.2 version. I found the following jira ticket. It is not the same problem that you have but it indicate that there were some issues: https://jira.spring.io/browse/SPR-11529. That problem was fixed in 4.0.3. I've tried to reproduce the problem on my side and spring resolved and injected 'right' manager (I have two managers implem

Categories : Spring

pass job parameters to custom writer Spring batch
You have to declare the bean with either step scope or job scope so you can have late binding of a property based on the job parameter: <bean id="personWriter" class="com.dev.writer.PersonItemWriter" scope="step"> <property name="resource" value="#{jobParameters[outputFileName]}" /> </bean> These scopes are not available by default, you need to include them either by eithe

Categories : Spring

Make Spring-Security oauth services transactional
What I did was add a aspect directly on DefaultTokenServices to give it the transactional behavior, and thus each call to methods of this class are transactional. <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*, is*, read*" read-only="true"/> <tx:method name="*"/> </tx:attributes>

Categories : Spring

Spring Web service unmarshalling not happening correctly
Answering my own question after getting frustrated for hours.There seems to be problem with the namespaces in wsdl.I changed following 2things in wsdl and generated the classes again resulting in proper responses. xmlns:tns1="http://fs.uk.com" to xmlns:tns1="http://service.fs.uk.com" targetNamespace="http://fs.uk.com" to targetNamespace="http://service.fs.uk.com" for element FSChild. It was lit

Categories : Spring

Spring MVC Data Binding: bind parameter to an object field with different name
You can use @JsonProperty Annotation for it.Like below. class Member { @JsonProperty("memberId") private Integer id; private String username; // ... ... }

Categories : Spring

GET request from a jsp to controller and send a string value with action
Try this <c:forEach items="${listobj.empDetails}" var="empValue"> <a href="${contextPath}/empInfo?name=${empValue.Name}">Emp Details </a> </c:forEach> There is no needs to use <%= %> you can not access ${empValue.Name} out side <c:forEach> as ${empValue.Name} is local to your <c:forEach> loop

Categories : Spring

Model View Controller (MVC) info
Depends what you mean by calling. But yes, View doesn't know anything about the controllers. It sends HttpRequests, and than the mechanism doing what you describe kicks in. There's the famous schema from spring docs, basically your bullets described via diagram. The point with respect to your question is that the view doesn't call the controller rather sends the request

Categories : Spring


Recently Add
How do I make Grails execute shell commands just before creating war file?
Display data from related entities to avoid the lazy initialization exception with setting up @BatchSize
spring boot mvc: failed after following the sample
Apache Camel iterate over List
Can I move entire web.xml to spring code base configuration? (WebApplicationInitializer)
Autowired Object is coming out null for a web project
@Autowired on setter function does not look at the property name (like autowired in XML does)
Cannot inject beans in servlet context to Controller
Serving outside web-app static files using spring MVC
jsf: Calling a method in managedbean giving exception
How to have a SAML request/response signed using Spring Security SAML extension
Autowiring issues with a class in Spring data Mongo repository
Internal Exception: java.sql.SQLNonTransientConnectionException: Could not send query: Software caused connection abort: socket write error
How to save spring integration message header into database
serving files from a spring boot war file
Spring Data + QueryDSL empty predicate + Predicate chaining
thymeleaf spring standard dialect: using template
spring-tool: the package of 3.6.2 is not useful on linux
Disable SSLv3 using Spring-Boot and embedded Tomcat
The annotation @EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?
Gradle ivy service MetaDataParseException
mocking a method with parameter as LIST type
Can I use spring thymeleaf with layoutdialect?
Playframework2 like reverse routing in spring
How can i send a parameter in a spring webflow event?
Deploying spring boot to elasticbeanstalk and setting system properties
Jackson and unmarshalling Spring HATEOAS references
problems with Native AspectJ with Spring
Split the query results into more jsp pages
Jms connection is timing out in spring batch remote partitoning on the master side
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.