What is an IoC container?
What is an IoC/DI framework?
Why do we need a framework for IoC/DI?
Is there any relationship between IoC/DI and AOP?
What is Spring.net/ninject with respect to IoC and AOP?
Is it possible to force java to make you catch RuntimeExceptions? Specifically I am working with the Spring framework and the whole Exception hierarchy is based upon RuntimeExceptions. A lot of the times I forget to try and catch the Exceptions. A specific example is when doing an LDAP query, or an SQL call.
I was reading an InfoQ article on Composite Oriented Programming earlier on:
http://www.infoq.com/articles/Composite-Programming-Qi4j
I was interested in finding out whether anybody is currently using (or has used) the Qi4j framework at all?
How does it compares to using a traditional dependency injection framework such as Spring for wiring classes together. Is the resulting object graph (based on mixins rather than classes) easier to deal with from a maintenance point of view?
I am creating a Spring based JSF application, where I am getting FacesContext.getCurrentInstance which returns null.
Here is my Java code
public static ServletContext getServletContext()
{
return (ServletContext) FacesContext.getCurrentInstance()
.getExternalContext().getContext();
}
This is the stack trace of my error
SEVERE: Exception sending context initialized event to listener instance of class
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbSettingsServiceTarget' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.baytalkitec.smartcall.service.impl.DbSettingsServiceImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.baytalkitec.smartcall.service.impl.DbSettingsServiceImpl]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 31 more
Caused by: java.lang.NullPointerException
at com.smartcall.util.FacesUtil.getServletContext(FacesUtil.java:21)
at com.smartcall.util.SpringApplicationContextUtil.init(SpringApplicationContextUtil.java:21)
at com.smartcall.util.SpringApplicationContextUtil.<init>(SpringApplicationContextUtil.java:16)
at com.smartcall.service.impl.DbSettingsServiceImpl.init(DbSettingsServiceImpl.java:17)
at com.smartcall.service.impl.DbSettingsServiceImpl.<init>(DbSettingsServiceImpl.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
... 33 more
and hence due to this error Server console in Eclipse reports that application failed to startup due to previous errors
My web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>smartcall2.0</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-bean.xml,/WEB-INF/faces-navigation.xml
</param-value>
</context-param>
<listener>
<listener-class>
com.sun.faces.config.ConfigureListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>180</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
I am not clear whether this error belongs to Spring or JSF or Eclipse.
I am using Eclipse Galileo, JSF 1.2,Spring 3
Please help
Thanks in advance
AppContext.xml
<bean id="myBean" class="com.myapp.MyClass">
<property ref="myService"/>
</bean>
MyService.java
@Service
public class MyService {
...
}
This will throw an exception stating that no bean can be found for property "myService", which I understand because it can't be found in the context files, but I can autowire that field in other spring managed beans, but I need to explicitly build the bean in my context because the POJO is not editable in the scope of my project.
I have a table with 11 columns, but I need to get only 2 of them in my application, I'm using spring/hibernate/DAO combination. For now I have a domain class which includes all 11 fields, and mapping file which maps all 11 columns in table. How do I use get just 2 of them not all?
Hi all,
In my code I am updating two table, one after the other.
update(table1_details);
update(table2_details);
So if the update fails in table1 , table2 should not be updated or should be rolled back.
How to handle this situation. I know I have to use transaction. Can some one help with code !!!
I am using Java with spring and hibernate .
Hello,
I have a test class that has a @Resource annotation for a setter and I need to make it Java 1.4 compliant, so obviously the annotation has to go. I'm using Spring.
So, how would I replace something like @Resource("my.resource") so that the setter gets the correct dependency injection? Would I need to make a bean in an xml file?
I'm pretty new to this so if I'm not providing enough information, let me know.
Can you rely on this scope and be sure that every time
1) a new session starts, the Spring bean will be initialized with default values
2) while session is kept alive, the current object will store its state during session life, will never be lost or corrupted and can always be got with [webappcontext].getBean ?
Has anyone used Php frameworks just like we have in Python(Django) and Java(Spring).
I want to use something which has end to end solutions. ORM tools, transaction mangement, logging etc.
I am not sure how Cake is?
But, I am looking something very similar to Django in Php.
i'm using spring+tapestry for authenticate webuser. I wonder is there any technique i can force all users that currently login in to logout let say i'm on scenario where the site is 'under maintenance mode'
Hi, i looking for guide/document/tutorial on how to use this new feature write-behind-cache in ehcache? Is there any demo in spring+jpa+ehcache+hibernate?
just to clariyfing, write-behind-cache mean each time we persist entity, it will be written into cache rather than into database correct?
I'm using Acegi/Spring Security in grails and when i use the annotations like @Secured(['ROLE_ADMIN']) it denies my login even though the user is part of ROLE_ADMIN.
In looking through the login is it seems that it's getting an IS_AUTHENTICATED_FULLY role also but I have never added that to a page so i'm not sure how to bypass that. I read somewhere to preauthorize the user, but i'm not sure how to do that with grails.
I have been updating all my services to be transactional by using Grail's ability to rollback when a RuntimeException is thrown in the service. I have, in most cases, doing this:
def domain = new Domain(field: field)
if (!domain.save()) {
throw new RuntimeException()
}
Anyways, I wanted to verify that this indeed will rollback the transaction... it got me thinking as to whether at this point it's already been committed.. Also, if not, would setting flush:true change that? I am not very familiar with how Spring/Hibernate does all of this :)
Hi there.
I need to pass the user name and password in the URL for a REST web services call.
I know that if I pass it this way in Firefox, it works:
https://{UserName}:{Password}@api.opsourcecloud.net/oec/0.9/myaccount
Is there a proper way to pass user name and password aside from the above example?
It's a Spring Security Context?
Hello,
I want a framework (or anything) that helps me make rich client guis. I know my server-side, but I don't like programming in ajax, javascript, css etc.
Something that wraps the ajax code in some objects/methods with clean syntax, would do the trick. I want to write code in java instead of defining css and html tags.
Does Java Spring, JSF, Django support this ?
Languages: Java, Python
Thank you
I'm using the Tapestry5 tapx template library to send an html email, as per this example.
When I run the example I get the following error:
Caused by: java.lang.RuntimeException: No service implements the interface org.springframework.context.ApplicationContext.
at org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:560)
at org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:44)
All the tapestry-* jars, including tapestry-spring-5.1.05.jar are in my classpath.
Any clues as to what I'm missing?
I need to create an aspect with a pointcut matching a method if:
- Is public
- Its class is annotated with @Controller
- One of its parameters (can have many) is annotated with @MyParamAnnotation.
I think the first two conditions are easy, but I don't know if its possible to accomplish the third with Spring. If it is not, maybe I can change it into:
- One of its parameters is an instance of type com.me.MyType (or implements some interface)
Do you think it's possible to achieve this? And will performance be good?
Thanks
What is the best way to manage user authentication/sessions in a web app, ideally in a clustered environment, using Spring Framework/MVC?
I thought of creating a login bean that creates a jsession for authenticated users and then using AOP to check for the jsession before each controller method inovcation.
If there isn't a better way, what are some possible alternatives? Thanks.
I'm trying to wrap my head around Dependency Injection.
One of the things I'm confused about is whether all of your object instantiation needs to be controlled by the DI framework (Spring, Guice, etc).
Or, if not, how do you determine which objects are instantiated by the framework and which objects are instantiated with the new operator?
In the setup of my test cases, I have this code:
ApplicationContext context = new ClassPathXmlApplicationContext(
"spring/common.xml"
);
StaticListableBeanFactory testBeanFactory = new StaticListableBeanFactory();
How do I connect the two in such a way that tests can register beans in the testBeanFactory during setup and the rest of the application uses them instead of the ones defined in common.xml?
Note: I need to mix a static (common.xml) and a dynamic configuration. I can't use XML for the latter because that would mean to write 1000 XML files.
I posted a question a few days ago mentionning Spring's OpenEntityManagerInViewFilter:
http://stackoverflow.com/questions/2385858/uirepeat-inside-a-uirepeat-and-lazyinitexception
An obvious thing that should have been asked and now comes to mind is how to test for the presence of an EntityManager in a JSF project. What is a good way of doing this?
I want to learn how to create distributed application environments and web services using spring, aspectj, hibernate, etc. rather than EJBs.
Can anyone recommend a book or set of books that can help me (a single all-in-one book would be preferable)?
Also, any advice regarding learning/creating distributed app environments and web services is appreciated.
let say i want my corporate server to communicate with google app engine vise verse. I know that gae do not support JMS,RMI etc. what is the best alternative for this kind of communication?(i think http get is not suitable for this kind of communicate) use task queue? both my corporate server and gae application using spring framework