NoClassDefFoundError Error invoking a method - java

I am getting this error while i have added the dependecies required commons-codec.
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getPassword' in class com.soft.DbGenUtl threw exception class java.lang.NoClassDefFoundError : org.apache.commons.codec.binary.Base64
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:246)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:220)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:70)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
at org.apache.velocity.Template.merge(Template.java:256)
at com.cwsoft.tools.filegenerator.VelocityTemplateProcessor.process(VelocityTemplateProcessor.java:63)
at com.cwsoft.tools.filegenerator.FileGenerator.execute(FileGenerator.java:121)
at com.cwsoft.tools.filegenerator.ant.FileGenerateTask.execute(FileGenerateTask.java:41)
... 46 more
maven2/repository/local/org/apache/commons/codec/binary] ls -lrt
total 144
-rw-r----- 1 ppk ppkgroup 3119 Dec 20 2013 StringUtils.class
-rw-r----- 1 ppk ppkgroup 4356 Dec 20 2013 Hex.class
-rw-r----- 1 ppk ppkgroup 3252 Dec 20 2013 BinaryCodec.class
-rw-r----- 1 ppk ppkgroup 2372 Dec 20 2013 BaseNCodecOutputStream.class
-rw-r----- 1 ppk ppkgroup 3127 Dec 20 2013 BaseNCodecInputStream.class
-rw-r----- 1 ppk ppkgroup 5348 Dec 20 2013 BaseNCodec.class
-rw-r----- 1 ppk ppkgroup 1409 Dec 20 2013 BaseNCodec$Context.class
-rw-r----- 1 ppk ppkgroup 939 Dec 20 2013 Base64OutputStream.class
-rw-r----- 1 ppk ppkgroup 929 Dec 20 2013 Base64InputStream.class
-rw-r----- 1 ppk ppkgroup 9201 Dec 20 2013 Base64.class
-rw-r----- 1 ppk ppkgroup 939 Dec 20 2013 Base32OutputStream.class
-rw-r----- 1 ppk ppkgroup 929 Dec 20 2013 Base32InputStream.class
-rw-r----- 1 ppk ppkgroup 7605 Dec 20 2013 Base32.class
Could you please suggest what am I missing here?
Thanks.

Related

Accessing folder outside user.home is returning false in Linux

I have installed tomcat and deployed a java web application in that in Redhat.
My System property user.home is pointing to /opt/tomcat.
This application tries to access a file path like this
root = new File(rootPath);
if (!root.isDirectory()) {
throw new IllegalArgumentException("Root is not a directory!");
}
Now i want to access any folder outside /opt like a sibling to /opt, it results false in root.isDirectory(). But if a folder is inside /opt/tomcat then it is properly returning as true.
Both the folders /opt and /nasdata(folder which i want to access) have same permissions.
UPDATED
ls -la /opt
drwxr-xr-x. 8 root root 4096 Jul 21 16:15 .
dr-xr-xr-x. 21 root root 4096 Jul 21 20:53 ..
drwxr-xr-x 10 tomcat tomcat 4096 Jul 26 21:20 tomcat
ls -la /opt/tomcat
drwxr-xr-x 10 tomcat tomcat 4096 Jul 26 21:20 .
drwxr-xr-x. 8 root root 4096 Jul 21 16:15 ..
drwxr-x--- 2 tomcat tomcat 4096 Jul 21 16:15 bin
-rw-r----- 1 tomcat tomcat 18949 Jun 28 01:46 BUILDING.txt
drwxr-x--- 3 tomcat tomcat 4096 Jul 23 09:20 conf
-rw-r----- 1 tomcat tomcat 6210 Jun 28 01:46 CONTRIBUTING.md
drwxr-x--- 2 tomcat tomcat 4096 Jul 21 20:14 lib
-rw-r----- 1 tomcat tomcat 57092 Jun 28 01:46 LICENSE
drwxr-x--- 2 tomcat tomcat 4096 Jul 28 04:58 logs
lrwxrwxrwx 1 root root 9 Jul 26 21:20 nasdata -> /nasdata/
-rw-r----- 1 tomcat tomcat 2333 Jun 28 01:46 NOTICE
drwxr-x--- 2 tomcat tomcat 4096 Jul 23 09:20 .oracle_jre_usage
-rw-r----- 1 tomcat tomcat 3372 Jun 28 01:46 README.md
-rw-r----- 1 tomcat tomcat 6898 Jun 28 01:46 RELEASE-NOTES
-rw-r----- 1 tomcat tomcat 16507 Jun 28 01:46 RUNNING.txt
drwxr-x--- 2 tomcat tomcat 4096 Jul 23 09:34 temp
drwxr-x--- 9 tomcat tomcat 4096 Jul 23 09:37 webapps
drwxr-x--- 3 tomcat tomcat 4096 Jul 21 16:28 work
ls -la of my root folder. I am trying to access nasdata folder and giving /nasdata as the path.
dr-xr-xr-x. 21 root root 4096 Jul 21 20:53 .
dr-xr-xr-x. 21 root root 4096 Jul 21 20:53 ..
-rw-r--r-- 1 root root 0 Feb 4 20:43 .autorelabel
lrwxrwxrwx. 1 root root 7 Feb 4 20:39 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Feb 4 20:52 boot
drwxr-xr-x 19 root root 3220 Jul 21 14:04 dev
drwxr-xr-x. 89 root root 4096 Jul 21 21:00 etc
drwxr-xr-x. 2 root root 4096 Feb 4 20:39 home
drwxr-xr-x 3 root root 4096 Jul 21 16:55 home2
lrwxrwxrwx. 1 root root 7 Feb 4 20:39 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Feb 4 20:39 lib64 -> usr/lib64
drwxr-xr-x. 5 root root 1024 Jul 21 16:58 localhome
drwx------. 2 root root 16384 Feb 4 20:38 lost+found
drwxr-xr-x. 2 root root 4096 Dec 14 2017 media
drwxr-xr-x. 2 root root 4096 Dec 14 2017 mnt
drwxrwxr-x 2 root 9999 4096 Jul 26 16:58 nasdata
drwxr-xr-x. 8 root root 4096 Jul 21 16:15 opt
dr-xr-xr-x 150 root root 0 Jul 21 14:04 proc
dr-xr-x---. 7 root root 4096 Jul 21 16:26 root
drwxr-xr-x 30 root root 980 Jul 21 16:46 run
lrwxrwxrwx. 1 root root 8 Feb 4 20:39 sbin -> usr/sbin
-rw-r--r-- 1 root root 127599309 Jul 21 20:53 sk
drwxr-xr-x. 2 root root 4096 Dec 14 2017 srv
dr-xr-xr-x 13 root root 0 Jul 21 14:04 sys
drwxrwxrwt. 14 root root 4096 Jul 28 03:43 tmp
drwxr-xr-x. 14 root root 4096 Jul 21 16:08 usr
drwxr-xr-x. 20 root root 4096 Feb 4 20:46 var
Best Regards,
Saurav

Maven can't see installed local dependency

I have a project with following POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I then compile and install with mvn clean install. I can see artefact installed in my .m2 dir:
lukasz#lukasz-XPS-L701X:~$ ls .m2/repository/com/example/demo/
0.0.1-SNAPSHOT maven-metadata-local.xml
I can use this file in other project when calling javac directly:
javac -cp .m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar
However, when I have another Maven project that has demo as dependency, Maven says it can't find it.
demo2 POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo2</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I run mvn clean compile in demo2, I get:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demo2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # demo2 ---
[INFO] Deleting /home/lukasz/parent/demo2/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # demo2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # demo2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/lukasz/parent/demo2/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.053 s
[INFO] Finished at: 2017-02-19T10:45:57+01:00
[INFO] Final Memory: 22M/254M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo2: Compilation failure: Compilation failure:
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
EDIT:
This is output of ls -lR .m2/repository/com/example/demo/
.m2/repository/com/example/demo/:
total 8
drwxr-xr-x 5 lukasz lukasz 4096 Feb 19 07:12 0.0.1-SNAPSHOT
-rw-r--r-- 1 lukasz lukasz 275 Feb 19 07:07 maven-metadata-local.xml
.m2/repository/com/example/demo/0.0.1-SNAPSHOT:
total 6468
drwxr-xr-x 4 lukasz lukasz 4096 Feb 19 07:07 BOOT-INF
-rw-r--r-- 1 lukasz lukasz 6595868 Feb 19 07:07 demo-0.0.1-SNAPSHOT.jar
-rw-r--r-- 1 lukasz lukasz 1410 Feb 19 01:01 demo-0.0.1-SNAPSHOT.pom
-rw-r--r-- 1 lukasz lukasz 701 Feb 19 07:07 maven-metadata-local.xml
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 META-INF
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 org
-rw-r--r-- 1 lukasz lukasz 185 Feb 19 07:07 _remote.repositories
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF:
total 8
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 classes
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 lib
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/classes:
total 4
-rw-r--r-- 1 lukasz lukasz 0 Feb 19 07:07 application.properties
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 com
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/classes/com:
total 4
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 example
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/classes/com/example:
total 8
-rw-r--r-- 1 lukasz lukasz 267 Feb 19 07:07 Aclass.class
-rw-r--r-- 1 lukasz lukasz 694 Feb 19 07:07 DemoApplication.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/BOOT-INF/lib:
total 6384
-rw-r--r-- 1 lukasz lukasz 16521 Dec 13 18:09 jcl-over-slf4j-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 4596 Dec 13 18:09 jul-to-slf4j-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 23647 Dec 13 18:09 log4j-over-slf4j-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 305150 Jan 20 19:58 logback-classic-1.1.9.jar
-rw-r--r-- 1 lukasz lukasz 472639 Jan 20 19:57 logback-core-1.1.9.jar
-rw-r--r-- 1 lukasz lukasz 41077 Dec 13 18:07 slf4j-api-1.7.22.jar
-rw-r--r-- 1 lukasz lukasz 273599 Feb 19 2016 snakeyaml-1.17.jar
-rw-r--r-- 1 lukasz lukasz 379905 Jan 25 13:13 spring-aop-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 762701 Jan 25 13:13 spring-beans-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 662119 Jan 30 19:31 spring-boot-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 1038200 Jan 30 19:39 spring-boot-autoconfigure-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 2290 Jan 30 19:45 spring-boot-starter-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 2309 Jan 30 19:45 spring-boot-starter-logging-1.5.1.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 1136805 Jan 25 13:14 spring-context-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 1117842 Jan 25 13:13 spring-core-4.3.6.RELEASE.jar
-rw-r--r-- 1 lukasz lukasz 263304 Jan 25 13:14 spring-expression-4.3.6.RELEASE.jar
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF:
total 8
-rw-r--r-- 1 lukasz lukasz 558 Feb 19 07:07 MANIFEST.MF
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 maven
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF/maven:
total 4
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 com.example
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF/maven/com.example:
total 4
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 demo
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/META-INF/maven/com.example/demo:
total 8
-rw-r--r-- 1 lukasz lukasz 116 Feb 19 07:07 pom.properties
-rw-r--r-- 1 lukasz lukasz 1410 Feb 19 01:01 pom.xml
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org:
total 4
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 springframework
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework:
total 4
drwxr-xr-x 3 lukasz lukasz 4096 Feb 19 07:07 boot
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot:
total 4
drwxr-xr-x 6 lukasz lukasz 4096 Feb 19 07:07 loader
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader:
total 92
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 archive
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 data
-rw-r--r-- 1 lukasz lukasz 1165 Jan 30 19:26 ExecutableArchiveLauncher$1.class
-rw-r--r-- 1 lukasz lukasz 3128 Jan 30 19:26 ExecutableArchiveLauncher.class
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 jar
-rw-r--r-- 1 lukasz lukasz 1533 Jan 30 19:26 JarLauncher.class
-rw-r--r-- 1 lukasz lukasz 2415 Jan 30 19:26 LaunchedURLClassLoader$1.class
-rw-r--r-- 1 lukasz lukasz 4698 Jan 30 19:26 LaunchedURLClassLoader.class
-rw-r--r-- 1 lukasz lukasz 4599 Jan 30 19:26 Launcher.class
-rw-r--r-- 1 lukasz lukasz 1468 Jan 30 19:26 MainMethodRunner.class
-rw-r--r-- 1 lukasz lukasz 1382 Jan 30 19:26 PropertiesLauncher$1.class
-rw-r--r-- 1 lukasz lukasz 1454 Jan 30 19:26 PropertiesLauncher$ArchiveEntryFilter.class
-rw-r--r-- 1 lukasz lukasz 16109 Jan 30 19:26 PropertiesLauncher.class
-rw-r--r-- 1 lukasz lukasz 1704 Jan 30 19:26 PropertiesLauncher$FilteredArchive$1.class
-rw-r--r-- 1 lukasz lukasz 2382 Jan 30 19:26 PropertiesLauncher$FilteredArchive.class
-rw-r--r-- 1 lukasz lukasz 1807 Jan 30 19:26 PropertiesLauncher$PrefixMatchingArchiveFilter.class
drwxr-xr-x 2 lukasz lukasz 4096 Feb 19 07:07 util
-rw-r--r-- 1 lukasz lukasz 1669 Jan 30 19:26 WarLauncher.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/archive:
total 52
-rw-r--r-- 1 lukasz lukasz 906 Jan 30 19:26 Archive.class
-rw-r--r-- 1 lukasz lukasz 302 Jan 30 19:26 Archive$Entry.class
-rw-r--r-- 1 lukasz lukasz 399 Jan 30 19:26 Archive$EntryFilter.class
-rw-r--r-- 1 lukasz lukasz 273 Jan 30 19:26 ExplodedArchive$1.class
-rw-r--r-- 1 lukasz lukasz 4974 Jan 30 19:26 ExplodedArchive.class
-rw-r--r-- 1 lukasz lukasz 1068 Jan 30 19:26 ExplodedArchive$FileEntry.class
-rw-r--r-- 1 lukasz lukasz 3792 Jan 30 19:26 ExplodedArchive$FileEntryIterator.class
-rw-r--r-- 1 lukasz lukasz 1438 Jan 30 19:26 ExplodedArchive$FileEntryIterator$EntryComparator.class
-rw-r--r-- 1 lukasz lukasz 7016 Jan 30 19:26 JarFileArchive.class
-rw-r--r-- 1 lukasz lukasz 1749 Jan 30 19:26 JarFileArchive$EntryIterator.class
-rw-r--r-- 1 lukasz lukasz 1051 Jan 30 19:26 JarFileArchive$JarFileEntry.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/data:
total 24
-rw-r--r-- 1 lukasz lukasz 1531 Jan 30 19:26 ByteArrayRandomAccessData.class
-rw-r--r-- 1 lukasz lukasz 551 Jan 30 19:26 RandomAccessData.class
-rw-r--r-- 1 lukasz lukasz 3390 Jan 30 19:26 RandomAccessDataFile.class
-rw-r--r-- 1 lukasz lukasz 3534 Jan 30 19:26 RandomAccessDataFile$DataInputStream.class
-rw-r--r-- 1 lukasz lukasz 2051 Jan 30 19:26 RandomAccessDataFile$FilePool.class
-rw-r--r-- 1 lukasz lukasz 1341 Jan 30 19:26 RandomAccessData$ResourceAccess.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/jar:
total 136
-rw-r--r-- 1 lukasz lukasz 4457 Jan 30 19:26 AsciiBytes.class
-rw-r--r-- 1 lukasz lukasz 2169 Jan 30 19:26 Bytes.class
-rw-r--r-- 1 lukasz lukasz 2943 Jan 30 19:26 CentralDirectoryEndRecord.class
-rw-r--r-- 1 lukasz lukasz 5449 Jan 30 19:26 CentralDirectoryFileHeader.class
-rw-r--r-- 1 lukasz lukasz 4602 Jan 30 19:26 CentralDirectoryParser.class
-rw-r--r-- 1 lukasz lukasz 430 Jan 30 19:26 CentralDirectoryVisitor.class
-rw-r--r-- 1 lukasz lukasz 306 Jan 30 19:26 FileHeader.class
-rw-r--r-- 1 lukasz lukasz 9657 Jan 30 19:26 Handler.class
-rw-r--r-- 1 lukasz lukasz 3350 Jan 30 19:26 JarEntry.class
-rw-r--r-- 1 lukasz lukasz 262 Jan 30 19:26 JarEntryFilter.class
-rw-r--r-- 1 lukasz lukasz 2002 Jan 30 19:26 JarFile$1.class
-rw-r--r-- 1 lukasz lukasz 1199 Jan 30 19:26 JarFile$2.class
-rw-r--r-- 1 lukasz lukasz 1427 Jan 30 19:26 JarFile$3.class
-rw-r--r-- 1 lukasz lukasz 12697 Jan 30 19:26 JarFile.class
-rw-r--r-- 1 lukasz lukasz 1540 Jan 30 19:26 JarFileEntries$1.class
-rw-r--r-- 1 lukasz lukasz 10924 Jan 30 19:26 JarFileEntries.class
-rw-r--r-- 1 lukasz lukasz 1967 Jan 30 19:26 JarFileEntries$EntryIterator.class
-rw-r--r-- 1 lukasz lukasz 1300 Jan 30 19:26 JarFile$JarFileType.class
-rw-r--r-- 1 lukasz lukasz 672 Jan 30 19:26 JarURLConnection$1.class
-rw-r--r-- 1 lukasz lukasz 9111 Jan 30 19:26 JarURLConnection.class
-rw-r--r-- 1 lukasz lukasz 3641 Jan 30 19:26 JarURLConnection$JarEntryName.class
-rw-r--r-- 1 lukasz lukasz 1629 Jan 30 19:26 ZipInflaterInputStream.class
.m2/repository/com/example/demo/0.0.1-SNAPSHOT/org/springframework/boot/loader/util:
total 8
-rw-r--r-- 1 lukasz lukasz 4887 Jan 30 19:26 SystemPropertyUtils.class
Please note that I did say I can use this jar (and Aclass) when calling javac directly with -cp.
EDIT:
Source for Demo2Application.java:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class Demo2Application {
public static void main(String[] args) {
SpringApplication.run(Demo2Application.class, args);
Aclass c = new Aclass();
}
}
Output of jat tvf on jar:
lukasz#lukasz-XPS-L701X:~/.m2/repository/com/example/demo/0.0.1-SNAPSHOT$ jar tvf demo-0.0.1-SNAPSHOT.jar
0 Sun Feb 19 07:07:38 CET 2017 META-INF/
558 Sun Feb 19 07:07:38 CET 2017 META-INF/MANIFEST.MF
0 Sun Feb 19 07:07:38 CET 2017 BOOT-INF/
0 Sun Feb 19 07:07:38 CET 2017 BOOT-INF/classes/
0 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/
0 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/example/
267 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/example/Aclass.class
694 Sun Feb 19 07:07:34 CET 2017 BOOT-INF/classes/com/example/DemoApplication.class
0 Sun Feb 19 07:07:30 CET 2017 BOOT-INF/classes/application.properties
0 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/
0 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/com.example/
0 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/com.example/demo/
1410 Sun Feb 19 01:01:32 CET 2017 META-INF/maven/com.example/demo/pom.xml
116 Sun Feb 19 07:07:38 CET 2017 META-INF/maven/com.example/demo/pom.properties
0 Sun Feb 19 07:07:38 CET 2017 BOOT-INF/lib/
41077 Tue Dec 13 18:07:58 CET 2016 BOOT-INF/lib/slf4j-api-1.7.22.jar
2309 Mon Jan 30 19:45:02 CET 2017 BOOT-INF/lib/spring-boot-starter-logging-1.5.1.RELEASE.jar
2290 Mon Jan 30 19:45:02 CET 2017 BOOT-INF/lib/spring-boot-starter-1.5.1.RELEASE.jar
662119 Mon Jan 30 19:31:36 CET 2017 BOOT-INF/lib/spring-boot-1.5.1.RELEASE.jar
472639 Fri Jan 20 19:57:20 CET 2017 BOOT-INF/lib/logback-core-1.1.9.jar
4596 Tue Dec 13 18:09:14 CET 2016 BOOT-INF/lib/jul-to-slf4j-1.7.22.jar
762701 Wed Jan 25 13:13:50 CET 2017 BOOT-INF/lib/spring-beans-4.3.6.RELEASE.jar
379905 Wed Jan 25 13:13:54 CET 2017 BOOT-INF/lib/spring-aop-4.3.6.RELEASE.jar
16521 Tue Dec 13 18:09:00 CET 2016 BOOT-INF/lib/jcl-over-slf4j-1.7.22.jar
263304 Wed Jan 25 13:14:04 CET 2017 BOOT-INF/lib/spring-expression-4.3.6.RELEASE.jar
23647 Tue Dec 13 18:09:06 CET 2016 BOOT-INF/lib/log4j-over-slf4j-1.7.22.jar
1136805 Wed Jan 25 13:14:18 CET 2017 BOOT-INF/lib/spring-context-4.3.6.RELEASE.jar
1117842 Wed Jan 25 13:13:44 CET 2017 BOOT-INF/lib/spring-core-4.3.6.RELEASE.jar
1038200 Mon Jan 30 19:39:22 CET 2017 BOOT-INF/lib/spring-boot-autoconfigure-1.5.1.RELEASE.jar
305150 Fri Jan 20 19:58:16 CET 2017 BOOT-INF/lib/logback-classic-1.1.9.jar
273599 Fri Feb 19 13:13:32 CET 2016 BOOT-INF/lib/snakeyaml-1.17.jar
0 Sun Feb 19 07:07:38 CET 2017 org/
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/
2415 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/LaunchedURLClassLoader$1.class
1454 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
1807 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
4599 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/Launcher.class
1165 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/ExecutableArchiveLauncher$1.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/jar/
2002 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$1.class
9657 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/Handler.class
3350 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarEntry.class
1427 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$3.class
2943 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
430 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
1300 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$JarFileType.class
10924 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFileEntries.class
12697 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile.class
1540 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFileEntries$1.class
672 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarURLConnection$1.class
1199 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFile$2.class
262 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarEntryFilter.class
4457 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/AsciiBytes.class
4602 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryParser.class
2169 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/Bytes.class
1629 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/ZipInflaterInputStream.class
1967 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
306 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/FileHeader.class
3641 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
9111 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/JarURLConnection.class
5449 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
1704 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$FilteredArchive$1.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/data/
1531 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/ByteArrayRandomAccessData.class
3534 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
2051 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessDataFile$FilePool.class
1341 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessData$ResourceAccess.class
3390 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessDataFile.class
551 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/data/RandomAccessData.class
4698 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/LaunchedURLClassLoader.class
1533 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/JarLauncher.class
1468 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/MainMethodRunner.class
2382 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$FilteredArchive.class
1382 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher$1.class
3128 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/ExecutableArchiveLauncher.class
1669 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/WarLauncher.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/archive/
1749 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
3792 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator.class
1068 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
1051 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
302 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/Archive$Entry.class
7016 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/JarFileArchive.class
4974 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive.class
906 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/Archive.class
1438 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$FileEntryIterator$EntryComparator.class
399 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/Archive$EntryFilter.class
273 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/archive/ExplodedArchive$1.class
16109 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/PropertiesLauncher.class
0 Sun Feb 19 07:07:38 CET 2017 org/springframework/boot/loader/util/
4887 Mon Jan 30 19:26:16 CET 2017 org/springframework/boot/loader/util/SystemPropertyUtils.class
Your class is not in the jar. Or rather, it's under the BOOT-INF/classes/com/example directory instead of being under the com/example directory.
This jar file is not a jar file that can be used as a library. It's an uber jar file that has been created by the Spring-Boot plugin to contain all the dependencies and classes of your first app, along with a spring boot loader that uses a custom classloader to load the application classes and the dependencies from the uber jar.
If the jar shouldn't be a Spring boot app, but a simple library, then just don't use the Spring-Boot plugin in that project.
If it's supposed to be a library and a Spring Boot app at the same time (which is strange), then split it into two projects: one that produces a library, and a second one which is a Spring Boot app, contains just the main class of the app (and the other classes that shouldn't be in the library), and has the library as dependency.

Version of zmq jar

I have zmq.jar built by someone else long time ago. How can I find out which version it corresponds to?
Not much in the MANIFEST:
$ cat MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.6.0_14 (Sun Microsystems Inc.)
Here's the contents. Would someone be able to tell whether it's 2.x or 3.x?
$ jar tvf zmq.jar
0 Thu Feb 02 14:59:52 EST 2012 META-INF/
71 Thu Feb 02 14:59:52 EST 2012 META-INF/MANIFEST.MF
2429 Wed Feb 01 14:24:32 EST 2012 org/zeromq/App.class
4320 Tue Jan 24 14:40:32 EST 2012 org/zeromq/EmbeddedLibraryTools.class
2392 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZContext.class
3536 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZFrame.class
920 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQ$Context.class
2401 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQ$Error.class
3232 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQ$Poller.class
5613 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQ$Socket.class
2484 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQ.class
771 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQException.class
1468 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQForwarder.class
1663 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQQueue.class
424 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMQStreamer.class
9771 Tue Jan 24 14:40:32 EST 2012 org/zeromq/ZMsg.class
Just ask for the version!
import org.zeromq.ZMQ;
public class ZMQVersion {
public static void main (String[] args) {
System.out.println(
String.format("Version string: %s, Version int: %d",
ZMQ.getVersionString(),
ZMQ.getFullVersion()));
}
}

Access PDF file from with JAR if the user fails to select a RadioButton

I would like to copy a PDF file out of my JAR if the user fails to select a Radiobutton. The problem I am having is that the console reports java.io.FileNotFoundException: file:/home/geeky/workspace/TabSync/bin/ndg/co/uk/TabSync/nullpdf.pdf (No such file or directory) even though the file is there. If I copy the path that is claimed as No such file... into Thunar then the file opens straight away so the path is correct.
The code is below:
URL nopathbrain = getClass().getResource("/ndg/co/uk/TabSync/nullpdf.pdf");
////////////////////////////////////////////////////////////////////////////////////////
public void actionPerformed(ActionEvent arg0) {
try{
//set the busy cursor while building the sync files
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (radioButton1.isSelected()) {
filepathbrain1 = txtPath1.getText();
System.out.println(filepathbrain1);
} else {
System.out.println(nopathbrain);
filepathbrain1 = String.valueOf(nopathbrain);
}
copysource();
copysource() looks like this
public void copysource() {
try{
File afile =new File(filepathbrain1);
File bfile =new File(buildpath +"/documents/1.pdf");
FileInputStream inStream = new FileInputStream(afile);
FileOutputStream outStream = new FileOutputStream(bfile);
byte[] buffer = new byte[1024];
int length;
//copy the file content in bytes
while ((length = inStream.read(buffer)) > 0){
outStream.write(buffer, 0, length);
} //end while
inStream.close();
outStream.close();
Output of jar -tvf is:
0 Sun Mar 31 09:51:56 BST 2013 ngd/
0 Sun Mar 31 09:51:56 BST 2013 ngd/co/
0 Sun Mar 31 09:51:56 BST 2013 ngd/co/uk/
0 Sun Mar 31 09:51:56 BST 2013 ngd/co/uk/TabSync/
806 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/About$1.class
556 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/About$2.class
4762 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/About.class
1802 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/Help.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$1.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$10.class
1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$11.class
1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$12.class
1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$13.class
1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$14.class
1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$15.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$16.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$17.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$18.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$19.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$2.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$20.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$21.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$22.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$23.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$24.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$25.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$26.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$27.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$28.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$29.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$3.class
735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$30.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$31.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$32.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$33.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$34.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$35.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$36.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$37.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$38.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$39.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$4.class
1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$40.class
4765 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$41.class
723 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$42.class
1185 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$43.class
697 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$44.class
1220 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$45.class
995 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$46.class
781 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$47.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$5.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$6.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$7.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$8.class
733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$9.class
2097 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$Field1Listener.class
47217 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main.class
1260 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/FileFiltererpdf.class
1260 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/FileFiltererjpg.class
991552 Wed Jul 27 19:13:00 BST 2011 ngd/co/uk/TabSync/Coalition_v2.ttf
991552 Wed Jul 27 19:13:00 BST 2011 Coalition_v2.ttf
409717 Thu Mar 21 14:15:32 GMT 2013 nullpdf.pdf
The problem I am having is that when the radiobutton is not selected then the copy of the PDF from the JAR does not work. If I provide a manual path to a file on my desktop then the copy works fine (so I am happy that copysource() works ok, it is just included for completeness).
EDITED HERE:
I am now trying to access the pdf via a temp file as it seems I should be using a Stream to get the resource, I am still getting file not found exceptions though. Code:
//write the null file to tmp for copy
try {
java.io.InputStream iss = getClass().getResourceAsStream("/nullpdf.pdf");
byte[] data = new byte[iss.available()];
iss.read(data);
iss.close();
String tempFile = "file";
File temp = File.createTempFile(tempFile, ".pdf");
FileOutputStream fos = new FileOutputStream(temp);
fos.write(data);
fos.flush();
fos.close();
nopathbrain = tempFile +".pdf";
} catch (IOException ex) {
ex.printStackTrace();
System.out.println("TEMP FILE NOT CREATED - ERROR in brainradiocheck");
}
I think the temp file is being created ok, but how do I get its filepath returned as a string? I want to set the filepath of the tempfile to nopathbrain.
Andy
To access a resource jar I use this statement:
this.getClass().getResourceAsStream("/es/app/firstTry/resources/button.jpg")
this returns a InputStream, so you could open it or copy to any directory.
//write the null file to tmp for copy
try {
java.io.InputStream iss = getClass().getResourceAsStream("/nullpdf.pdf");
byte[] data = new byte[iss.available()];
iss.read(data);
iss.close();
String tempFile = "file";
File temp = File.createTempFile(tempFile, ".pdf");
FileOutputStream fos = new FileOutputStream(temp);
fos.write(data);
fos.flush();
fos.close();
nopathbrain = temp.getAbsolutePath();
System.out.println(tempFile);
System.out.println(nopathbrain);
} catch (IOException ex) {
ex.printStackTrace();
System.out.println("TEMP FILE NOT CREATED - ERROR in brainradiocheck");
}
Answered myself if anyone else is facing similar.

How to to autodeploy war file with GlassFish -- from "Core JavaServerFaces" by David Geary, Cay S. Horstmann

Naive question, but this is my first step in JSF, so forgive me ;-)
I am following all the steps of the first example from "Core JavaServerFaces" by David Geary, Cay S. Horstmann (the 3rd edition).
What works in general:
java works
glassfish works
I can compile the attached code
I can create .war file
The problem begins when I copy the war file into autodeploy subdirectory of GlassFish and try to show the appropriate page in GF. In return I get 404 error and in logs I find this:
Selecting file /opt/glassfish3/glassfish/domains/domain1/autodeploy/login.war for autodeployment.
Module type not recognized for module /opt/glassfish3/glassfish/domains/domain1/applications/login
There is no installed container capable of handling this application login
Autodeploy failed : /opt/glassfish3/glassfish/domains/domain1/autodeploy/login.war.
glassfish 3.1.2, java 1.6.0_29, opensuse 11.4.
The question is how to make this code work?
Updates
jar tvf login.war
0 Thu Apr 12 22:24:24 CEST 2012 META-INF/
71 Thu Apr 12 22:24:24 CEST 2012 META-INF/MANIFEST.MF
0 Mon Jun 27 10:13:54 CEST 2011 src/
0 Mon Jun 27 10:13:54 CEST 2011 src/java/
0 Mon Jun 27 10:13:54 CEST 2011 src/java/com/
0 Thu Apr 12 22:16:32 CEST 2012 src/java/com/corejsf/
603 Thu Apr 12 22:16:32 CEST 2012 src/java/com/corejsf/UserBean.java
0 Mon Jun 27 10:13:54 CEST 2011 web/
0 Thu Apr 12 21:24:56 CEST 2012 web/WEB-INF/
877 Mon Jun 27 10:13:54 CEST 2011 web/WEB-INF/web.xml
0 Thu Apr 12 22:21:38 CEST 2012 web/WEB-INF/classes/
0 Thu Apr 12 22:21:38 CEST 2012 web/WEB-INF/classes/com/
0 Thu Apr 12 22:21:38 CEST 2012 web/WEB-INF/classes/com/corejsf/
704 Thu Apr 12 22:21:38 CEST 2012 web/WEB-INF/classes/com/corejsf/UserBean.class
0 Mon Jun 27 10:13:54 CEST 2011 web/WEB-INF/beans.xml
786 Mon Jun 27 10:13:54 CEST 2011 web/index.xhtml
394 Mon Jun 27 10:13:54 CEST 2011 web/welcome.xhtml
Your WAR file is broken.
Package it up in the web folder instead. WEB-INF should be in the root.

Categories