Jay Roy
asked on
spring on unix box
hi guys
i have my spring-config.xml which goes like
I am using maven set up to load the libraries
The application runs fine from windows systems
however when i create a jar and try to run it from my unix box it throws error
in unix this is what ia m doing
$java -Denv=dev -jar $HOME/Customer.jar param1
Customer jar has
The error is
Any idea what is going wrong ? What i am confused is it works from Windows (when i run CustomerMain.java as java application) but it fails when run from unix.
Any idea why that is ?
thanks
i have my spring-config.xml which goes like
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd">
..<my beans...>
</beans:beans>
I am using maven set up to load the libraries
The application runs fine from windows systems
however when i create a jar and try to run it from my unix box it throws error
in unix this is what ia m doing
$java -Denv=dev -jar $HOME/Customer.jar param1
Customer jar has
public class CustomerMain{
...
public static void main(String args[]) {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-config.xml");
...
}
}
The error is
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from class path resource [spring-config.xml] is invalid;
nested exception is org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 110; cvc-elt.1: Cannot find the declaration of element 'beans:beans'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
Any idea what is going wrong ? What i am confused is it works from Windows (when i run CustomerMain.java as java application) but it fails when run from unix.
Any idea why that is ?
thanks
ASKER
>>And then Maven produces a JAR file of "your code"
actually I export the java project as a runnable jar.
(in eclipse) right click on project --export as --runnable jar
and in the unix box I do have a folder created called 'lib' and placed all the required jars there
and put those jars in the class path, I dont think its a problem with jars.
any other clue what could be the reason for the error on unix box?
thanks.
actually I export the java project as a runnable jar.
(in eclipse) right click on project --export as --runnable jar
and in the unix box I do have a folder created called 'lib' and placed all the required jars there
and put those jars in the class path, I dont think its a problem with jars.
any other clue what could be the reason for the error on unix box?
thanks.
Can you post your CLASSPATH here then? I still think it is a case where not ALL the dependencies are satisfied.
Looks like an internal xml inconsistency. I think you need to ensure you have exactly the same Spring version on each box to ensure problem-free portability
ASKER
well in my unix script i am doing
export LIB=$HOME/lib; #lib contains all the jars
for file in ${LIB}/*.* ; do CLASSPATH=$CLASSPATH:$file ; done
#and trying to run using
$java -Denv=dev -jar $HOME/Customer.jar param1
$java -cp $CLASSPATH -Denv=dev -jar $HOME/Customer.jar param1
but no luck
i think the jars are in classpath its some other issue.
export LIB=$HOME/lib; #lib contains all the jars
for file in ${LIB}/*.* ; do CLASSPATH=$CLASSPATH:$file
#and trying to run using
$java -Denv=dev -jar $HOME/Customer.jar param1
$java -cp $CLASSPATH -Denv=dev -jar $HOME/Customer.jar param1
but no luck
i think the jars are in classpath its some other issue.
Ah, ok, I can see another issue then. You cannot use the -jar option and set the classpath (either by -cp option or environment) at the same time. Try this...
Java -cp $CLASSPATH;$HOME/Customer. jar -Denv=dev CustomerMain param1
Note, if CustomerMain resides in a package, rather the in the default root package, you have to specify the fully qualified name above, ie. if it is in "cust.main" then you need to specify cust.main.CustomerMain in the command above.
Java -cp $CLASSPATH;$HOME/Customer.
Note, if CustomerMain resides in a package, rather the in the default root package, you have to specify the fully qualified name above, ie. if it is in "cust.main" then you need to specify cust.main.CustomerMain in the command above.
ASKER
hm i did that but getting
...
/cust/testing/customer/Cus tomer.jar param1
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<cl assname>]
-enableassertions[:<packag ename>...| :<classnam e>]
enable assertions with specified granularity
-da[:<packagename>...|:<cl assname>]
-disableassertions[:<packa gename>... |:<classna me>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
....
...
/cust/testing/customer/Cus
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<cl
-enableassertions[:<packag
enable assertions with specified granularity
-da[:<packagename>...|:<cl
-disableassertions[:<packa
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
....
ASKER
and this is my command
java -cp $CLASSPATH;$HOME/Customer. jar -Denv=dev com.test.CustomerMain param1
java -cp $CLASSPATH;$HOME/Customer.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
changed to
>>java -cp $CLASSPATH:$HOME/Customer. jar -Denv=dev com.test.CustomerMain param1
now it doesnt look like the main method is invoked.
>>java -cp $CLASSPATH:$HOME/Customer.
now it doesnt look like the main method is invoked.
What output did you get?
Please post output of
Please post output of
echo $CLASSPATH
ASKER
echo $CLASSPATH
.:/apps/com/cust/config::/ apps/com/c ust/lib/ac tivation-1 .1.jar:/ap ps/com/cus t/lib/aopa lliance-1. 0.jar:/app s/com/cust /lib/com.j ameria.ocp t.tmta-0.0 .1.jar:/ap ps/com/cus t/lib/comm ons-beanut ils-1.8.2. jar:/apps/ com/cust/l ib/commons -codec-1.5 .jar:/apps /com/cust/ lib/common s-collecti ons-3.2.1. jar:/apps/ com/cust/l ib/commons -dbcp-1.4. jar:/apps/ com/cust/l ib/commons -digester- 2.0.jar:/a pps/com/cu st/lib/com mons-io-2. 4.jar:/app s/com/cust /lib/commo ns-jexl-2. 0.1.jar:/a pps/com/cu st/lib/com mons-loggi ng-1.1.1.j ar:/apps/c om/cust/li b/commons- pool-1.5.4 .jar:/apps /com/cust/ lib/dom4j- 1.6.1.jar: /apps/com/ cust/lib/g eronimo-st ax-api_1.0 _spec-1.0. jar:/apps/ com/cust/l ib/jcl-ove r-slf4j-1. 7.3.jar:/a pps/com/cu st/lib/jet tison-1.1. jar:/apps/ com/cust/l ib/jms-1.1 .jar:/apps /com/cust/ lib/jmxri- 1.2.1.jar: /apps/com/ cust/lib/j mxtools-1. 2.1.jar:/a pps/com/cu st/lib/jtd s-1.2.5.ja r:/apps/co m/cust/lib /jxls-core -1.0-RC-2. jar:/apps/ com/cust/l ib/jxls-re ader-1.0-R C-2.jar:/a pps/com/cu st/lib/log 4j-1.2.15. jar:/apps/ com/cust/l ib/mail-1. 4.jar:/app s/com/cust /lib/ojdbc 14-10.2.0. 3.0.jar:/a pps/com/cu st/lib/poi -3.9.jar:/ apps/com/c ust/lib/po i-ooxml-3. 6.jar:/app s/com/cust /lib/poi-o oxml-schem as-3.6.jar :/apps/com /cust/lib/ slf4j-api- 1.7.3.jar: /apps/com/ cust/lib/s lf4j-log4j 12-1.7.4.j ar:/apps/c om/cust/li b/spring-a op-2.5.6.j ar:/apps/c om/cust/li b/spring-b atch-core- 2.1.9.RELE ASE.jar:/a pps/com/cu st/lib/spr ing-batch- infrastruc ture-2.1.9 .RELEASE.j ar:/apps/c om/cust/li b/spring-b eans-3.2.2 .RELEASE.j ar:/apps/c om/cust/li b/spring-c ontext-3.2 .2.RELEASE .jar:/apps /com/cust/ lib/spring -core-3.2. 2.RELEASE. jar:/apps/ com/cust/l ib/spring- expression -3.2.2.REL EASE.jar:/ apps/com/c ust/lib/sp ring-jdbc- 3.2.2.RELE ASE.jar:/a pps/com/cu st/lib/spr ing-suppor t-2.0.8.ja r:/apps/co m/cust/lib /spring-tx -3.2.2.REL EASE.jar:/ apps/com/c ust/lib/sq ljdbc4-3.0 .jar:/apps /com/cust/ lib/stax-a pi-1.0.1.j ar:/apps/c om/cust/li b/xml-apis -1.0.b2.ja r:/apps/co m/cust/lib /xmlbeans- 2.3.0.jar: /apps/com/ cust/lib/x pp3_min-1. 1.4c.jar:/ apps/com/c ust/lib/xs tream-1.3. jar:/apps/ com/cust/c onfig/dev/ *.*::/apps /com/cust/ lib/activa tion-1.1.j ar:/apps/c om/cust/li b/aopallia nce-1.0.ja r:/apps/co m/cust/lib /com.jamer ia.ocpt.tm ta-0.0.1.j ar:/apps/c om/cust/li b/commons- beanutils- 1.8.2.jar: /apps/com/ cust/lib/c ommons-cod ec-1.5.jar :/apps/com /cust/lib/ commons-co llections- 3.2.1.jar: /apps/com/ cust/lib/c ommons-dbc p-1.4.jar: /apps/com/ cust/lib/c ommons-dig ester-2.0. jar:/apps/ com/cust/l ib/commons -io-2.4.ja r:/apps/co m/cust/lib /commons-j exl-2.0.1. jar:/apps/ com/cust/l ib/commons -logging-1 .1.1.jar:/ apps/com/c ust/lib/co mmons-pool -1.5.4.jar :/apps/com /cust/lib/ dom4j-1.6. 1.jar:/app s/com/cust /lib/geron imo-stax-a pi_1.0_spe c-1.0.jar: /apps/com/ cust/lib/j cl-over-sl f4j-1.7.3. jar:/apps/ com/cust/l ib/jettiso n-1.1.jar: /apps/com/ cust/lib/j ms-1.1.jar :/apps/com /cust/lib/ jmxri-1.2. 1.jar:/app s/com/cust /lib/jmxto ols-1.2.1. jar:/apps/ com/cust/l ib/jtds-1. 2.5.jar:/a pps/com/cu st/lib/jxl s-core-1.0 -RC-2.jar: /apps/com/ cust/lib/j xls-reader -1.0-RC-2. jar:/apps/ com/cust/l ib/log4j-1 .2.15.jar: /apps/com/ cust/lib/m ail-1.4.ja r:/apps/co m/cust/lib /ojdbc14-1
.:/apps/com/cust/config::/
ASKER
ok this is getting printed in the logs
org.xml.sax.SAXParseExcept ion; lineNumber: 12; columnNumber: 110; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces. internal.u til.ErrorH andlerWrap per.create SAXParseEx ception(Er rorHandler Wrapper.ja va:198)
at com.sun.org.apache.xerces. internal.u til.ErrorH andlerWrap per.warnin g(ErrorHan dlerWrappe r.java:99)
org.xml.sax.SAXParseExcept
at com.sun.org.apache.xerces.
at com.sun.org.apache.xerces.
As i mentioned above, it looks like a misconfiguration of xml:
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
doesn't exist, so won't be resolvable. Check what it should be for your version of Spring
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
doesn't exist, so won't be resolvable. Check what it should be for your version of Spring
ASKER
hmmmm strange, i see that too, but it works from windows so i am confused
ASKER
i am using spring-beans-3.2.2.RELEASE .jar
I don't use Spring but in that vast classpath, it looks like you have a mixture of versions
2.0.8
2.1.9
2.5.6
3.2.2
unless various parts can vary in their versions
/apps/com/cust/lib/spring- aop-2.5.6. jar
/apps/com/cust/lib/spring- batch-core -2.1.9.REL EASE.jar
/apps/com/cust/lib/spring- batch-infr astructure -2.1.9.REL EASE.jar
/apps/com/cust/lib/spring- beans-3.2. 2.RELEASE. jar
/apps/com/cust/lib/spring- context-3. 2.2.RELEAS E.jar
/apps/com/cust/lib/spring- core-3.2.2 .RELEASE.j ar
/apps/com/cust/lib/spring- expression -3.2.2.REL EASE.jar
/apps/com/cust/lib/spring- jdbc-3.2.2 .RELEASE.j ar
/apps/com/cust/lib/spring- support-2. 0.8.jar
/apps/com/cust/lib/spring- tx-3.2.2.R ELEASE.jar
2.0.8
2.1.9
2.5.6
3.2.2
unless various parts can vary in their versions
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
/apps/com/cust/lib/spring-
ASKER
one quick quiestion
you said
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
doesnt exisit,
but it does point to a xsd file when i click on that link, right
you said
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
doesnt exisit,
but it does point to a xsd file when i click on that link, right
but it does point to a xsd file when i click on that link, rightYes, sorry. When i first tried it, the link was not found. Is now
Do you still get the same error?
Incidentally THIS suggests you had similar problems to me, since the third possible reason can be eliminated
Another question is this: if you're using 3.2.2, why isn't the schema link more like this?
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
ASKER
i changed 3.1 to 3.2 but still no luck
The same error comes up with 3.2 version aswell.
The same error comes up with 3.2 version aswell.
Yes, i'm not advocating that as a solution. It's more of a why
Can you tell me what this prints on the Unix box please?
Can you tell me what this prints on the Unix box please?
wget -q -O /dev/null http://www.springframework.org/schema/beans/spring-beans-3.1.xsd && echo -e '\x64\x6f\x77\x6e\x6c\x6f\x61\x64\x61\x62\x6c\x65'
ASKER
hi,,
$ wget -q -O /dev/null http://www.springframework.org/schema/beans/spring-beans-3.1.xsd && echo -e '\x64\x6f\x77\x6e\x6c\x6f\ x61\x64\x6 1\x62\x6c\ x65'
it just hangs
i dont see any output
$ wget -q -O /dev/null http://www.springframework.org/schema/beans/spring-beans-3.1.xsd && echo -e '\x64\x6f\x77\x6e\x6c\x6f\
it just hangs
i dont see any output
Sure it hangs and doesn't just return to the prompt?
If you're sure it hangs it looks like
a. you don't have a proper internet connection
or
b. you have not configured your proxy properly
IOW, we're looking at reasons 1) or 2) from the error message given to you
a. you don't have a proper internet connection
or
b. you have not configured your proxy properly
IOW, we're looking at reasons 1) or 2) from the error message given to you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In my last post I gave a few things to try, which one fixed your problem? Just out of interest?
ASKER
i was reinventing the wheel by creating a new jar on my own by exporting the project as a jar. What i dint know was maven was also creating a jar.
Once i started using the jar which maven created , i did not find any of the above classpath issues.
thanks.
Once i started using the jar which maven created , i did not find any of the above classpath issues.
thanks.
Here's my thoughts on whats happening... On your Windows box, when you say that it is working, you are actually running it via your development environment (eg. Eclipse, Netbeans, IntelliJ, etc). And then Maven produces a JAR file of "your code" which you copy to unix and it fails to run there. The problem then is that on Unix you don't have all the other JAR's that you need, ie. Spring, and all its dependencies, and hence the error message.