PropertiesLauncher unable to jar files in Uberjar when using Spring Boot - spring

We seem to be having an issue while using propertiesLauncher (layout as ZIP). When we run the jar with or without using -Dloader.path
java -jar myuberjar.jar
We keep getting an error saying that it is not able to find jar file that is present in myuberjar.jar
Caused by: java.lang.IllegalArgumentException: File [/Users/myuser/myuberjar.jar!/lib/jackson-module-jaxb-annotations-2.5.4.jar] referenced by given URL [file:/Users/myuser/myuberjar.jar!/lib/jackson-module-jaxb-annotations-2.5.4.jar] does not exist
at org.hibernate.jpa.boot.archive.internal.StandardArchiveDescriptorFactory.buildArchiveDescriptor(StandardArchiveDescriptorFactory.java:73)
at org.hibernate.jpa.boot.archive.internal.JarProtocolArchiveDescriptor.<init>(JarProtocolArchiveDescriptor.java:71)
at org.hibernate.jpa.boot.archive.internal.StandardArchiveDescriptorFactory.buildArchiveDescriptor(StandardArchiveDescriptorFactory.java:55)
at org.hibernate.jpa.boot.archive.internal.StandardArchiveDescriptorFactory.buildArchiveDescriptor(StandardArchiveDescriptorFactory.java:48)
at org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.buildArchiveDescriptor(AbstractScannerImpl.java:95)
at org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:70)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:725)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:221)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:188)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider$1.<init>(SpringHibernateJpaPersistenceProvider.java:49)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:49)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
Not sure what we are missing.
SpringBoot - 1.2.4.RELEASE
JDK1.8
PropertiesLauncher
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
</configuration>
</plugin>
When i extract the uberjar , i can see all the jars in the lib folder. Bellow are the contents of the manifest file
Manifest-Version: 1.0
Implementation-Title: AppService
Implementation-Version: 0.0.1-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: avinash
Start-Class: com.company.app.AppServiceApplication
Implementation-Vendor-Id: com.company.services.app
Spring-Boot-Version: 1.2.4.RELEASE
Created-By: Apache Maven 3.2.1
Build-Jdk: 1.8.0_25
Implementation-Vendor: Pivotal Software, Inc.
Main-Class: org.springframework.boot.loader.PropertiesLauncher

The issue is not with Spring Boot properties launcher, but more with Hibernate jars as described in the bug below.
https://hibernate.atlassian.net/browse/HHH-4161

Related

ClassCastException: Can't cast oracle.sql.ARRAY to oracle.sql.ARRAY in JBoss 7.1.1.Final

DemoApp is spring integration project deployed in jboss 7.1.1.Final
The result returned from a stored procedure contains object of oracle.sql.ARRAY (object referring ojdbc jar of jboss module)
And I tried converting to oracle.sql.ARRAY which throwing exception
Code:
URL resultJarLocation= resultMap.get("returnObj").getClass().getProtectionDomain().getCodeSource().getLocation();
URL appJarLocation = oracle.sql.ARRAY.class.getProtectionDomain().getCodeSource().getLocation();
System.out.println("resultJarLocation : " + resultJarLocation);
System.out.println("appJarLocation : " + appJarLocation);
oracle.sql.ARRAY returnObj=(oracle.sql.ARRAY)resultMap.get("returnObj");
EXCEPTION:
org.springframework.messaging.MessageHandlingException: java.lang.ClassCastException: oracle.sql.ARRAY cannot be cast to oracle.sql.ARRAY
The application ARRAY class is referring ojdbc jar in the deployed application.
where as result set ARRAY class referreing ojdbc jar jboss module
Sys Output:
resultJarLocation : jar:file:/<JBOSS_HOME>/modules/com/oracle/ojdbc6/main/ojdbc6.jar
appJarLocation : vfs:/<JBOSS_HOME>/bin/content/DemoApp.war/WEB-INF/lib/ojdbc6.jar
You are trying to cast between classes loaded by different classloaders. JVM distinguishes classes not only by name and package but also by the classloader used. In other words, from JVM perspective is like trying to cast from say String to Long; you cannot.
The only think you can do is configuration. Set up either for the same classloader to be used, or the classloaders to be in the same hierarchy, to take advantage of delegation.
I am not very familiar with JBoss (especially current versions) but I know it has (or used to have in the past) some very different classloading strategy than other application servers. Checking with its documentation on classloading would be my first option.
I solved the problem by changing the ojdbc jar's scope as 'provided' as this will not include the jar in the WEB-INF/lib.
And then added the Dependencic of jboss 7 module 'com.oracle.ojdbc6' in pom.. which will add the Dependencies attribute in META-INF/MANIFEST.MF file, as a result on deployment the jboss 7's ojdbc jar will be uses for object creation for both jboss and application, and the classloader will be the jboss's classloader.
Bellow are the code in pom.
1) Manifest entry :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>com.oracle.ojdbc6</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
2) Dependency as Provided:
<dependency>
<scope>provided</scope>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.2.0</version>
</dependency>
META-INF/Manifest.MF file will be generated with dependency entry
Manifest-Version: 1.0
Dependencies: com.oracle.ojdbc6
Built-By: Mrinmoy
Build-Jdk: 1.7.0_65
Created-By: Apache Maven 3.2.2
Archiver-Version: Plexus Archiver

Howto use Maven Cargo Plugin to deploy a Web Application Bundle (WAB, OSGI + JavaEE) into Glassfish 3.x

I'm trying to use the Maven Cargo Plugin to deploy a set of OSGI bundles and an hybrid application .war (Webapplication with Restservice which uses OSGI) also called a Web Application Bundle (or WAB) (e.g. see https://glassfish.java.net/public/GF-OSGi-Features.pdf).
Deploying of OSGI bundles into a Glassfish 3.1.x works fine, but I haven't found a way to deploy the Web Application Bundle.
It's packaging is "war", but I have to deploy it as OSGI bundle. So how can I tell this the Cargo Plugin?
The maven configuration I tried to use:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<wait>false</wait>
<container>
<containerId>glassfish3x</containerId>
<home>${glassfish.home}</home>
<type>installed</type>
</container>
<configuration>
<type>existing</type>
<home>${glassfish.home}</home>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.rmi.port>4848</cargo.rmi.port>
<cargo.domain.name>${glassfish.domain}</cargo.domain.name>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>com.acme.rest</groupId>
<artifactId>rest-api</artifactId>
<type>bundle</type>
</deployable>
</deployables>
</configuration>
</plugin>
But the following error shows up:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:redeploy (default-cli) on project rest-api: Artifact [com.acme.rest:rest-api:bundle] is not a dependency of the project. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:redeploy (default-cli) on project rest-api: Artifact [com.acme.rest:rest-api:bundle] is not a dependency of the project.
Deploying as component type "web" works, but then I can't use the OSGI bundles...
Does anybody have experience with deploying Web Application Bundle and OSGI bundles?
I don't know about cargo plugin, but to deploy a wab using asadmin client, one has to pass a --type=osgi option as shown below:
asadmin deploy --type=osgi foo.war
So, see if you can configure cargo plugin to pass this option.
Sahoo
The trick is :
<deployable>
<groupId>com.acme.rest</groupId>
<artifactId>rest-api</artifactId>
<type>war</type>
<implementation>org.codehaus.cargo.container.deployable.Bundle</implementation>
</deployable>
You still have a WAR artifact, but Bundle will trick Cargo to deploy it as OSGi.
Try using version 1.4.7 which added support for sending asadmin params in conjunction with the param that #Sahoo mentioned.
<cargo.glassfish.deploy.arg.1>--type=osgi foo.war</cargo.glassfish.deploy.arg.1>
Allow passing extra parameters for glassfish deployment
https://jira.codehaus.org/browse/CARGO-1245

JNLP: tools.jar not in the classpath

it's me again. And today, I'm facing kind of a weird problem. Either I didn't understand something correctly or I'm simply missing the forrest in front of the trees.
Following scenario:
I'm using JavaFX, bundled in JDK 1.7
I need both client runtimes: Desktop (jar) and Applet (jnlp inside the browser)
I have a maven project set up for the project
I have a parent pom and different sub modules
I need my client to communicate with a web service, that for I'v chosen CXF as framework (I need to be able to switch web services on runtime) for connecting to the web service
The 'connect to the web service stuff' is an own maven sub module called wsConnector
Here is some more environment information and my pom snippets:
mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Program Files (x86)\Apache\maven-3.0.4\bin\..
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_07\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
For being able to compile the wsConnector sub module, again which takes care about all the web service connection stuff, I need to integrate the tools.jar from the JDK as CXF needs that.
relevant properties from the parent pom.xml:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
...
</properties>
sub module pom.xml:
<properties>
<cxf.version>2.6.2</cxf.version>
</properties>
<dependencies>
<dependency>
... // some other sub modules
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>tools</artifactId>
<version>${maven.compiler.source}]</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
If I run mvn clean package, everything works fine and dandy. In the deploy directory of my client app (where the jar, generated HTML and jnlp file is also), I find the tools.jar, too.
If I have a look in the JNLP file, I find the entry:
<jar href="tools.jar" size="15226565" download="eager" />
Now my problem is: if I run the client with java -jar client.jar, everything works. But if I call the HTML / JNLP file, i get a ClassNotFoundException, pointing out that tools.jar is not on the classpath.
Therefore, it doesn't care if I open the applet from a server or localhost.
Here is the stacktrace:
java.lang.IllegalStateException: Unable to create schema compiler
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:694)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:303)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:270)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:263)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:198)
at com.multiguide.ws.WebServiceConnector.setWsdlUrl(WebServiceConnector.java:45)
at com.multiguide.ws.WebServiceConnector.setWsdlUrl(WebServiceConnector.java:31)
at com.multiguide.view.administration.WebServiceInformationPanel.connect(WebServiceInformationPanel.java:130)
at com.multiguide.view.administration.WebServiceInformationPanel.refresh(WebServiceInformationPanel.java:70)
at com.multiguide.view.administration.WebServiceInformationPanel.<init>(WebServiceInformationPanel.java:45)
at com.multiguide.view.administration.WebServiceInformationPanel$$FastClassByGuice$$da5f387e.newInstance(<generated>)
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
... 9 more
Caused by: javax.xml.bind.JAXBException - with linked exception:
java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompiler(JAXBUtils.java:679)
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:686)
... 49 more
Caused by:
java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompiler(JAXBUtils.java:672)
... 50 more
Is it a class loading issue as I'm using guice? Without this exception, the app is working like a charme. I can do all the web service stuff I need to do: connecting, switching URL, ... So I wouldn't expect that to be the reason.
Note besides: I think it doesn't matter here right now, but as I'm using guice, of course my JNLP file has the
<security>
</all-permissions>
</security>
flag.
Has anyone of you experiences with that? Maybe I really just miss a thing, but any help (as always ;) ) is highly appreciated :)
finally I got the tools.jar in the classpath. I figured out it was missing in the manifest of my jar-file I'm delivering and which contains my client application.
As this is a JavaFX application, I needed to add the tools.jar dependency within the classpath tag of the configuration of the manifest file of the client sub module:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
...
<Class-Path>jfxrt.jar tools.jar</Class-Path>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
After having tools.jar in the classpath, CXF tries to call the java compiler, see the error message:
org.apache.cxf.common.jaxb.JAXBUtils logGeneratedClassNames
INFO: Created classes: <list of my generated JAVA files from the wsdl file here>
[ERROR] IOException during exec() of compiler "javac". Check your path environment variable.
Okt 23, 2012 3:46:20 PM org.apache.cxf.endpoint.dynamic.DynamicClientFactory createClient
SEVERE: Could not compile java files for <url to wsdl file here>.
So this means for me that I would need to require having a JDK running and set up on a client machine. If I would serve the javac too (just a thought play don't blame me :) ), this would mean that I'd need to execute something on the client machine, which is a no-go for me.
That for, I will find an alternative solution for what I initially wanted (solution will be outsourcing the generate-ws-accessing-classes).
Though, for the initial question of how to integrate tools.jar in the classpath, what I've written above solved the problem for me.

Configuring Spring Batch with Maven

Configuring Spring Batch with Maven. JDK used: 1.6, Spring Batch version 2.1.8.RELEASE; Spring version 3.0.5.RELEASE. Getting run time exception as below:
D:\SpringProject\SpringTry\target>java -jar SpringTry-1.0-SNAPSHOT.jar jobs/helloWorld.xml helloWorldJob
2012-09-02 00:23:51,650 INFO [org.springframework.context.support.ClassPathXmlApplicationContext] - <Refreshing org.springframework.context.
support.ClassPathXmlApplicationContext#b29c9d: startup date [Sun Sep 02 00:23:51 IST 2012]; root of context hierarchy>
2012-09-02 00:23:51,769 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path
resource [jobs/helloWorld.xml]>
2012-09-02 00:23:53,854 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path
resource [launch-context.xml]>
2012-09-02 00:23:53,929 ERROR [org.springframework.batch.core.launch.support.CommandLineJobRunner] - <Job Terminated in error: Configuration
problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch]
Offending resource: class path resource [jobs/helloWorld.xml]
>
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler fo
r XML schema namespace [http://www.springframework.org/schema/batch]
Offending resource: class path resource [jobs/helloWorld.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
Any suggestion on how to resolve this. Also noticed that Spring 2.5.6 is getting downloaded everytime, along with version mentioned 3.0.5
My manifest looks like:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0
Main-Class: org.springframework.batch.core.launch.support.CommandLineJobRunner
Class-Path: lib/spring-batch-core-2.1.9.RELEASE.jar lib/xstream-1.3.jar lib/xpp3_min-1.1.4c.jar lib/jettison-1.1.jar lib/spring-aop-2.5.6.jar lib/aopalliance-1.0.jar lib/spring-tx-2.5.6.jar lib/spring-batch-infrastructure-2.1.9.RELEASE.jar lib/spring-beans-3.0.5.RELEASE.jar lib/spring-context-3.0.5.RELEASE.jar lib/spring-expression-3.0.5.RELEASE.jar lib/spring-asm-3.0.5.RELEASE.jar lib/spring-core-3.0.5.RELEASE.jar lib/commons-logging-1.1.1.jar lib/spring-jdbc-3.0.5.RELEASE.jar lib/log4j-1.2.16.jar lib/maven-resources-plugin-2.4.3.jar lib/maven-plugin-api-2.0.6.jar lib/maven-project-2.0.6.jar lib/maven-profile-2.0.6.jar lib/maven-artifact-manager-2.0.6.jar lib/maven-plugin-registry-2.0.6.jar lib/maven-core-2.0.6.jar lib/wagon-file-1.0-beta-2.jar lib/maven-plugin-parameter-documenter-2.0.6.jar lib/wagon-http-lightweight-1.0-beta-2.jar lib/wagon-http-shared-1.0-beta-2.jar lib/jtidy-4aug2000r7-dev.jar lib/xml-apis-1.0.b2.jar lib/maven-reporting-api-2.0.6.jar lib/doxia-sink-api-1.0-alpha-7.jar lib/wagon-provider-api-1.0-beta-2.jar lib/maven-repository-metadata-2.0.6.jar lib/maven-error-diagnostics-2.0.6.jar lib/commons-cli-1.0.jar lib/wagon-ssh-external-1.0-beta-2.jar lib/wagon-ssh-common-1.0-beta-2.jar lib/maven-plugin-descriptor-2.0.6.jar lib/plexus-interactivity-api-1.0-alpha-4.jar lib/wagon-ssh-1.0-beta-2.jar lib/jsch-0.1.27.jar lib/classworlds-1.1.jar lib/maven-artifact-2.0.6.jar lib/maven-settings-2.0.6.jar lib/maven-model-2.0.6.jar lib/maven-monitor-2.0.6.jar lib/plexus-container-default-1.0-alpha-9-stable-1.jar lib/junit-3.8.1.jar lib/plexus-utils-2.0.5.jar lib/maven-filtering-1.0-beta-4.jar lib/plexus-build-api-0.0.4.jar lib/plexus-interpolation-1.13.jar
Most probably you are either:
simply using a version of spring-batch-core jar (Maven dependency) which has version below 2.0. Schema naming works for version 2.0 and above. If it's the case, update your dependency
or
You have the correct (higher than 2.0) version of spring-batch-core in your project's pom.xml, but you also have a transitive dependency which brings into your project an earlier version of spring-batch-core. If that's the case, try the following:
mvn dependency:tree -Dverbose -Dincludes=org.springframework.batch
this will list all the dependencies that bring in their own version of spring-batch dependencies. Add an exclude entry on spring-batch-core for those dependencies, something like this:
<dependency>
<groupId>whatever.group</groupId>
<artifactId>whateverArtifact</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
</exclusion>
</exclusions>
</dependency>
My issue was resolved by adding maven-shade-plugin as detailed in the:
https://stackoverflow.com/a/8574629/1419116

maven jetty plugin log4j configuration

i have a java web app with maven.
i'm using jetty to run it during development (by using maven jetty plugin)
i've my log4j.properties file placed under src/main/resources and it is copied under WEB-INF/classes when deployed as expected.
in my log4j.properties file i defined a filter variable and when deployed it is also filtered with the real value.
in log4j.properties under src/main/resources;
log4j.appender.FILE.File = ${config-gui.log-file}
in log4j.properties under WEB-INF/classes (after deployed with filtering);
log4j.appender.FILE.File = /tmp/mylogfile.log
my problem is; i'm getting following error when i run mvn jetty:run
log4j:ERROR setFile(null,true) call failed.<br />
java.io.FileNotFoundException: (No such file or directory)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:289)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:163)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:215)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:132)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:96)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:654)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:612)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:509)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:415)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:441)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:88)
at com.pribas.bucherplayerconfiggui.util.LoggerUtil.getLogger(LoggerUtil.java:10)
at com.pribas.bucherplayerconfiggui.Initialization.<clinit>(Initialization.java:22)
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 java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.webapp.WebXmlConfiguration.newListenerInstance(WebXmlConfiguration.java:649)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:630)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:367)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initWebXmlElement(AbstractConfiguration.java:190)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initialize(AbstractConfiguration.java:133)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:222)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configure(AbstractConfiguration.java:113)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:180)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configureWebApp(AbstractConfiguration.java:96)
at org.mortbay.jetty.plus.webapp.Configuration.configureWebApp(Configuration.java:124)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1217)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:110)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo$1.filesChanged(AbstractJettyRunMojo.java:409)
at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:493)
at org.mortbay.util.Scanner.reportDifferences(Scanner.java:359)
at org.mortbay.util.Scanner.scan(Scanner.java:286)
at org.mortbay.util.Scanner$1.run(Scanner.java:246)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
i think this error is because of it sees log4j.properties file which is under src/main/resources (which has appender's file param is not acceptable) instead of under WEB-INF/classes one.
i want maven jetty plugin to ignore log4j.properties file which is under src/main/resources and sees the one under WEB-INF/classes.
how can i do this?
or if this error is not related the idea i have, how can i solve this?
thx in advance.
I think, you can hardly guarantee which of log4j.properties will be used on in your jar or in WEB-INF/classes. It depends on concrete classloader implementation (in Tomcat or Jetty) which can either see WEB-INF/classes/log4j.properties or WEB-INF/libs/yourlib.jar:/log4j.properties. So you need to filter here or there :)
Using maven profiles you can configure the <excludes> for your resources and use this profile for to build web application for Tomcat deployment.
Maybe better solution will be renaming /src/main/resources/log4j.properties to /src/main/resources/log4j-jetty.properties and then configure Log4j via jetty plugin to use that resource:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
...
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>log4j-jetty.properties</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>

Resources