Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am getting the below exception while creating bean eqSaml11TicketValidator.
I am using IBM Websphere 8.5.5.
Context initialization failed:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eqSaml11TicketValidator' defined in class path resource [META-INF/eQSecurityClient.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
The class you are trying to create cannot be instantiated by the JVM. The error message ExceptionInInitializerError can have several reasons
The constructor of the class failed with an exception
At least one class or instance initialisation failed, e.g.
public class Test {
private static int num = 1/(1-1); // Throws Exception
private Object object = new SomeObject(); // if new SomeObject() throws exception
Another reason could be that you are missing a class on your classpath that this class or any class used by this class including parent classes require.
If the exception happens in you code, you could try to wrap the creation of the object in a try/catch block and print the cought exception including it's cause. The cause will most likely show the real reason of the failure.
Related
Actually, I am facing below exception
ERROR : XML Read or Write is not done properly.
org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: my_ClassName nor any of its super class is known to this context.
While making request that is throwing exception XMLMappingException. There is no code change in existing I just added new wsdl(converted to jar in proper place)but facing issue.
If anyone knows answer this question.
I tried the stack overflow solutions regarding this issue, solutions are not matching to my problem statement.
Basically, the code I have is here below. Take into account that this is a "test" state of the code. The original problematic was a call on init() to a different class that threw a checked exception. This throw was catched by a try/catch block, then the application failed when trying to create the exception. All that has been removed for clarity's sake, as the problem was in the "MyCustomRuntimeException" creation.
#Component
public class ClassName {
public ClassName() {
//minor, non problematic operations.
}
#PostConstruct
public void init() {
throw new MyCustomRuntimeException("AAAAAAAH");
}
}
MyCustomRuntimeException is defined like this:
public class MyCustomRuntimeException extends RuntimeException {
public MyCustomRuntimeException (String message) {
super(message);
}
}
And, I'm getting an "UnsatisfiedDependencyException" when creating a class that uses this class. The console points towards the line where the new MyCustomRuntimeException is being thrown, and I don't really get what's going on.
Also, "MyCustomRuntimeException" started as a regular exception, but I saw that I should throw a RunTimeException instead because the #PostConstruct forbids checked exceptions to be thrown. And I've also tried to throw a standard RunTimeException with no luck.
So, I'm clueless here. Any ideas on why I can't throw this exception?
Every bean in the context needs to be correctly created. When an error occurs the creation of beans will stop/fail and the context (or in other words your Application) will not start.
You get an UnsatisfiedDependencyException due to the fact that the ClassName bean is created because it is needed by the other bean. After construction of ClassName it will call the #PostConstruct of the ClassName bean, and that fails due to an exception. Hence the instance doesn't get created, hence an UnsatisfiedDependencyException.
The root cause of the UnsatisfiedDependencyException will be the exception thrown by your own initializer method.
Here is what my code looks like, and it is unclear how/why executorService.submit(work::get) would throw a ClassNotFoundException on the anonymous class in question. It does not happen all the time, but once this exception is encountered, it does not seem to recover - subsequent requests are then met with the same exceptions. Anyone know what could be causing this to occur?
EDIT: I can confirm that either all calls to this method work, or none does, in a VM session - it is not like some succeed while others fail due to the said exception.
Further edit: https://bugs.openjdk.java.net/browse/JDK-8148560 is the exactly the bug I am experiencing, but that one was closed since it was not reproducible and/or the reporter did not respond. It somehow looks like the anonymous type resulting from the lambda expression is garbage collected before the executor gets to execute the expression, but obviously not always. The jdk in use is openjdk1.8.0_221.
package com.ab.cde.ct.service.impl;
#Service
public class IngestionService {
#Autowired private TransactionTemplate transactionTemplate;
#Autowired private AsyncTaskExecutor executorService;
#Transactional
public void ingest(Data data) {
Supplier<Optional<String>> work = () -> transactionTemplate.execute(s -> {
// actual work on the data object, enclosed in a try/catch/finally
});
executorService.submit(work::get); // this is where the exception gets thrown
}
}
Here is what the exception stacktrace looks like (line nos. won't correspond since the code above is only a prototype):
2019-10-23 19:11:35,267|[http-apr-26001-exec-10]|[B6AC864143092042BBB4A0876BB51EB6.1]|[]|[ERROR] web.error.ErrorServlet [line:142] org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/ab/cde/ct/service/impl/IngestionService$$Lambda$53
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/ab/cde/ct/service/impl/IngestionService$$Lambda$53
at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1275)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:951)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:853)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
Caused by: java.lang.NoClassDefFoundError: com/ab/cde/ct/service/impl/IngestionService$$Lambda$53
at com.ab.cde.ct.service.impl.IngestionService$$Lambda$53/812375226.get$Lambda(Unknown Source)
at com.ab.cde.ct.service.impl.IngestionService.ingest(IngestionService.java:264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy252.ingest(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.ab.cde.ct.service.impl.IngestionService$$Lambda$53
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1185)
... 115 more
This is the case of synthetic method generated by lambda which is unable to find the required class (i.e. TransactionCallback) and thus the below error
Caused by: java.lang.NoClassDefFoundError: com/ab/cde/ct/service/impl/IngestionService$$Lambda$53
at com.ab.cde.ct.service.impl.IngestionService$$Lambda$53/812375226.get$Lambda(Unknown Source)
The particular code which causes this issue is
Supplier<Optional<String>> work = () -> transactionTemplate.execute(s -> {
// actual work on the data object, enclosed in a try/catch/finally
});
To get past this modify the code as below
TransactionCallback<Optional<String>> callback = transactionStatus -> {
// your processing goes here
return Optional.of("some value");
};
Supplier<Optional<String>> work = () -> transactionTemplate.execute(callback);
If above still doesn't work use below workaround
Object callback = (TransactionCallback<Optional<String>>)transactionStatus -> {
// your processing goes here
return Optional.of("some value");
};
Supplier<Optional<String>> work = () -> transactionTemplate.execute((TransactionCallback<Optional<String>>)callback);
Do let know in comments if any more information is required.
P.S.: There is no need for #Transactional if transactionTemplate is being used as both essentially serves the same purpose.
References:
Lambda compilation here and here
Synthetic methods in java
I've had this before with both DI issues and with ambiguity bugs/config problems in package resolution. I'm assuming from your post that the error happens after successful startup, and exactly on invocation of that line in the method, and can be hit in the debugger.
First suggestion:
With Gradle/Maven, check dependent packages to make sure everything has the version it needs, and you aren't overriding a version globally that may affect a dependent package that requires a higher or lower version of that dependency.
Some low hanging fruit to try first (if it is easy enough to pick):
Update your JDK version or Java version (or see if another dev on your team has a different version and they can repro the issue)
Update your version of spring (even a minor version)
Update your IDE
Add logging and check if the issue can be reproduced in release environments.
Regarding dependency injection,
I would recommend trying something like the following.. and is also a good practice for dependency injection in spring, as it gives spring a more explicit dependency map, and increases your ability to debug the application dependencies.
#Service
public class IngestionService {
private TransactionTemplate transactionTemplate;
private AsyncTaskExecutor executorService;
public IngestionService(TransactionTemplate transactionTemplate, AsyncTaskExecutor executorService) {
this.transactionTemplate = transactionTemplate;
this.executorService = executorService;
}
#Transactional
public void ingest(Data data) {
Supplier<Optional<String>> work = () -> transactionTemplate.execute(s -> {
// actual work on the data object, enclosed in a try/catch/finally
});
executorService.submit(work::get); // this is where the exception gets thrown
}
}
There are a few reasons I recommend this:
In java, when no constructor is defined, it is implied that there is a default constructor, and the compiler will generate a constructor for you. To spring, this can be confusing and also decrease performance.
Defining this constructor explicitly tells Spring: I'm relying on these two dependencies which I also have setup as Beans that will be non-null and fully resolved on construction. You must initialize those dependencies first and pass them in before this can be a valid object.
This helps in debugging, you can set a breakpoint in the constructor and validate what is coming in.
If there is an issue with your bean setup for the dependencies, Spring will explode. The spring stack traces aren't always the most helpful, but it may help you debug any issue where you're not fully isolating and declaring beans you depend on in the correct way.
It allows you to eliminate the possibility of any issues with injection, both from the Spring Framework point of view (hard to tell what happens behind the scenes), and from your application/domain logic point of view. If it is still null later, you'd have been able to debug what was passed in the constructor - meaning it either came in null, was de-allocated later, or there is an ambiguity problem where there may be two defined and spring will pass in the first one created even though there may eventually be multiple executorServices created.
As this should be a valid bean definition as long as the class is included in your configuration's component scan, you may need to define the bean explicitly in a configuration class, especially if you have multiple beans of each type (which could also be your problem)
Ex:
#Configuration
class SomeConfiguration {
#Bean
public IngestionService myIngestionServiceDefaultBeanNameChangeMe(TransactionTemplate transactionTemplateParamSentBySpringAutomaticallyChangeMyName, AsyncTaskExecutor executorServiceSentBySpringAutomaticallyChangeMyName) {
return new IngestionService(transactionTemplateParamSentBySpringAutomaticallyChangeMyName, executorServiceSentBySpringAutomaticallyChangeMyName);
}
}
Note that for the configuration, the params for the bean method will be sent in by spring automatically once those beans have been initialized within this config or another config. Pretty cool eh?
Also the name of your bean corresponds with the method name here, and if you have multiple beans of the same type spring could pass in as parameters, you may need to tell spring which bean name to use. To do this you'd utilize the #Qualifier annotation.
I really hope this helps, or at least validate instantiation is happening correctly.
Oracle BPM Version 11.1.1.7. In a Humantask.task, Events tab, Content Change Callbacks section, I have entered the fully qualified class name of a class that implements NotesStore and the addNote and getNotes methods.
The class uses public methods in an AppModule to write and read comments using our custom table and these methods were well tested during development using the the BC tester and a temporary main in the callback class.
The project is compiled to a jar and placed in the BPM project's SCA-INF/lib folder, then the SCA and related ADF human task forms are deployed.
When a comment is made in the out of box human task comments section during a process instance, the class is called, but an exception occurs in the getNotes method at the line the AppModule is created:
java.lang.ClassCastException: oracle.jbo.common.ampool.PoolMgr
In the class, the AppModule is created as so:
AuditModule service = (AuditModule)Configuration.createRootApplicationModule("com.co.modules.AuditModule", "AuditModuleLocal");
I've tried adding a web.xml config file to the SCA BPM project with a filter as discussed in this post (last answer). This discusses triggering the ADF Context initialization, but I'm still getting the error.
The question is, how can I use a call back from a human task to call a method that uses AppModule public methods to do the DB work? Oracle's documentation is very sparse in this area (29.11.1).
UPDATE
Turns out that the stack trace shows that it is having problems looking up the data source name and is actually throwing a JBO error. If anyone runs in to this, check the stack trace for other issues.
UPDATE2
Finally got this to write task comments into the custom comments table. It turns out it doesn't seem possible to use an AppModule/Model approach in a comments callback class as there appears no way to initiate the needed ADF context when the class is called. By rewriting the class to access the DB directly in code the comment callback class does write the table. But, I am getting the same error as this post. Namely:
Exception invoking method from XML data control. Cause:oracle.bpel.services.workflow.client.WorkflowServiceClientException: java.rmi.UnmarshalException: cannot unmarshaling return; nested exception is:
Supplemental Detail java.io.IOException: Error: Unexpected type encountered in writeExternal oracle.bpel.services.workflow.client.WorkflowServiceClientException: java.rmi.UnmarshalException: cannot unmarshaling return; nested exception is:
java.io.IOException: Error: Unexpected type encountered in writeExternal
I suspect this is an Oracle framework issue as the types that are passed back are from the NotesStore implementation which are all passed back to the framework:
public class CommentsCallback implements NotesStore, Serializable...
public List<CommentType> getNotes(Task task)
Has anyone solved this? Full stacktrace at:
https://community.oracle.com/thread/3638940
After discussion with Oracle, the key to avoiding the unexpected type error is to use an ObjectFactory to populate the CommentType object. While we took a different approach ultimately, the below code was provided by Oracle as an example and might help someone trying to do this:
import oracle.bpel.services.workflow.task.model.ObjectFactory;
import oracle.bpel.services.workflow.task.model.CommentType;
import oracle.bpel.services.workflow.task.model.IdentityType;
...
ObjectFactory factory = new ObjectFactory()
CommentType commentType = factory.createCommentType();
IdentityType updatedBy = factory.createIdentityType();
updatedBy.setId("some user");
updatedBy.setType(IWorkflowConstants.IDENTITY_TYPE_USER);
updatedBy.setDisplayName("some user display name");
commentType.setUpdatedBy(updatedBy);
commentType.setComment("some comment");
...set the rest of the comment fields as necessary...
I'm working with Spring security and Hibernate, but I am getting the following problem in the xml file spring-security.xml
Description Resource Path Location Type
Error occured processing XML
Could not initialize class org.springframework.security.config.http.MatcherType'. See Error Log for more details spring-security.xml /testholding/WebContent/WEB-INF line 9 Spring Beans Problem
The problem is the HTTP /HTTP of spring-security.xml
I need help please!
The message Could not initialize class SomeClass means that the JVM has already tried and failed to statically initialize the class SomeClass. If you restart your web application container and make another attempt to reproduce the error, you may get a different message the first time.
Static initialization of a class consists of running any static { } blocks and assigning values given to any static fields. In the case of the MatcherType class mentioned in your error message, the static initialization is as follows:
private static final Log logger = LogFactory.getLog(MatcherType.class);
private static final String ATT_MATCHER_TYPE = "request-matcher";
private static final String ATT_PATH_TYPE = "path-type";
The two string constants won't be a problem. However, the first one is where I suspect the problem to be. The method LogFactory.getLog is in Apache Commons Logging.
My bet is therefore that your web application is missing the commons-logging jar. Try adding that and seeing if it makes a difference.