deploying jsf jpa web application in weblogic 12.1.1 - spring

i am developping a web application using Maven , JSF 2.2 ,JSTL 1.2.1 , JPA 2.1 , Spring 4.2.9, Hibernate-jpa-api-2.1
i can deploy my application in Tomcat and run it without problems , but i want deploy in weblogic 12.1.1 as well but i got some problems starting my app server :
nested exception is java.lang.NoSuchMethodError : javax.persistance.Table.indexes()[Ljavax/persistence/Index;
....
org.springframework.beans.factory.BeanCreationException : Error creatin bean with name 'myEmf' defined in class path resource [jpaConfig.xml]
....
Error javax.entreprise.resource.webcontainer.jsf.application
i have created a weblogic.xml in my deployed war like this :
<prefer-application-packages>
<package-name>javax.faces.*</package-name>
<package-name>com.sun.faces.*</package-name>
<package-name>com.bea.faces.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>javax.faces.*</resource-name>
<resource-name>com.sun.faces.*</resource-name>
<resource-name>com.bea.faces.*</resource-name>
<resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
</prefer-application-resources>

The error message "java.lang.NoSuchMethodError" indicates a library collision with the JPA 2.0 Library of Weblogic. Since you are packing your own library for that, try adding "javax.persistence.*" to the weblogic.xml
Option 2: Add the JPA 2.1 Support to weblogic classpath
In your domain/bin/setDomainEnv (.cmd for windows, .sh for unix) add a PRE_CLASSPATH Variable. On a windows System this would look like this:
set PRE_CLASSPATH=C:/weblogic_12130/oracle_common/modules/javax.‌​persistence_2.1.jar;‌​C:/weblogic_12130/wl‌​server/modules/com.o‌​racle.weblogic.jpa21‌​support_1.0.0.0_2-1.‌​jar

Related

Unable to deploy war to Tomcat

I get this error when deploying application war to the server:
12-Sep-2018 10:21:54.726 SEVERE [localhost-startStop-1] org.apache.catalina.startup.ContextConfig.processAnnotationsJar Unable to process Jar entry [module-info.class] from Jar [file:/xxx/apache-tomcat-8.0.41_xxxx/webapps/xxx/WEB-INF/lib/jaxb-api-2.3.0.jar] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
Informations:
Application is a micro-service created with Spring Boot
Java used is version 8
Tomcat version: tomcat-8.0.41
Thank you.
module-info.class is a module descriptor for Java’s module system that was introduced in Java 9. Some code in Tomcat 8.0 is unable to read the bytecode in that class file so deployment is failing.
I believe this is a limitation of Tomcat 8.0 that has been fixed in 8.5. Also note that an end-of-life announcement has been made for 8.0 so you should be planning to upgrade ASAP even without this problem.

spring-boot banner.text not working when deployed as a WAR File

Deployment Server : Liberty
java -jar spring-boot-application.jar -> Banner is printed as expected
My banner.text
Application Name : ${application.title}
Application Version : ${application.version}
Application Formatted Version : ${application.formatted-version}
Spring Boot Version : ${spring-boot-version}
Spring Boot Formatted Version : ${spring-boot.formatted-version}
--------------------------------------------------------------------------
${AnsiColor.BRIGHT_RED} Spring boot banner customization example
-------------------------------------------------------------------------
However when I build this jar as webapp
mvn install -Pwebapp ( maven-war-plugin)
and deploy the WAR on Liberty Server - only ${spring-boot.formatted-version} is printed. rest are blank.
Any clues ?

Why isn't this jar packaging valid for Spring Boot?

I am trying to understand the packaging of Spring Boot into "fat" jars. From what I know "fat" jars have their own special classes that load up the main class when the jar is running and also sets the classpath accordingly.
What I cannot understand is why when I use Eclipse to extract all my dependencies into a folder structure in the jar, the jar no longer runs as a correct Spring Boot application.
To repeat what I have done here just take a simple Spring Boot app and from Eclipse select the following-:
Export --> Runnable Jar --> Select Main Class --> Extract required libraries into jar.
Just run the jar from the command line as you would any jar. Spring Boot initially starts up but fails with the following message-:
2017-05-02 22:06:40.484 WARN 3468 --- [ main]
ationConfigEmbeddedWebA pplicationContext : Exception encountered
during context initialization - cancel ling refresh attempt:
org.springframework.beans.factory.BeanDefinitionStoreExcep tion:
Failed to process import candidates for configuration class
[com.main.Test Main]; nested exception is
java.lang.IllegalArgumentException: No auto configuration classes
found in META-INF/spring.factories. If you are using a custom packa
ging, make sure that file is correct.
Can I somehow edit the spring.factories file to include my classses ?
I just trying to understand how Spring actually packages the files through its Maven plugin.
I think that because it's a Spring Boot application, you need to use their plugin for building. It is because, spring Boot has its own jar loading mechanism for that (the BOOT-INF introduction in Spring Boot 1.4).
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
From documentation:
The Spring Boot Maven Plugin provides Spring Boot support in Maven, allowing you to package executable jar or war archives and run an application “in-place”.
Link to documetantion (Appendix E)
Something about spring.factories and locating auto-configuration candidates - Auto-configuration

grails 2.3 java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument

When i run my grails application in tomcat i get the following error
java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument. But the batik-svg-dom.1.7.jar is packaged in the war and in the classpath.
I don't however get this error when i am running the application in debug mode in STS.
I am using Grails 2.3 and building my war using maven. I am using FOP and have excluded the "xml-apis".
I have tried to place the batik-svg-dom.jar in the lib folder of tomcat, that did not work.
Thanks in advance.

Grails 1.2.1 with Spring 3.0.0 dependency problem under Jetty

Just moved to Grails 1.2.1 (used 1.1.1 before). Changed application.properties, ran grails upgrade, fixed BuildConfig and Bootstrap - everything works just fine from grails console.
However, getting a problem when deploy packaged war under jetty 6.1.22:
1581 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.setParameterNameDiscoverer(Lorg/springframework/core/ParameterNameDiscoverer;)V
My project is built with maven2. I researched the war dependencies and see that both spring 2.5.6 and 3.0.0.RELEASE are used there.
I then tried to suppress use of spring 2.5.6 and got a problem with Acegi plugin (using version 0.5.1):
2010-03-10 21:06:56.440:WARN::Nested in org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
Any help would be greatly appreciated.
The problem is caused by the fact that in new version of Spring
ConfigurableWebApplicationContext is located in spring-web.jar, but the interface it inherits ConfigurableApplicationContext, which contains setId(String) method is in located in spring-context.jar.
If you have a library which has been compiled against older version of spring-context it will fail with NoMethodFound exception.
The solution is to locate and recompile that library against latest Spring version.
If you are using Spring version below 3.0 you could try to put full Spring bundle Jar instead of separate packages.

Resources