ellandrd
asked on
Error Reading File
up to a few days ago my application worked like a treat. ive spend the last fews days create .EXE .JNLP files, and writing README files for it.
Now today - just for one last clean and build before I package it, im getting this "cannot compile stylesheet" error.
I havnt changed anything to brake it but for some reason it isnt working anymore...
ive build a simple RSS feed based on swing components.
I have my XSL file in a folder called "etc"
here is a run down of my structure:
newsreader
|----build
|----docs
|----dist
|----etc
|----src
|----test
the actual error im getting is:
run:
ERROR: 'C:\newsreader\build\class es\etc\rss .xsl (The system cannot find the path specified)'
FATAL ERROR: 'Could not compile stylesheet'
BUILD SUCCESSFUL (total time: 4 seconds)
how i read my file in RSSContentPane.java:
try {
File file = new File( "etc/rss.xsl" ) ;
this.rssSource = new URL( this.selectedRSSFeed ) ;
this.xslSource = file.toURL() ;
this.writer = new StringWriter() ;
this.rssTransformer = new RSSTransformer() ;
this.rssTransformer.proces s( this.rssSource, this.xslSource, this.writer ) ;
this.setText( this.writer.getBuffer().to String() ) ;
this.html.setCaretPosition ( 0 ) ;
} catch( MalformedURLException e ) {
JOptionPane.showMessageDia log( null, e.toString(), "News Reader (RSS)", JOptionPane.ERROR_MESSAGE ) ;
System.exit( 0 ) ;
} catch ( TransformerException e ) {
JOptionPane.showMessageDia log( null, e.toString(), "News Reader (RSS)", JOptionPane.ERROR_MESSAGE ) ;
} catch ( IOException e ) {
JOptionPane.showMessageDia log( null, e.toString(), "News Reader (RSS)", JOptionPane.ERROR_MESSAGE ) ;
System.exit( 0 ) ;
}
transformer.java code:
public class RSSTransformer {
private TransformerFactory factory;
/** Creates a new instance of RSSTransformer */
public RSSTransformer() {
factory = TransformerFactory.newInst ance();
}
public void process( URL url, URL xsl, Writer out ) throws TransformerException {
try {
Templates template = factory.newTemplates( new StreamSource( xsl.toExternalForm() ) );
Transformer transformer = template.newTransformer();
transformer.transform( new StreamSource( url.toExternalForm() ), new StreamResult( out ) );
} catch ( TransformerConfigurationEx ception e ) {
JOptionPane.showMessageDia log( null, "Your RSS source was not valid" , "News Reader (RSS)", JOptionPane.ERROR_MESSAGE );
} catch ( TransformerException e ) {
JOptionPane.showMessageDia log( null, "Your RSS source was not valid" , "News Reader (RSS)", JOptionPane.ERROR_MESSAGE );
}
}
}
if you need more code please ask...
ps. this is urgent!
Now today - just for one last clean and build before I package it, im getting this "cannot compile stylesheet" error.
I havnt changed anything to brake it but for some reason it isnt working anymore...
ive build a simple RSS feed based on swing components.
I have my XSL file in a folder called "etc"
here is a run down of my structure:
newsreader
|----build
|----docs
|----dist
|----etc
|----src
|----test
the actual error im getting is:
run:
ERROR: 'C:\newsreader\build\class
FATAL ERROR: 'Could not compile stylesheet'
BUILD SUCCESSFUL (total time: 4 seconds)
how i read my file in RSSContentPane.java:
try {
File file = new File( "etc/rss.xsl" ) ;
this.rssSource = new URL( this.selectedRSSFeed ) ;
this.xslSource = file.toURL() ;
this.writer = new StringWriter() ;
this.rssTransformer = new RSSTransformer() ;
this.rssTransformer.proces
this.setText( this.writer.getBuffer().to
this.html.setCaretPosition
} catch( MalformedURLException e ) {
JOptionPane.showMessageDia
System.exit( 0 ) ;
} catch ( TransformerException e ) {
JOptionPane.showMessageDia
} catch ( IOException e ) {
JOptionPane.showMessageDia
System.exit( 0 ) ;
}
transformer.java code:
public class RSSTransformer {
private TransformerFactory factory;
/** Creates a new instance of RSSTransformer */
public RSSTransformer() {
factory = TransformerFactory.newInst
}
public void process( URL url, URL xsl, Writer out ) throws TransformerException {
try {
Templates template = factory.newTemplates( new StreamSource( xsl.toExternalForm() ) );
Transformer transformer = template.newTransformer();
transformer.transform( new StreamSource( url.toExternalForm() ), new StreamResult( out ) );
} catch ( TransformerConfigurationEx
JOptionPane.showMessageDia
} catch ( TransformerException e ) {
JOptionPane.showMessageDia
}
}
}
if you need more code please ask...
ps. this is urgent!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cool ok...
ASKER
see using Absolute path, where would i start it from? newsreader or my c:\?
how are you running it?
if you add your etc directory to your class path you can use the following:
this.xslSource = getClass().getResource("rs s.xsl");
you then don't need to create that file instance at all
this.xslSource = getClass().getResource("rs
you then don't need to create that file instance at all
ASKER
Standalone application - im planning of distributing it by webstart...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>if you add your etc directory to your class path....
see when people do this, will this be for the whole of netbeans or just this project?
see when people do this, will this be for the whole of netbeans or just this project?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If using Webstart, option b. in my comment is best
ASKER
>>then add the etc directory into your jar, and use:
not sure how i do this?
do i have to change my build.xml? i have already customised this build.xml...
not sure how i do this?
do i have to change my build.xml? i have already customised this build.xml...
ASKER
actually on saying that, the only thing ive changed since it has been all working is my build.xml file...
what to see it?
what to see it?
>>do i have to change my build.xml?
Not sure, but if you have one, i'm surprised your resources are not already there. Please post output of
jar tf yourjar.jar
Not sure, but if you have one, i'm surprised your resources are not already there. Please post output of
jar tf yourjar.jar
>>what to see it?
I assume you mean *want* to see it. Not yet ;-)
I assume you mean *want* to see it. Not yet ;-)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i get "jar" not recognised
ASKER
objects
i want to load it from the jar... there will be no copying of files to users disk...
it will be either an jar file wrapped in .exe or an jnlp file for webstart...
i want to load it from the jar... there will be no copying of files to users disk...
it will be either an jar file wrapped in .exe or an jnlp file for webstart...
the build is using a base diretcory of:
C:\newsreader\build\classe s\
it should be:
C:\newsreader
C:\newsreader\build\classe
it should be:
C:\newsreader
> i want to load it from the jar... there will be no copying of files to users disk...
then do as I suggested above :)
then do as I suggested above :)
the code you have currently won't work with the xsl in the jar, you need to change it
ASKER
im not sure:
here is how is set up some properties in my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="NewsReader" default="run" basedir=".">
<import file="nbproject/build-impl .xml"/>
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build /classes"/ >
<property name="project.source" location="${basedir}/src/" />
<property name="project.etc" location="${basedir}/etc/" />
<property name="project.documentatio n" location="${basedir}/doc/" />
<property name="project.main.class" value="u0207372.NRStandalo ne"/>
...
do you mean just have:
<property name="project.build" location="${basedir}/build "/>
?
here is how is set up some properties in my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="NewsReader" default="run" basedir=".">
<import file="nbproject/build-impl
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build
<property name="project.source" location="${basedir}/src/"
<property name="project.etc" location="${basedir}/etc/"
<property name="project.documentatio
<property name="project.main.class" value="u0207372.NRStandalo
...
do you mean just have:
<property name="project.build" location="${basedir}/build
?
moving the xsl into your jar will mean you don't need to change the build as you will no longer need the line that is giving you the error
this:
File file = new File( "etc/rss.xsl" ) ;
this.rssSource = new URL( this.selectedRSSFeed ) ;
this.xslSource = file.toURL() ;
becomes just:
this.rssSource = new URL( this.selectedRSSFeed ) ;
this.xslSource = getClass().getResource("/e tc/rss.xsl ");
File file = new File( "etc/rss.xsl" ) ;
this.rssSource = new URL( this.selectedRSSFeed ) ;
this.xslSource = file.toURL() ;
becomes just:
this.rssSource = new URL( this.selectedRSSFeed ) ;
this.xslSource = getClass().getResource("/e
ASKER
ok but im not too sure how i add te xsl file or this etc folder into the jar file?
add the directory to the file list in your jar build target
Please post the output of
jar tf yourjar.jar
jar tf yourjar.jar
ASKER
>>Date: 03/23/2006 10:56AM GMT
Oh, OK. You need to add %JAVA_HOME%\bin to your path
(Creating the variable JAVA_HOME [the installation directory of your JDK] first if necessary)
theres no need to run jar :)
ASKER
ok guys - the two of ye telling me to do different things isnt helping!
i want my application to run off a exe or jnlp - there will be no copying of files onto users disks.
CEHJ
i cant get jar to work...
Objects
>>add the directory to the file list in your jar build target
im stuck here with this... i never added file list to jar so i dont know what im doing...
what ive got is:
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl .xml"/>
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build /classes"/ >
<property name="project.source" location="${basedir}/src/" />
<property name="project.etc" location="${basedir}/etc/" />
<property name="project.documentatio n" location="${basedir}/doc/" />
<property name="project.main.class" value="u0207372.NRStandalo ne"/>
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build} "/>
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main. class}" fork="true" classpath="project.classpa th" dir="${basedir}/build/clas ses">
</java>
</target>
...
i want my application to run off a exe or jnlp - there will be no copying of files onto users disks.
CEHJ
i cant get jar to work...
Objects
>>add the directory to the file list in your jar build target
im stuck here with this... i never added file list to jar so i dont know what im doing...
what ive got is:
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build
<property name="project.source" location="${basedir}/src/"
<property name="project.etc" location="${basedir}/etc/"
<property name="project.documentatio
<property name="project.main.class" value="u0207372.NRStandalo
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build}
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}"
</javac>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main.
</java>
</target>
...
>>i cant get jar to work...
That should be done - a Java developer should always be able to run jar ;-)
>>>>add the directory to the file list in your jar build target
It's already added
That should be done - a Java developer should always be able to run jar ;-)
>>>>add the directory to the file list in your jar build target
It's already added
xslSource = getResource("etc/rss.xsl" ) ;
Since it's already added, the above should work
Since it's already added, the above should work
Sorry
xslSource = getResource("/etc/rss.xsl" ) ;
xslSource = getResource("/etc/rss.xsl"
ASKER
method getResource not found?
in your case it would be something like:
<jar destfile="${basedir}/rssre ader.jar">
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
add that to your build target (or you can make it seperate if yuou want)
<jar destfile="${basedir}/rssre
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
add that to your build target (or you can make it seperate if yuou want)
Sorry - not quite awake
getClass().getResource(... .......... .......... .........
getClass().getResource(...
> method getResource not found?
see what I suggested earlier.
using the above build it would be:
this.xslSource = getClass().getResource("rs s.xsl");
see what I suggested earlier.
using the above build it would be:
this.xslSource = getClass().getResource("rs
ASKER
like this
<!-- compile the application -->
<target name="build" description="--> compile the application">
<jar destfile="${basedir}/dist/ rssreader. jar">
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
</target>
?
also this:
this.xslSource = this.getClass().getResourc e( "/etc/rss.xsl" ) ;
gives me a null pointer...
i have tired too:
this.xslSource = this.getClass().getResourc e( "etc/rss.xsl" ) ;
still null pointer...
<!-- compile the application -->
<target name="build" description="--> compile the application">
<jar destfile="${basedir}/dist/
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
<javac srcdir="${basedir}/src/" destdir="${project.build}"
</javac>
</target>
?
also this:
this.xslSource = this.getClass().getResourc
gives me a null pointer...
i have tired too:
this.xslSource = this.getClass().getResourc
still null pointer...
>>like this
No - you need to compile it before you jar it
No - you need to compile it before you jar it
see my comment above:
this.xslSource = this.getClass().getResourc e( "rss.xsl" ) ;
and move the builkding of jar, *after* the jjavac
this.xslSource = this.getClass().getResourc
and move the builkding of jar, *after* the jjavac
ASKER
still get null pointer!
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
<jar destfile="${basedir}/rssre ader.jar">
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
</target>
in my RSSContentPane, ive got:
URL xslSource = getClass().getResource( "rss.xsl" ) ;
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}"
</javac>
<jar destfile="${basedir}/rssre
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
</target>
in my RSSContentPane, ive got:
URL xslSource = getClass().getResource( "rss.xsl" ) ;
sorry, should have been:
URL xslSource = getClass().getResource( "/rss.xsl" ) ;
URL xslSource = getClass().getResource( "/rss.xsl" ) ;
ASKER
i'd love to say it working but im still getting this:
run:
Exception in thread "main" java.lang.NullPointerExcep tion
at u0207372.gui.RSSContentPan el.updateR SSNews(RSS ContentPan el.java:66 )
at u0207372.gui.RSSContentPan el.<init>( RSSContent Panel.java :52)
at u0207372.NRStandalone.<ini t>(NRStand alone.java :27)
at u0207372.NRStandalone.main (NRStandal one.java:4 6)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
run:
Exception in thread "main" java.lang.NullPointerExcep
at u0207372.gui.RSSContentPan
at u0207372.gui.RSSContentPan
at u0207372.NRStandalone.<ini
at u0207372.NRStandalone.main
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
ASKER
see when i added these lines of code:
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
<jar destfile="${basedir}/rssre ader.jar">
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
</target>
should this have created a rssreader.jar in the base dir?
because it dont!
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}"
</javac>
<jar destfile="${basedir}/rssre
<fileset dir="${project.build}" />
<fileset dir="${project.etc}"/>
</jar>
</target>
should this have created a rssreader.jar in the base dir?
because it dont!
forgot to change the run target :)
it needs to include the jar in the classpath instead of the classes onm disk
it needs to include the jar in the classpath instead of the classes onm disk
> should this have created a rssreader.jar in the base dir?
yes it should have, did u run the build target?
if so, what was the output?
yes it should have, did u run the build target?
if so, what was the output?
<java classname="${project.main. class}" fork="true" classpath="${basedir}/rssr eader.jar" dir="${basedir}">
>><fileset dir="${project.etc}"/>
Rather than the above, you'd be better with
<fileset dir="${basedir}"/>
<!-- keep logical separation intact and include what's necessary -->
<include name="etc/**" />
</fileset>
Rather than the above, you'd be better with
<fileset dir="${basedir}"/>
<!-- keep logical separation intact and include what's necessary -->
<include name="etc/**" />
</fileset>
ASKER
>>yes it should have, did u run the build target?
>>if so, what was the output?
build:
Building jar: C:\rssreader\rssreader.jar
BUILD SUCCESSFUL (total time: 0 seconds)
but not jar file though!
>>it needs to include the jar in the classpath instead of the classes onm disk
in here:
<path id="project.classpath">
<pathelement location="${project.build} "/>
</path>
>>if so, what was the output?
build:
Building jar: C:\rssreader\rssreader.jar
BUILD SUCCESSFUL (total time: 0 seconds)
but not jar file though!
>>it needs to include the jar in the classpath instead of the classes onm disk
in here:
<path id="project.classpath">
<pathelement location="${project.build}
</path>
see my comment above
ASKER
ok objects ive added that line you gave me in here:
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main. class}" fork="true" classpath="${basedir}/rssr eader.jar" dir="${basedir}">
</java>
</target>
im sorry after i refreshed my folder, the jar appeared... in the base dir
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main.
</java>
</target>
im sorry after i refreshed my folder, the jar appeared... in the base dir
ASKER
im still getting this null pointer...
dont know what ive got wrong?
URL xslSource = getClass().getResource( "/rss.xsl" ) ;
in my build.xml file i ahve this:
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl .xml"/>
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build /classes"/ >
<property name="project.source" location="${basedir}/src/" />
<property name="project.etc" location="${basedir}/etc/" />
<property name="project.documentatio n" location="${basedir}/doc/" />
<property name="project.main.class" value="u0207372.NRStandalo ne"/>
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build} "/>
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
<jar destfile="${basedir}/rssre ader.jar">
<fileset dir="${project.build}" />
<fileset dir="${project.etc}" includes="**/*.xsl"/>
</jar>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main. class}" fork="true" classpath="${basedir}/rssr eader.jar" dir="${basedir}/build/clas ses" />
</target>
.....
dont know what ive got wrong?
URL xslSource = getClass().getResource( "/rss.xsl" ) ;
in my build.xml file i ahve this:
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build
<property name="project.source" location="${basedir}/src/"
<property name="project.etc" location="${basedir}/etc/"
<property name="project.documentatio
<property name="project.main.class" value="u0207372.NRStandalo
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build}
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}"
</javac>
<jar destfile="${basedir}/rssre
<fileset dir="${project.build}" />
<fileset dir="${project.etc}" includes="**/*.xsl"/>
</jar>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main.
</target>
.....
ASKER
i hate when people dont reply ;-)
List the jar
jar tf rssreader.jar
, using the full path to jar.exe if necessary
jar tf rssreader.jar
, using the full path to jar.exe if necessary
ASKER
the output is:
META-INF
u0207372
rss.xsl
META-INF
u0207372
rss.xsl
ASKER
so the rss.xsl is been added the the jar, but after that i dont know what im doing esp playing around with the build.xml...
There's no application in there! - Just two directories and your xsl file
ASKER
what do you mean?
what is mean to be in there?
what is mean to be in there?
All your classes. Can you post the output of
dir build/classes /s/b
dir build/classes /s/b
Sorry - that was meant to be
All your classes. Can you post the output of
dir build\classes /s/b
All your classes. Can you post the output of
dir build\classes /s/b
ASKER
it contains all my .class files
Please post output
ASKER
you still there? when you go offline tell me...
Yes
ASKER
just so you know im getting nowhere!
ive just spend last 2 hours getting nowhere..
lets just get this working and no messing about - e.g 1 liner comments - ive never played about the build.xml before so therefore ive not got a clue what im doing!
ive just spend last 2 hours getting nowhere..
lets just get this working and no messing about - e.g 1 liner comments - ive never played about the build.xml before so therefore ive not got a clue what im doing!
Going off for few minutes
*You* must do what i ask then - so far you haven't ;-) Back soon
ASKER
ok lets start from stratch.
here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="NewsReader" default="build" basedir=".">
<import file="nbproject/build-impl .xml"/>
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build /classes"/ >
<property name="project.source" location="${basedir}/src/" />
<property name="project.etc" location="${basedir}/etc/" />
<property name="project.documentatio n" location="${basedir}/doc/" />
<property name="project.main.class" value="u0207372.NRStandalo ne"/>
<path id="project.classpath">
<!--pathelement location="${project.build} "/-->
<pathelement location="${basedir}/dist/ newsreader .jar"/>
</path>
<!-- build the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
<jar destfile="${basedir}/dist/ newsreader .jar" basedir="${project.build}" update="false">
<fileset dir="${project.etc}"/>
<manifest>
<attribute name="Built-By" value="u0207372"/>
<attribute name="Main-Class" value="${project.main.clas s}"/>
<attribute name="Specification-Title" value="${ant.project.name} "/>
</manifest>
</jar>
</target>
<!-- run the application -->
<target name="run" depends="build" description="--> run the application">
<java classname="${project.main. class}" classpathref="project.clas spath" fork="true">
</java>
<jar destfile="${basedir}/dist/ newsreader .jar" basedir="${project.build}" update="false">
<fileset dir="${project.etc}"/>
<manifest>
<attribute name="Built-By" value="u0207372"/>
<attribute name="Main-Class" value="${project.main.clas s}"/>
<attribute name="Specification-Title" value="${ant.project.name} "/>
</manifest>
</jar>
</target>
<!-- clean the application -->
<target name="clean" description="--> clean">
<delete>
<fileset dir="${project.build}" includes="**.*"/>
</delete>
</target>
</project>
when i build i get the XSL file and build/classess put into the JAR file.
when i run i get:
build:
run:
Exception in thread "main" java.lang.NullPointerExcep tion
at u0207372.RSSTransformer.pr ocess(RSST ransformer .java:30)
at u0207372.gui.RSSContentPan el.updateR SSNews(RSS ContentPan el.java:65 )
at u0207372.gui.RSSContentPan el.<init>( RSSContent Panel.java :52)
at u0207372.NRStandalone.<ini t>(NRStand alone.java :27)
at u0207372.NRStandalone.main (NRStandal one.java:4 6)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Now i know the XSL file is in the JAR as when i extend my JAR i can see it along with my u0207372/build/classes.
the u0207372/build/classes contains:
gui/RSSContentPane.class
gui/RSSInput.class
gui/RSSList.class
NRStandalone.class
RSSTransformer.class
in my RSSContentPane.java I have this:
URL xslSource = this.getClass().getResourc e( "/rss.xsl" ) ;
if you need anything else - just ask
here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="NewsReader" default="build" basedir=".">
<import file="nbproject/build-impl
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build
<property name="project.source" location="${basedir}/src/"
<property name="project.etc" location="${basedir}/etc/"
<property name="project.documentatio
<property name="project.main.class" value="u0207372.NRStandalo
<path id="project.classpath">
<!--pathelement location="${project.build}
<pathelement location="${basedir}/dist/
</path>
<!-- build the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src" destdir="${project.build}"
</javac>
<jar destfile="${basedir}/dist/
<fileset dir="${project.etc}"/>
<manifest>
<attribute name="Built-By" value="u0207372"/>
<attribute name="Main-Class" value="${project.main.clas
<attribute name="Specification-Title"
</manifest>
</jar>
</target>
<!-- run the application -->
<target name="run" depends="build" description="--> run the application">
<java classname="${project.main.
</java>
<jar destfile="${basedir}/dist/
<fileset dir="${project.etc}"/>
<manifest>
<attribute name="Built-By" value="u0207372"/>
<attribute name="Main-Class" value="${project.main.clas
<attribute name="Specification-Title"
</manifest>
</jar>
</target>
<!-- clean the application -->
<target name="clean" description="--> clean">
<delete>
<fileset dir="${project.build}" includes="**.*"/>
</delete>
</target>
</project>
when i build i get the XSL file and build/classess put into the JAR file.
when i run i get:
build:
run:
Exception in thread "main" java.lang.NullPointerExcep
at u0207372.RSSTransformer.pr
at u0207372.gui.RSSContentPan
at u0207372.gui.RSSContentPan
at u0207372.NRStandalone.<ini
at u0207372.NRStandalone.main
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
Now i know the XSL file is in the JAR as when i extend my JAR i can see it along with my u0207372/build/classes.
the u0207372/build/classes contains:
gui/RSSContentPane.class
gui/RSSInput.class
gui/RSSList.class
NRStandalone.class
RSSTransformer.class
in my RSSContentPane.java I have this:
URL xslSource = this.getClass().getResourc
if you need anything else - just ask
Is there a package specified in NRStandalone.java?
ASKER
package u0207372 ;
ASKER
is there a way we could copy all the etc folder into the jar file instead of just the rss.xsl?
OK. Can you please copy and paste (i include the prompt below) the output of
C:\whatever\build\classes> dir /s/b
?
C:\whatever\build\classes>
?
>> is there a way we could copy all the etc folder into the jar file instead of just the rss.xsl?
Yes, i mentioned that earlier, but forget that for the moment - there seem to be more fundamental issues wrong
Yes, i mentioned that earlier, but forget that for the moment - there seem to be more fundamental issues wrong
ASKER
C:\newsreader\build\classe s>dir /s/b
C:\newsreader\build\classe s\u0207372
C:\newsreader\build\classe s\u0207372 \gui
C:\newsreader\build\classe s\u0207372 \NRStandal one.class
C:\newsreader\build\classe s\u0207372 \RSSTransf ormer.clas s
C:\newsreader\build\classe s\u0207372 \gui\RSSCo ntentPanel .class
C:\newsreader\build\classe s\u0207372 \gui\RSSIn put$1.clas s
C:\newsreader\build\classe s\u0207372 \gui\RSSIn put.class
C:\newsreader\build\classe s\u0207372 \gui\RSSLi st$1.class
C:\newsreader\build\classe s\u0207372 \gui\RSSLi st.class
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
C:\newsreader\build\classe
OK - not as bad as i thought. BACK THE ORIGINAL UP and try the following. You'll need to load the xsl file as i originally mentioned (after my self-correction)
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl .xml"/>
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build /classes"/ >
<property name="project.source" location="${basedir}/src/" />
<property name="project.etc" location="${basedir}/etc/" />
<property name="project.documentatio n" location="${basedir}/doc/" />
<property name="project.main.class" value="u0207372.NRStandalo ne"/>
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build} "/>
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref="project.clas spath" debug="on">
</javac>
<jar basedir="${basedir}" destfile="${basedir}/rssre ader.jar">
<manifest>
<attribute name="Main-Class" value="${project.main.clas s}"/>
</manifest>
<fileset dir="${project.build}">
<include name="**/*.class" />
</fileset>
<fileset dir="${basedir}"/>
<!-- keep logical separation intact and include what's necessary -->
<include name="etc/**/*.xsl" />
</fileset>
</jar>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main. class}" fork="true" classpath="${basedir}/rssr eader.jar" dir="${basedir}/build/clas ses" />
</target>
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build
<property name="project.source" location="${basedir}/src/"
<property name="project.etc" location="${basedir}/etc/"
<property name="project.documentatio
<property name="project.main.class" value="u0207372.NRStandalo
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build}
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}"
</javac>
<jar basedir="${basedir}" destfile="${basedir}/rssre
<manifest>
<attribute name="Main-Class" value="${project.main.clas
</manifest>
<fileset dir="${project.build}">
<include name="**/*.class" />
</fileset>
<fileset dir="${basedir}"/>
<!-- keep logical separation intact and include what's necessary -->
<include name="etc/**/*.xsl" />
</fileset>
</jar>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java classname="${project.main.
</target>
The end of what i just posted is missing the closing </project> tag
Also, replace the java task with the following:
<java jar="rssreader.jar" fork="true" dir="${basedir}" />
Also, replace the java task with the following:
<java jar="rssreader.jar" fork="true" dir="${basedir}" />
ASKER
>>You'll need to load the xsl file as i originally mentioned (after my self-correction)
as in: 03/23/2006 11:56AM GMT
as in: 03/23/2006 11:56AM GMT
ASKER
>>Also, replace the java task with the following:
>><java jar="rssreader.jar" fork="true" dir="${basedir}" />
eh? lost
>><java jar="rssreader.jar" fork="true" dir="${basedir}" />
eh? lost
>>eh? lost
Use that instead of
<java classname="${project.main. class}" fork="true" classpath="${basedir}/rssr eader.jar" dir="${basedir}/build/clas ses" />
Use that instead of
<java classname="${project.main.
ASKER
i get this:
build:
Building jar: C:\newsreader\dist\newsrea der.jar
C:\newsreader\build.xml:23 : A zip file cannot include itself
BUILD FAILED (total time: 1 second)
Now i have not added: <java jar="rssreader.jar" fork="true" dir="${basedir}" /> as i dont know where it goes...
build:
Building jar: C:\newsreader\dist\newsrea
C:\newsreader\build.xml:23
BUILD FAILED (total time: 1 second)
Now i have not added: <java jar="rssreader.jar" fork="true" dir="${basedir}" /> as i dont know where it goes...
>>as i dont know where it goes...
It goes where i said - in place of where the previous java task was
It goes where i said - in place of where the previous java task was
ASKER
run:
java.lang.NoClassDefFoundE rror: u0207372/NRStandalone
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
java.lang.NoClassDefFoundE
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
jar tf rssreader.jar
output please
output please
ASKER
newsreader
META-INF
build
dist
doc
etc
nbproject
src
test
NewsReader.jnlp
applet.policy
build.xml
manifest.mf
readme.html
run.bat
META-INF
build
dist
doc
etc
nbproject
src
test
NewsReader.jnlp
applet.policy
build.xml
manifest.mf
readme.html
run.bat
If that's really the jar listing again it's got nothing of interest in it. That doesn't look like it was produced with the build xml i've just given you. Better post the output of
type build.xml
type build.xml
ASKER
C:\newsreader>type build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl .xml"/>
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build /classes"/ >
<property name="project.source" location="${basedir}/src/" />
<property name="project.etc" location="${basedir}/etc/" />
<property name="project.documentatio n" location="${basedir}/doc/" />
<property name="project.main.class" value="u0207372.NRStandalo ne"/>
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build} "/>
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}" classpathref=
"project.classpath" debug="on">
</javac>
<jar basedir="${basedir}" destfile="${basedir}/dist/ newsreader .jar">
<manifest>
<attribute name="Main-Class" value="${project.main.clas s}"/>
</manifest>
<fileset dir="${project.build}">
<include name="**/*.class" />
</fileset>
<fileset dir="${basedir}">
<include name="etc/**/*.xsl" />
</fileset>
</jar>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java jar="${basedir}/dist/newsr eader.jar" fork="true" dir="${basedir}/b
uild/classes" />
<!--java classname="${project.main. class}" fork="true" classpath="${base
dir}/dist/newsreader.jar" dir="${basedir}/build/clas ses" /-->
</target>
</project>
C:\newsreader>
<?xml version="1.0" encoding="UTF-8"?>
<project name="RSSReader" default="run" basedir=".">
<import file="nbproject/build-impl
<!-- define some useful properties -->
<property name="project.build" location="${basedir}/build
<property name="project.source" location="${basedir}/src/"
<property name="project.etc" location="${basedir}/etc/"
<property name="project.documentatio
<property name="project.main.class" value="u0207372.NRStandalo
<!-- define a classpath and attach a reference to it -->
<path id="project.classpath">
<pathelement location="${project.build}
</path>
<!-- compile the application -->
<target name="build" description="--> compile the application">
<javac srcdir="${basedir}/src/" destdir="${project.build}"
"project.classpath" debug="on">
</javac>
<jar basedir="${basedir}" destfile="${basedir}/dist/
<manifest>
<attribute name="Main-Class" value="${project.main.clas
</manifest>
<fileset dir="${project.build}">
<include name="**/*.class" />
</fileset>
<fileset dir="${basedir}">
<include name="etc/**/*.xsl" />
</fileset>
</jar>
</target>
<!-- run the application -->
<target name="run" description="--> run the application">
<java jar="${basedir}/dist/newsr
uild/classes" />
<!--java classname="${project.main.
dir}/dist/newsreader.jar" dir="${basedir}/build/clas
</target>
</project>
C:\newsreader>
OK - looks like the output file has now changed, can you post the output of
jar tf dist\newsreader.jar
jar tf dist\newsreader.jar
ASKER
it working!!!!! yes - can eat now - havnt eaten since 6.30 dismorning...
ASKER
kinda need to pull myself from outta this chair now...
cheers for the help..
just wanna do one more test before accepting....
cheers for the help..
just wanna do one more test before accepting....
ASKER
ok ive tried to add my package target and sign-jar target and im getting this:
jarsigner: unable to sign jar: java.util.zip.ZipException : duplicate entry: etc/rss.xsl
C:\newsreader\build.xml:57 : The following error occurred while executing this line:
C:\newsreader\build.xml:72 : exec returned: 1
BUILD FAILED (total time: 0 seconds)
maybe i have it done wrong - i trying to have the same as what you had for build...
here is my code:
<!-- package the application -->
<target name="package" depends="build" description="--> create distribution">
<jar destfile="NewsReaderApp.ja r" basedir="${basedir}" update="false">
<fileset dir="${basedir}">
<include name="etc/**" />
</fileset>
<manifest>
<attribute name="Built-By" value="u0207372"/>
<attribute name="Main-Class" value="${project.main.clas s}"/>
<attribute name="Specification-Title" value="${ant.project.name} "/>
</manifest>
</jar>
<!-- Signing is normally only required for extended permissions
and integrity checks. If not, delete the next line and the associated target. -->
<antcall target="sign-jar">
</antcall>
</target>
<!-- sign the application -->
<target name="sign-jar">
<!-- check if a keystore file is required -->
<condition property="keystore.missing ">
<not>
<available file="${basedir}/etc/u0207 372Store">
</available>
</not>
</condition>
<antcall target="generate-keystore" >
</antcall>
<signjar jar="NewsReaderApp.jar" keystore="${basedir}/etc/u 0207372Sto re" alias="u0207372Sign" signedjar="SignedNewsReade rApp.jar" storepass="lqv78" keypass="lqv78" verbose="true">
</signjar>
</target>
<!-- Generating a new keystore file -->
<target name="generate-keystore" if="keystore.missing">
<echo>***** Generating a new keystore file. *****</echo>
<genkey alias="u0207372Sign" storepass="lqv78" verbose="true" keystore="${basedir}/etc/u 0207372Sto re" keypass="lqv78" dname="CN=u0207372, OU=u0207372, O=Aberdeen, C=UK">
</genkey>
</target>
jarsigner: unable to sign jar: java.util.zip.ZipException
C:\newsreader\build.xml:57
C:\newsreader\build.xml:72
BUILD FAILED (total time: 0 seconds)
maybe i have it done wrong - i trying to have the same as what you had for build...
here is my code:
<!-- package the application -->
<target name="package" depends="build" description="--> create distribution">
<jar destfile="NewsReaderApp.ja
<fileset dir="${basedir}">
<include name="etc/**" />
</fileset>
<manifest>
<attribute name="Built-By" value="u0207372"/>
<attribute name="Main-Class" value="${project.main.clas
<attribute name="Specification-Title"
</manifest>
</jar>
<!-- Signing is normally only required for extended permissions
and integrity checks. If not, delete the next line and the associated target. -->
<antcall target="sign-jar">
</antcall>
</target>
<!-- sign the application -->
<target name="sign-jar">
<!-- check if a keystore file is required -->
<condition property="keystore.missing
<not>
<available file="${basedir}/etc/u0207
</available>
</not>
</condition>
<antcall target="generate-keystore"
</antcall>
<signjar jar="NewsReaderApp.jar" keystore="${basedir}/etc/u
</signjar>
</target>
<!-- Generating a new keystore file -->
<target name="generate-keystore" if="keystore.missing">
<echo>***** Generating a new keystore file. *****</echo>
<genkey alias="u0207372Sign" storepass="lqv78" verbose="true" keystore="${basedir}/etc/u
</genkey>
</target>
With any luck you should be able to start that by double-clicking the jar
>>jar="NewsReaderApp.jar"
But that isn't the jar is it?
But that isn't the jar is it?
ASKER
its ok i fixed it...
ASKER
see if i build it and try try build it again it wont let me.
but if i build it, then clean it -cleaning it does nothing...
<!-- clean the application -->
<target name="clean" description="--> clean">
<delete>
<fileset dir="${basedir}/build/clas ses" includes="**.*"/>
</delete>
</target>
but if i build it, then clean it -cleaning it does nothing...
<!-- clean the application -->
<target name="clean" description="--> clean">
<delete>
<fileset dir="${basedir}/build/clas
</delete>
</target>
I would normally do
<fileset dir="${basedir}/build/clas ses" includes="**/*.*"/>
<fileset dir="${basedir}/build/clas
:-)
Sorry had to get some sleep, can you explain the split please.
The question was about reading the xsl which I helped you with with.
Fxing your build was a seperate issue and really should have been a seperate question.
The question was about reading the xsl which I helped you with with.
Fxing your build was a seperate issue and really should have been a seperate question.
and his earlier comment that you accepted is wrong:
> xslSource = getResource("/etc/rss.xsl" ) ;
> xslSource = getResource("/etc/rss.xsl"
It isn't wrong ;-)
ASKER
>>and his earlier comment that you accepted is wrong:
> xslSource = getResource("/etc/rss.xsl" ) ;
it worked.
I split the points as both of your comments had helped in the end - did you want me to award all points to you? I split them as I though it wasnt fair to award CEHJ all 500 even though he spend hours helping me out, but so did you.
Yes the question was about reading in my xsl file, but inorder to do so you suggested include it in the jar file so this lead to changing my build.xml file to include the xsl file... remember? (Date: 03/23/2006 10:50AM GMT) hence why the question lead more into changing my build.xml file.
Im sure you have been apart of many threads that have evolved off-topic while trying to solve the problem e.g the asker thinks its 1 thing, when it isnt and the thread changes course...
>>The question was about reading the xsl which I helped you with with.
And i award you some points for helping - i might have not selected the right comments but at least you got some credit for it... after all how many comments are in this thread? it isnt easy to read back over them all and selected the best ones when you havent eaten in like 9 hours or have not moved from your chair...
in fact i lost a whole day work yesterday due to this issue and thanks to both of ye, I got it fixed, but at some expense.
ellandrd
> xslSource = getResource("/etc/rss.xsl"
it worked.
I split the points as both of your comments had helped in the end - did you want me to award all points to you? I split them as I though it wasnt fair to award CEHJ all 500 even though he spend hours helping me out, but so did you.
Yes the question was about reading in my xsl file, but inorder to do so you suggested include it in the jar file so this lead to changing my build.xml file to include the xsl file... remember? (Date: 03/23/2006 10:50AM GMT) hence why the question lead more into changing my build.xml file.
Im sure you have been apart of many threads that have evolved off-topic while trying to solve the problem e.g the asker thinks its 1 thing, when it isnt and the thread changes course...
>>The question was about reading the xsl which I helped you with with.
And i award you some points for helping - i might have not selected the right comments but at least you got some credit for it... after all how many comments are in this thread? it isnt easy to read back over them all and selected the best ones when you havent eaten in like 9 hours or have not moved from your chair...
in fact i lost a whole day work yesterday due to this issue and thanks to both of ye, I got it fixed, but at some expense.
ellandrd
ASKER
p.s im not here to argue with people over some stupid points
> it worked.
it won't even compiled (as u yourself stated)
And the corrected version was copied from my previous comments.
> hence why the question lead more into changing my build.xml file.
which should have been a seperate question.
the solution to your problem required no change to your build script
as I \stated you just needed to include the xsl in your classpath
> Im sure you have been apart of many threads that have evolved off-topic while trying to solve the problem e.g the asker thinks its
> 1 thing, when it isnt and the thread changes course...
Yes, but I don't expect the points for it after someone else has alr3eaqdy answered the question.
> p.s im not here to argue with people over some stupid points
If you don't like the system then don't use it :)
I'll get the admins to have a look at it.
it won't even compiled (as u yourself stated)
And the corrected version was copied from my previous comments.
> hence why the question lead more into changing my build.xml file.
which should have been a seperate question.
the solution to your problem required no change to your build script
as I \stated you just needed to include the xsl in your classpath
> Im sure you have been apart of many threads that have evolved off-topic while trying to solve the problem e.g the asker thinks its
> 1 thing, when it isnt and the thread changes course...
Yes, but I don't expect the points for it after someone else has alr3eaqdy answered the question.
> p.s im not here to argue with people over some stupid points
If you don't like the system then don't use it :)
I'll get the admins to have a look at it.
ASKER
>>it won't even compiled (as u yourself stated)
>>And the corrected version was copied from my previous comments.
look at: Date: 03/23/2006 11:03AM GMT - this is the code i used and you got credit for your comments
>>which should have been a seperate question.
>>the solution to your problem required no change to your build script
>>as I \stated you just needed to include the xsl in your classpath
OK, fair point - but i didnt know how to do this, hence why i asked for help with it.
you could have said stop, this question is not related to changing build.xml so open new Q. but you didnt - you continued to provide comments to help me change my build.xml:
Date: 03/23/2006 10:50AM GMT
Date: 03/23/2006 11:36AM GMT
Date: 03/23/2006 11:55AM GMT
Yes - i'll take the blame for not seeing this (opening new thread), but i should have been corrected.
>>Yes, but I don't expect the points for it after someone else has alr3eaqdy answered the question.
Its called been fair - if i awarded CEHJ all the points you'd be giving out, saying you helped me - next thing i'd see is comment from mods and question reopened...
so to bypass this, i split the points.
>>I'll get the admins to have a look at it.
do what you want - i dont care - as far as i can see, the mods have looked at this question and have made there comments on it to you: https://www.experts-exchange.com/questions/21788228/Working-please-check.html
you are never happy with any decisions i make anyway so whats the point?
there is times when i open questions and you comment, and i think yes - objects just commented - he'll help me out... but then i think oh no - he's sooooo picky and will be on my back for a few days as the decisions/comments i make, he wont like...
this site is meant to be trying to hold onto members - not push them away and this is exactly what you doing!
>>And the corrected version was copied from my previous comments.
look at: Date: 03/23/2006 11:03AM GMT - this is the code i used and you got credit for your comments
>>which should have been a seperate question.
>>the solution to your problem required no change to your build script
>>as I \stated you just needed to include the xsl in your classpath
OK, fair point - but i didnt know how to do this, hence why i asked for help with it.
you could have said stop, this question is not related to changing build.xml so open new Q. but you didnt - you continued to provide comments to help me change my build.xml:
Date: 03/23/2006 10:50AM GMT
Date: 03/23/2006 11:36AM GMT
Date: 03/23/2006 11:55AM GMT
Yes - i'll take the blame for not seeing this (opening new thread), but i should have been corrected.
>>Yes, but I don't expect the points for it after someone else has alr3eaqdy answered the question.
Its called been fair - if i awarded CEHJ all the points you'd be giving out, saying you helped me - next thing i'd see is comment from mods and question reopened...
so to bypass this, i split the points.
>>I'll get the admins to have a look at it.
do what you want - i dont care - as far as i can see, the mods have looked at this question and have made there comments on it to you: https://www.experts-exchange.com/questions/21788228/Working-please-check.html
you are never happy with any decisions i make anyway so whats the point?
there is times when i open questions and you comment, and i think yes - objects just commented - he'll help me out... but then i think oh no - he's sooooo picky and will be on my back for a few days as the decisions/comments i make, he wont like...
this site is meant to be trying to hold onto members - not push them away and this is exactly what you doing!
ASKER