spring

Injecting fields via Spring into entities loaded by Hibernate

I am looking for a way to inject certain properties via Spring in a bean that is loaded from the DB by Hibernate. E.g. class Student { int id; //loaded from DB String name; //loaded from DB int injectedProperty; //Inject via Spring } Can I configure Spring so that whenever Hibernate creates objects of class Student, some pro...

CXF server-side logging to a table

In CXF, you can enable logging using this: <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> Source: http://cxf.apache.org/docs/configuration.html Everything seems to go to files or console and can be configured using Log4j as well it seems. My question is, how do you enable logging on server side so th...

mvc call service layer method

i have a method inside service layer that is called by view layer to save content. the model is annotated with @Version JPA so support concurrent-update. but during web application peak-usage, sometime, i will get 17 Aug 2010 16:30:26,477 ERROR [http-2020-23] - Could not synchronize database state with session org.hibernate.StaleObjec...

Spring @Transactional wrapping 2 methods

Hello I'm a Spring newby. I use the @Transactional annotation for my dao methods: @Transactional public Person getById(long id) { return new Person(jdbcTemplate.queryForMap(...)); } @Transactional public void save(Person person) { jdbcTemplate.update(...); } and I've set up the transaction manager like this: <tx:annotation-...

How can I measure the number of times and response time of a method called in a Spring Bean

I would like to measure the number of times a method is called on a service provisioned by Spring. In EJB land this information is usually provided by the container. Now since spring is conceived when "Anything you can do, I can do better" was playing on the radio, I expect there to be a nice and elegant component hidden somewhere whi...

Spring and Hibernate: can't delete entry

Hi everyone, I stuck with entry deleting an entry from DB. I have Hibenrnate integrated with spring. RDMS is HyperSql and application server is Tomcat 6. For dependency management I use maven and for development I use Eclipse with maven plug-in. Hibernate is in version: 3.3.2.GA Spring is in version: 3.0.3.RELEASE HyperSql is in ver...

Is it possible to use multiple @Qualifier annotation in Spring?

I have a set of beans that are characterized by two properties. They are basically serializers for different classes and for different purposes. For example, there may be an Order serializer for local log, Order serializer for logging webservice call, Customer serializer for tracking URL and Customer serializer for tracking URL. This ...

Embedding ActiveMQ broker in Spring-MVC Tomcat webapp

I have a small Spring MVC webapp (which embeds ActiveMQ) that is designed to run in a local Tomcat, and reliably message to a queue on a remote ActiveMQ. All of that's in place, except for the "reliably". At the moment, if the remote site goes down, the send fails dramatically. My send config: <!-- Connection setup --> <bean id="connec...

hibernate circular foreign key

I have to test some code I have not myself written. It is an integration test: the application is running continuously on a server and my tests run against it. The tests are Selenium tests, they launch a browser, execute some JavaScript inside it to simulate user actions and checks if the database is correctly updated. I have to restore...

Need solution to webapp errors from Tomcat trying to log events after logger has been disposed

Enviroment: JSF 2.0, RichFaces 3.3.3, Facelets 1.1.15B1, Spring Framework 3.x, WebFlow 2.1, MyBatis 3.0.1, Oracle 10/11 g backend, SLF4j into Log4j. Well thats probably TMI since my issue is only a logging problem but better to be too thorough than not. Anyways... I just setup SLF4j & log4j so now all of the internal facelets log msgs ...

Creating a Spring bean holds ServletRequest properties

I need to create a Spring bean so that it stores serverName, serverPort, contextPath properties of a HttpServletRequest object so that I can inject this bean to other beans as I need. In my opinion, those properties do not change with any URI so that it is good to initialize this once (anyway, passing request instance many times is not...

eXtreme Design-by-Contract with Java, other than XINS?

Are there any technical Design-by-Contract solutions for Java projects similar to XINS? I'm looking for projects/frameworks that enforce developers to first author a contract for their application and then code within the boundaries of that contract, really using the contract to the full potential. I'm looking for something that, like XI...

Using Beans to populate/Reterive view

Hello All, I'm new to Spring and little confused of how to use beans for populating and retrieving values to/from the view. Here is what I'm doing now. In the controller I'm initializing two beans xxxMain.java and xxxView.java. I'm using xxxMain.java to retrieve values FROM the view and xxxView.java for pre-populating the view. Here ...

Is POJO Servlet ever considered?

POJO is the norm in Spring but also pervasive in JEE world. One non-POJO stronghold is Servlet. i'm wonderring if any open source ever appeals to change. POJO examples: class MyHttpServlet { @Inject void doGet (@HttpServletRequest Request request, @HttpServletResponse Response response) {..} } class MyOtherServlet { @Inje...

RESTful URLs with Spring 3

How do I get nice-looking URLs in Spring (without a UrlRewriteFilter)? Does Spring 3 have any convenient way of getting nice-looking URLs (like, annotations, or something)? For example: /springmvc/hello instead of /springmvc/hello_world.html. ...

Forcing ResourceBundleViewResolver to load view.properties file from specific location

Hi all. Is there a way to set a specific location where the ResourceBundleViewResolver should look for the view.properties files? By specific location I mean somewhere not inside the classpath but anywhere in the file system / network resource. Thanks in advance. ...

How do i write Junit4 tests without Spring transactional test support?

I would like to test transaction rollbacks in my application service. As a result i do not want to use spring's AbstractTransactionalJUnit4SpringContextTests with the @Transactional annotation as that wraps my test method in a transaction. I know spring also offers AbstractJUnit4SpringContextTests for tests without transactions. Howeve...

How do you publish a JMS topic with Spring JMS?

Hello, I have a component that sends messages to a queue to be handled by another system. It should also publish a topic about job statuses every once in a while. Can I just use the same JmsTemplate used to send to a queue AND to publish to a topic? I created a new topic in ActiveMQ, except that when I send from JmsTemplate a message,...

Cant get Junit to work with Spring in an ANT build

I am trying to get Spring MVC and Junit working with eachother and I am having trouble configuring the build.xml file. I am fairly new at using ANT and do not really understand all the tutorials. I put the junit.jar file in the lib direcotory, but still am getting the following message from my console. test: BUILD FAILED C:\Java\mmz\WE...

Spring project segmentation, best practices?

Im a spring newby (been baby sitting an ERP tool for the past 5 years). Anyway, I've got a few of the sample apps (petstore/etc) running, got spring security basics figured out, and am ready to start a new project. My question is, are there any best practices for "breaking apart" the site into different webapps. For example, the proje...