Mybatis #Autowired Mapper not injectes Mapper interface and throws NPE - interface

I am trying to inject Mybatis Interface from Child project parent in Maven structure.But Mapper is not injected properly and it throws NullPointerException .Please help me why Mybatis interface mapper not injected properly?

Related

JPA #Inheritance strategy failure after domain deported to a JAR

I had to change a JPA Inheritance strategy from SINGLE_TABLE to JOINED after moving my entities to an Maven module, in order for them to used from different applications.
The junit tests were OK when launched within Eclipse (Spring Boot, Spring Data JPA) but failed at Maven build (Mapping Exception).
#Entity
//#Inheritance(strategy = TABLE_PER_CLASS)
//#DiscriminatorColumn(name = "privilege_datarealm_type")
#Inheritance(strategy = JOINED)
public abstract class PrivilegeDataRealm<E extends SchemaElement>
extends Privilege<PrivilegeDataRealm<E>>
implements SchemaElement {
Does anyone have any clue of explanations for this issue ?

Activator.getDefault().getLog() nullpointer exception

In my Plugin, I have a Util class which using eclipse default log, like below
private static ILog log = Activator.getDefault().getLog();
It works during plugin in runtime. But when i try to test this Util class at java application ,it got Nullpointer Exception at Activator.getfault().getLog() , how to solve this problem?

STS reports error in bean config for java.sql.Date property

I have a bean class with a property setter like this:
public void setDueDate(java.sql.Date dueDate)
I also have an instance of this bean configured in XML like this:
<property name="dueDate">
<bean class="java.sql.Date"/>
</property>
STS marks that config with an error:
No constructor with 0 arguments defined in class 'java.sql.Date'
Well, that's true, java.sql.Date has no no-arg constructor. But this app works fine so obviously Spring is smart enough to create a Date instance without a constructor. Question is, why is the STS editor/builder complaining, and is it possible to convince it that this is not an error or warning?
At this time, I can only see 3 situations where the code "would work", in the order of their likeliness to happen:
the parent bean where the property is injected is defined with scope="prototype" or lazy-init="true" and is not accessed at all
the runtime classpath contains an implementation of java.sql.Dateshadowing the original
that particular context xml is not used in the application
Otherwise, Spring should issue a nice:
Could not instantiate bean class [java.sql.Date]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.sql.Date.<init>()
In case the code works, but STS reports an wrong error, please file a bug against STS at https://issuetracker.springsource.com/browse/STS (as mentioned above).
In the meantime you can workaround this issue by disabling the validation via the Spring preferences for the project. Just go to preferences of the project -> Spring, then the "Project Validators" tab, and deactivate the validation that is responsible for the wrong error report.

Google Guice 3 and OSGi (Eclipse equinox) problem,

I have trouble running Guice 3 within an OSGi container.
Following is a simple test I wrote to test if Guice work well with OSGi.
A simple guice module like:
public class Module extends AbstractModule {
#Override
protected void configure() {
bind(IInterface.class).to(IImplement.class);
}
}
The IInterface and IImplement are both very trivial.
The OSGi activator like this:
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
Injector inj = Guice.createInjector(new Module());
IInterface e = inj.getInstance(IInterface.class);
e.sayHello();
}
In Eclipse, I made a target contains all the Guice Jars, and to make guice resolve itself, I made two additional bundle for the aopalliance.jar and javax.injector.jar
However, this simple test fail to load the test bundle, gives me error message complaining cannot find a guice class cannot be found:
Exception in guicetest.Activator.start() of bundle guicetest
Caused by: java.lang.NoClassDefFoundError: com/google/inject/binder/AnnotatedBindingBuilder
at guicetest.guice.Module.configure(Module.java:11)
I hope I have made the problem clear. Can anyone show me how to resolve this problem?
Ah, after just posting the question I found the root of the problem. I didn't specify the com.google.inject.binder package, which the problematical class resides, in the test bundle's Import-Packages. Although the Module doesn't import directly that package, it looks it is still necessary to specify all the indirect dependent packages as well.

UnsupportedPointcutPrimitiveException on simple AOP example

I try to run a simple aop example in this site. I have spring aop and aspectj, aspectjweaver jars:
#Aspect
public class StringAspect {
#Pointcut("call(* String.toLowerCase())")
public void toLowerCasePointcut() {}
#Around("toLowerCasePointcut()")
public String toLowerCaseAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
String text = ((String) joinPoint.getTarget()).toUpperCase();
return text;
}
}
When I run this example in Test.java like "AaBbCc".toLowerCase(), I get this exception;
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean ... Initialization of bean failed; nested exception is org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression call(* String.toLowerCase()) contains unsupported pointcut primitive 'call'
Spring AOP doesnt contain "call", but why aspectj weaving is not working, ,do you have an idea? Thank you.
edit:
In my spring config file I only have bean definition of #aspect annotated class and <aop:aspectj-autoproxy />.
my jars are : spring-aop-3.0.5, aopalliance, aspectjrt1.6.8, aspectjweaver1.5.0
Have you tried to use the AspectJ Eclipse plugin to do the weaving? (It is also included in SpringSource Tool Suite)
If you have some aspect configuration in your Spring configuration. Try to remove it and just enable AspectJ nature on the project. Also remove all AspectJ jar files and only use those that is attached automatically by the plugin.
With this setup it works for me at least.
Updated: Weaving the aspect advice into code
You get an exception from the Spring container because of your call pointcut. But you want AspectJ weavingweave the aspect. Then you need to use either compile-time or load-time weaving. Compile-time weaving is the simplest alternative ant the alternative offered by the plugin.
You can look at the AspectJ compiler as an advanced Java compiler that also supports AspectJ. So you can run your compiled code anywhere.
Also, you do not need the plugin to compile. You can for example compile with an Ant task as I have showed here.
But the easiest alternative is to use the plugin. This also gives you extra help which I have described briefly here.
I hope this helps!