Birt integration in JHipster application - birt

I'm fairly new to Jhipster and angularjs and i'm trying to integrate the Birt engine in a JHipster application using an H2 embedeed database.
I found this page that details how to integrate the birt engine in a spring application but i don't to how to applicate this for my application.
Here are the modifications performed in the jhipster project:
add dependency to org.eclipse.birt.runtime in pom
Create the classes Car, CarServiceImpl, BirtView, BirtEngineFactory and BirtDataServiceConfiguration in a sub-package report as described in the article.
I added the BirtWebConfiguration class in the sub-package config. I removed the #ComponentScan line that is already taken into account in the Application class.
I created an empty report in src/main/webapp/reports/toto.rptdesign
My problems are:
When accessing the application main page a "PageNotFound exception" with the following message "No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'dispatcherServlet'". I presume this is due to the BirtWebConfiguration that seems to overwritte the rest path configuration.
How shall I define a new rest end-point /reports ?
When accessing the http://localhost:8080/reports page, a thymeleaf exception is raised
[ERROR] org.thymeleaf.TemplateEngine - [THYMELEAF][http-nio-127.0.0.1-8090-exec-5] Exception processing template "birtView": Error resolving template "birtView", template might not exist or might not be accessible by any of the configured Template Resolvers
[ERROR] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "birtView", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "birtView", template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:245) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.3.RELEASE.jar:na]
at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) ~[thymeleaf-spring4-2.1.3.RELEASE.jar:na]
at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring4-2.1.3.RELEASE.jar:na]
Thanks for any help.

Has the BirtView bean been created? For example, in config/LocaleConfiguration.java:
#Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/reports").setViewName("birtView");
}
#Bean
public BirtView birtView(){
BirtView birtView = new BirtView();
birtView.setDataSource(dataSource);
birtView.setAppContext(applicationContext);
birtView.setBirtEngine(this.engine().getObject());
return birtView;
}

Related

Upgrading from WebLogic 12.1.3 to 12.2.1.4 breaks our application using Spring Framework 3.0.2

Our company is having us upgrade from Oracle WebLogic 12.1.3 to 12.2.1.4 since 12.1.3 is out of support/going out of support.
We have a major application that is using Spring Framework v3.0.2. When we deploy the EAR to 12.2.1.4 and attempt to consume any of the web services, we get this error stack trace. I've removed names that specify our company with generic names but you should be able to get the gist of what is happening:
2021-06-02 15:21:50.019/27.406 Oracle Coherence GE 12.2.1.4.0 (thread=[STANDBY] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a): Configured versioned, multi-cluster Management over ReST
02.06.2021 15:22:11 - error trying to getBean("DefaultJBL"): Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/lasor/2wlg44/lib/Lasor_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.foo.app.corebuslogic.common.exceptions.LoggedException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DefaultJBL' defined in URL [zip:C:/javadev/server/appserver.12.2.1.4/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/app/2wlg44/lib/App_core-1.0.jar!/com/foo/app/corebuslogic/common/jbl/DefaultJBL.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.aep.lasor.corebuslogic.common.exceptions.LoggedException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
at com.foo.util.FOOApplicationContext.fetchBean(FOOApplicationContext.java:203)
at com.foo.app.buslogic.common.generic.GenericSessionBean.getBL(GenericSessionBean.java:293)
at com.foo.app.buslogic.common.generic.GenericSessionBean.query(GenericSessionBean.java:97)
I also believe the API is SOAP in 12.1.3 but I see REST specified in the 12.2.1.4 logs. Could this be the issue or am I reading that incorrectly?
Also, the classes is says it cannot find I've verified are there in the deployment area of WebLogic so I'm not sure why it can't find them.
Here is where the code throws an exception no matter what bean name I pass in but they've all been defined. The class is our FOOApplicationContext that implements org.springframework.context.ApplicationContextAware and has a fetchBean function that does the following:
public static Object fetchBean(final String beanName) throws FOOException {
Object object = null;
if (beanName == null) {
throw new FOOException("beanName is null");
}
try {
object = currentSpringContext().getBean(beanName);
} catch (Exception e) {
final String message = "error trying to getBean('"" + beanName + "\"): " + e.getMessage();
throw new FOOException(message, e);
}
return object;
}
When getBean() is called under WebLogic 12.1.3, it works. But it throws the AOP Exception error listed above when this exact same function is called under WebLogic 12.4.1.2. No code changes, etc. Not sure why this is.
We haven't created an actual server yet to deploy to, but instead I've installed it locally on my development machine. I've set up the database connections, etc the same way as do when locally installing 12.1.3. Is there something that has changed in regards to Spring Framework? The code was written over 8+ years ago and I inteherited the support for it and now I have to get us moved to WebLogic 12.2.1.4 before the end of this year and this is a major part of a very important application. The WebLogic application houses all the business logic and database access in it so without it, the front-end app is dead in the water.
Also, none of our registered beans will instantiate at all under WebLogic 12.2.1.4 but it works under 12.1.3. I've even recompiled the EAR file and again, it works under 12.1.3 but not 12.2.1.4.
I've found what appears to be a possibly circular reference between 2 objects that are not registered as beans, but the beans do depend on. So those 2 objects are not registered as beans. Not sure why it was done that way, but in any case, this doesn't seem to create a problem in 12.1.3. But one of the objects (FOOException) shows up in the error thrown when trying to create the DefaultJBL bean within the FOOApplicationContext object.
I'm not sure what else I can provide. Searching around the internet has not found a solution to my issue. I've found some that appeared as if they would fix it, but they turn out to not apply. I cannot seem to find anyone else with this issue, but Google and Duck Duck Go all find various "solutions" that don't apply to my situation.
Thanks!
ClassNotFound Exception, You may need to update the Dependencies pertaining to Spring Framework

Spring Boot + Thymeleaf CSS file cannot access and have 500 error no template found

When I use Spring Boot 1.4.0 + Thymeleaf, I find the static resources couldn't access and throw the error "template might not exist or might not be accessible by any of the configured Template Resolvers".
Folder structure about my static resources
Browser show 500 error
From server log, can find the error "template not found". But the URL should be my CSS file location.
2018-08-28 21:07:29.826 ERROR 5676 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "Spring Boot Application is available.", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
It sounds like Spring Boot is trying to resolve the resource path as a template. There may be a conflict with a path to one of your controllers. Spring Boot by default serves static resources from /**. You can alter this default path in your application.properties file with the spring.mvc.static-path-pattern.
## application.properties
spring.mvc.static-path-pattern=/resources/**
This would result in a new resource path to your static content
boostrap.min.css
http://localhost:8080/resources/css/bootstrap.min.css
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-spring-mvc-static-content
After checking my source code, I find it's because I have another controller has request mapping to home page and block CSS/JS URL. After I comment the function test2(), home page can load static resources now.
#RequestMapping(value = "/")
public String test1(){
return "index";
}
#RequestMapping
public String test2(){
return "index";
}

Spring Boot + Web + Thymeleaf: Circular view path in Spring IO Guide for "Securing a Web Application"

I am trying out the Spring IO Guide for "Securing a Web Application" available at https://spring.io/guides/gs/securing-web/.
The guide instructs to build a simple unsecured web application first and secure it using Spring Security later. However, after building the unsecured web application with Spring Boot 2.0.1.RELEASE version, I am getting the following error on trying to access a URL (http://localhost:9191/hello) of the web application:
2018-05-04 09:58:07.742 ERROR 25968 --- [nio-9191-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circular view path [hello]: would dispatch back to the current handler URL [/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause
javax.servlet.ServletException: Circular view path [hello]: would dispatch back to the current handler URL [/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
I replicated the code as available at the above URL (i.e. https://spring.io/guides/gs/securing-web/) and my embedded tomcat server is running on port 9191 (as port 8080 is used by some other app). Any help is appreciated. Thanks in advance!
Edit:
Following is the configuration/controller code from the guide:
#Configuration
public class MvcConfig implements WebMvcConfigurer {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/home").setViewName("home");
registry.addViewController("/").setViewName("home");
registry.addViewController("/hello").setViewName("hello");
registry.addViewController("/login").setViewName("login");
}
}
Please add dependency for thymeleaf in your pom. as ViewResolver of thymeleaf is not present to resolve th:href="#{/hello} in your hello.html so throwing error:
Add below dependency in your pom.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
check spring-boot-starter-thymeleaf dependency in your build path

spring + hibernate web application

I have started Web Application using Spring + Hibernate MVC. I Created All File. There are some issues when i'm debug my application. Here I have attached test-servlet.xml. First one is that how to add' ' then there are 3 errors when i'm debug my application. I have also mentioned that error line. So any one help me plz on this???
error :
![javax.servlet.ServletException: Servlet.init() for servlet test threw exception
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource \[/WEB-INF/config/test-servlet.xml\]; nested exception is java.lang.NoClassDefFoundError: org/springframework/transaction/interceptor/TransactionInterceptor
java.lang.NoClassDefFoundError: org/springframework/transaction/interceptor/TransactionInterceptor]
The exception says:
java.lang.NoClassDefFoundError:
org/springframework/transaction/interceptor/TransactionInterceptor
Check your WEB-INF/lib and make sure you have the spring jar file that contains this class.
Download the org.springframework.transaction.jar and add add it to your classpath.
This class is found in "spring-tx" jar that should be present in your classpath (lib). Please check this. If not present please download appropriate version from here.

java.lang.IllegalStateException: getWriter() has already been called for this response

I am doing training about CXF and Spring, so I wrote a very simple CXF demo which only has the interface "HelloWorld" and its implementor "HelloWorldWs".
I want to publish it with Tomcat. I wrote a web.xml and applicationContext.xml(Spring profile. Though i can publish the WSDL .But the console list a problem:
Servlet.service() for servlet [CXFServlet] in context with path [/cxf_spring] threw exception java.lang.IllegalStateException: getWriter() has already been called for this response
I did not use or write any io function, just a "sayhi" function. I am stumped.
This is actually a bug and is fixed as part of https://issues.apache.org/jira/browse/CXF-5620,
CXF 2.7.11 (released)

Resources