Cannot resolve symbol, but the dependency is in local repo - java
I've been reading all similar problems with maven but I cannot seem to be able to fix it. The issue is the classic "Cannot resolve symbol 'pippo'", in which case pippo is part of
import com.pippo.device.manager.data.model.Device;
This class Device comes from this artifact that I have in my local repo
<dependency>
<groupId>com.pippo</groupId>
<artifactId>device.manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Evidence that it is in the local repository
/mnt/c/Users/sanvegeta/.m2/repository$ find . -type f -name "*device.manager*" -ls
38228 -rwxrwxrwx 1 sanvegeta sanvegeta 39142700 Oct 1 09:00 ./com/pippo/device.manager/0.0.1-SNAPSHOT/device.manager-0.0.1-SNAPSHOT.jar
4 -rwxrwxrwx 1 sanvegeta sanvegeta 1969 Oct 1 08:47 ./com/pippo/device.manager/0.0.1-SNAPSHOT/device.manager-0.0.1-SNAPSHOT.pom
and evidence that this is the correct local repository
mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]'
/mnt/c/Users/sanvegeta/.m2/repository
Just to give you a little bit of context: I'm working on a lab exercise and I created 2 microservices: com.pluto.user.manager and com.pippo.device.manager. They both expose CRUD REST API to work respectively on User and Device. Part of my exercise is to refer to the entity Device from another service (in this case from com.pluto.user.manager) so, in the user.manager, I created an API that is supposed to link the device to the user (it's just adding an id to the user, nothing serious). And the compiler complains. I even tried to create a docker container with jdk, maven and git, and tried to compile there: same problem.
The class where the error appears is the following
package com.pluto.user.manager.controller;
import com.pippo.device.manager.data.model.Device; // problem here
import com.pluto.user.manager.data.model.User;
import com.pluto.user.manager.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
#RestController
#RequestMapping("/users")
public class UserController {
#Autowired
private UserService userService;
// various CRUD API here
// ...
#PostMapping(path = "/{id}/link", consumes = "application/json", produces = "application/json")
public User link(#PathVariable String id, #RequestBody Device device) {
return userService.linkToDevice(id, device.getId());
}
}
Please, can you help me understand what am I doing wrong?
Edit 1: adding pom.xml of user.manager as requested
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pluto</groupId>
<artifactId>user.manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>user.manager</name>
<description>User Manager Service</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.pippo</groupId>
<artifactId>device.manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</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>
<version>${project.parent.version}</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
and the output of "mvn clean package"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building user.manager 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # user.manager ---
[INFO] Deleting /mnt/e/Repository/GCP/exercise1/user.manager/target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # user.manager ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # user.manager ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /mnt/e/Repository/GCP/exercise1/user.manager/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[3,43] package com.pippo.device.manager.data.model does not exist
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[40,99] package com.pippo.device.manager.data.model does not exist
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.983 s
[INFO] Finished at: 2021-10-01T23:01:35+02:00
[INFO] Final Memory: 28M/100M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project user.manager: Compilation failure: Compilation failure:
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[3,43] package com.pippo.device.manager.data.model does not exist
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[40,99] package com.pippo.device.manager.data.model does not exist
[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
and output of jar -tvf /mnt/c/Users/sanvegeta/.m2/repository/com/pippo/device.manager/0.0.1-SNAPSHOT/device.manager-0.0.1-SNAPSHOT.jar
0 Fri Oct 01 08:59:58 CEST 2021 META-INF/
467 Fri Oct 01 08:59:58 CEST 2021 META-INF/MANIFEST.MF
0 Fri Feb 01 00:00:00 CET 1980 org/
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/
5871 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/ClassPathIndexFile.class
6806 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/ExecutableArchiveLauncher.class
3966 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/JarLauncher.class
1483 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/LaunchedURLClassLoader$DefinePackageCallType.class
1535 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class
11154 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/LaunchedURLClassLoader.class
5932 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/Launcher.class
1536 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/MainMethodRunner.class
266 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$1.class
1484 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
8128 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$ClassPathArchives.class
1953 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
18267 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher.class
1750 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/WarLauncher.class
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/
302 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/Archive$Entry.class
511 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/Archive$EntryFilter.class
4745 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/Archive.class
6093 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$AbstractIterator.class
2180 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$ArchiveIterator.class
1857 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$EntryIterator.class
1269 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
2527 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$SimpleJarFileArchive.class
5346 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive.class
2884 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$AbstractIterator.class
1981 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
1081 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
2528 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$NestedArchiveIterator.class
10349 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive.class
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/
485 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessData.class
282 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile$1.class
2680 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
3259 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class
4015 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile.class
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/
1438 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/AbstractJarFile$JarFileType.class
878 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/AbstractJarFile.class
4976 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/AsciiBytes.class
616 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/Bytes.class
295 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord$1.class
3319 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64End.class
2039 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64Locator.class
5029 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
6889 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
4624 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryParser.class
540 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
345 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/FileHeader.class
13649 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/Handler.class
3885 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarEntry.class
1458 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarEntryCertification.class
299 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarEntryFilter.class
2299 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFile$1.class
1299 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFile$JarEntryEnumeration.class
16312 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFile.class
1368 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$1.class
2258 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
1281 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$Offsets.class
1338 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$Zip64Offsets.class
1334 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$ZipOffsets.class
17280 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries.class
3512 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileWrapper.class
702 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarURLConnection$1.class
4302 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
9440 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarURLConnection.class
3559 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/StringSequence.class
1813 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/ZipInflaterInputStream.class
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/
293 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/JarMode.class
2201 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/JarModeLauncher.class
1292 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/TestJarMode.class
0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/util/
5174 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/util/SystemPropertyUtils.class
0 Fri Oct 01 08:59:58 CEST 2021 BOOT-INF/
0 Fri Oct 01 08:59:58 CEST 2021 BOOT-INF/classes/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/controller/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/data/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/data/model/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/repository/
0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/service/
0 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/
0 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/com.pippo/
0 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/com.pippo/device.manager/
804 Fri Oct 01 08:59:36 CEST 2021 BOOT-INF/classes/application.properties
737 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/Application.class
2433 Fri Oct 01 08:59:48 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/controller/DeviceController.class
1617 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/data/model/Device.class
364 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/repository/DeviceRepository.class
3530 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/service/DeviceService.class
1969 Fri Oct 01 08:47:32 CEST 2021 META-INF/maven/com.pippo/device.manager/pom.xml
67 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/com.pippo/device.manager/pom.properties
0 Fri Oct 01 08:59:58 CEST 2021 BOOT-INF/lib/
382204 Wed Sep 15 07:22:06 CEST 2021 BOOT-INF/lib/spring-aop-5.3.10.jar
2087074 Fri Feb 01 00:00:00 CET 1980 BOOT-INF/lib/aspectjweaver-1.9.7.jar
159222 Wed Mar 03 13:06:58 CET 2021 BOOT-INF/lib/HikariCP-4.0.3.jar
427946 Wed Sep 15 07:22:12 CEST 2021 BOOT-INF/lib/spring-jdbc-5.3.10.jar
15392 Fri Aug 02 22:14:54 CEST 2019 BOOT-INF/lib/jakarta.transaction-api-1.3.3.jar
164392 Fri Aug 02 16:59:46 CEST 2019 BOOT-INF/lib/jakarta.persistence-api-2.2.3.jar
7351256 Mon May 24 12:01:22 CEST 2021 BOOT-INF/lib/hibernate-core-5.4.32.Final.jar
60911 Tue May 25 13:11:32 CEST 2021 BOOT-INF/lib/jboss-logging-3.4.2.Final.jar
782774 Thu Mar 19 13:33:58 CET 2020 BOOT-INF/lib/javassist-3.27.0-GA.jar
3510658 Tue Mar 09 15:35:56 CET 2021 BOOT-INF/lib/byte-buddy-1.10.22.jar
445288 Wed Sep 06 11:15:04 CEST 2006 BOOT-INF/lib/antlr-2.7.7.jar
202552 Fri Jan 22 15:15:02 CET 2021 BOOT-INF/lib/jandex-2.2.3.Final.jar
67815 Sat Oct 19 22:46:30 CEST 2019 BOOT-INF/lib/classmate-1.5.1.jar
323630 Sun Apr 12 12:05:40 CEST 2020 BOOT-INF/lib/dom4j-2.1.3.jar
78948 Fri Oct 30 16:06:46 CET 2020 BOOT-INF/lib/hibernate-commons-annotations-5.1.2.Final.jar
1019255 Tue Jul 20 13:39:34 CEST 2021 BOOT-INF/lib/jaxb-runtime-2.3.5.jar
72008 Tue Jul 20 13:39:08 CEST 2021 BOOT-INF/lib/txw2-2.3.5.jar
29807 Thu Mar 18 15:25:56 CET 2021 BOOT-INF/lib/istack-commons-runtime-3.0.12.jar
68453 Thu Feb 20 18:37:08 CET 2020 BOOT-INF/lib/jakarta.activation-1.2.2.jar
375623 Fri Sep 17 09:20:56 CEST 2021 BOOT-INF/lib/spring-data-jpa-2.5.5.jar
1260499 Fri Sep 17 09:19:30 CEST 2021 BOOT-INF/lib/spring-data-commons-2.5.5.jar
204085 Wed Sep 15 07:22:22 CEST 2021 BOOT-INF/lib/spring-orm-5.3.10.jar
1267911 Wed Sep 15 07:22:10 CEST 2021 BOOT-INF/lib/spring-context-5.3.10.jar
333421 Wed Sep 15 07:22:10 CEST 2021 BOOT-INF/lib/spring-tx-5.3.10.jar
696648 Wed Sep 15 07:22:04 CEST 2021 BOOT-INF/lib/spring-beans-5.3.10.jar
41513 Tue Jul 20 13:56:20 CEST 2021 BOOT-INF/lib/slf4j-api-1.7.32.jar
47229 Wed Sep 15 07:22:24 CEST 2021 BOOT-INF/lib/spring-aspects-5.3.10.jar
1392938 Thu Sep 23 07:11:26 CEST 2021 BOOT-INF/lib/spring-boot-2.5.5.jar
1564860 Thu Sep 23 07:10:20 CEST 2021 BOOT-INF/lib/spring-boot-autoconfigure-2.5.5.jar
292027 Fri Sep 10 00:27:02 CEST 2021 BOOT-INF/lib/logback-classic-1.2.6.jar
472431 Fri Sep 10 00:15:50 CEST 2021 BOOT-INF/lib/logback-core-1.2.6.jar
17762 Sat Mar 06 22:13:24 CET 2021 BOOT-INF/lib/log4j-to-slf4j-2.14.1.jar
300365 Sat Mar 06 22:11:34 CET 2021 BOOT-INF/lib/log4j-api-2.14.1.jar
4589 Tue Jul 20 13:55:30 CEST 2021 BOOT-INF/lib/jul-to-slf4j-1.7.32.jar
25058 Fri Aug 02 11:08:52 CEST 2019 BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar
326914 Mon Feb 22 05:55:56 CET 2021 BOOT-INF/lib/snakeyaml-1.28.jar
1515991 Fri Aug 27 00:33:48 CEST 2021 BOOT-INF/lib/jackson-databind-2.12.5.jar
75704 Thu Aug 26 23:31:22 CEST 2021 BOOT-INF/lib/jackson-annotations-2.12.5.jar
365536 Thu Aug 26 23:57:50 CEST 2021 BOOT-INF/lib/jackson-core-2.12.5.jar
34438 Fri Aug 27 01:10:42 CEST 2021 BOOT-INF/lib/jackson-datatype-jdk8-2.12.5.jar
120362 Fri Aug 27 01:10:24 CEST 2021 BOOT-INF/lib/jackson-datatype-jsr310-2.12.5.jar
9440 Fri Aug 27 01:10:34 CEST 2021 BOOT-INF/lib/jackson-module-parameter-names-2.12.5.jar
3429357 Mon Sep 06 23:09:00 CEST 2021 BOOT-INF/lib/tomcat-embed-core-9.0.53.jar
255802 Mon Sep 06 23:09:00 CEST 2021 BOOT-INF/lib/tomcat-embed-el-9.0.53.jar
277386 Mon Sep 06 23:09:00 CEST 2021 BOOT-INF/lib/tomcat-embed-websocket-9.0.53.jar
1633568 Wed Sep 15 07:22:16 CEST 2021 BOOT-INF/lib/spring-web-5.3.10.jar
1027620 Wed Sep 15 07:22:26 CEST 2021 BOOT-INF/lib/spring-webmvc-5.3.10.jar
288281 Wed Sep 15 07:22:04 CEST 2021 BOOT-INF/lib/spring-expression-5.3.10.jar
93107 Tue Dec 19 16:23:24 CET 2017 BOOT-INF/lib/validation-api-2.0.1.Final.jar
2303679 Mon Oct 14 09:19:50 CEST 2019 BOOT-INF/lib/h2-1.4.200.jar
115638 Mon Jan 27 09:34:38 CET 2020 BOOT-INF/lib/jakarta.xml.bind-api-2.3.3.jar
46613 Thu Feb 20 18:37:30 CET 2020 BOOT-INF/lib/jakarta.activation-api-1.2.2.jar
1479606 Fri Feb 01 00:00:00 CET 1980 BOOT-INF/lib/spring-core-5.3.10.jar
24436 Wed Sep 15 07:21:48 CEST 2021 BOOT-INF/lib/spring-jcl-5.3.10.jar
29277 Fri Feb 01 00:00:00 CET 1980 BOOT-INF/lib/spring-boot-jarmode-layertools-2.5.5.jar
2403 Fri Oct 01 09:00:00 CEST 2021 BOOT-INF/classpath.idx
212 Fri Oct 01 09:00:00 CEST 2021 BOOT-INF/layers.idx
Edit 2 (closer to the resolution)
As Stephen suggested, the internal structure of the generated jar file seems wrong. I crafted an alternative jar file with the paths that don't start with BOOT-INF/classes, and the user.manager service compiles and runs just fine.
Now the question is: how do I instruct spring boot to either generate the correct structure or to "see" the classes?
I think you have the wrong dependency. By my reading of the jar -tf output, that looks like a SpringBoot executable JAR file. The Device.class file is there, but its path is not right ... for a normal Java compiler to resolve it:
This:
BOOT-INF/classes/com/pippo/device/manager/data/model/Device.class
needs to be this:
com/pippo/device/manager/data/model/Device.class
I can't find any trace of "com.pippo.*" using Google, so I am guessing that this is a private project.
But if you want use the com.pippo.device.manager classes in other modules, you need to modify its POM file to generate a regular JAR, and use that as the dependency.
One suggestion would be to refactor the existing com.pippo / device.manager project into a SpringBoot project and a (new) regular "library" JAR project, with the former depending on the latter. Put the classes that you want to reuse in com.pluto / project.manager into the "library" project.
Related
attempted to open sandboxed jar as a Trusted-Code but jar is properly signed
I am encountering a very strange behaviour with a Java Web Start application. On one particular machine (windows 7 64 bits, java SE Runtime ENvironment (build 1.7.0-b147)), the application refuses to start with the following error: attempted to open sandboxed jar https://example.com/jnlp/lib/LHC.jar as Trusted-Code The doc suggests that this particular jar contains "untrusted components". I don't know what untrusted components are but after some search it seems to indicate this is linked to particular classes or resources not signed inside the jar. This can't be the case as I get this result with the jarsigner utility: s 6501 Fri Jun 02 11:12:50 CEST 2017 META-INF/MANIFEST.MF 6359 Fri Jun 02 11:12:50 CEST 2017 META-INF/COMPANYBE.SF 4115 Fri Jun 02 11:12:50 CEST 2017 META-INF/COMPANYBE.RSA 0 Fri Jun 02 11:12:02 CEST 2017 META-INF/ 0 Fri Jun 02 11:12:02 CEST 2017 META-INF/maven/ 0 Fri Jun 02 11:12:02 CEST 2017 META-INF/maven/com.companygroup/ 0 Fri Jun 02 11:12:02 CEST 2017 META-INF/maven/com.companygroup/TestConnector/ 0 Fri Jun 02 11:12:02 CEST 2017 conf/ 0 Fri Jun 02 11:12:02 CEST 2017 Elevation/ 0 Fri Jun 02 11:12:02 CEST 2017 com/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/entity/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/gui/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/exception/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/http/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/actions/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/actions/list/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/main/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/thread/ 0 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/ 0 Fri Jun 02 11:12:02 CEST 2017 JNLP-INF/ 0 Fri Jun 02 11:12:02 CEST 2017 images/ 0 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/ 0 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/UnlimitedJCEPolicyJDK8/ 0 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/UnlimitedJCEPolicyJDK7/ 0 Fri Jun 02 11:12:02 CEST 2017 modules/ sm 14850 Fri Jun 02 11:12:02 CEST 2017 META-INF/maven/com.companygroup/TestConnector/pom.xml sm 119 Fri Jun 02 11:12:02 CEST 2017 META-INF/maven/com.companygroup/TestConnector/pom.properties sm 19759 Fri Jun 02 11:12:02 CEST 2017 conf/axis2.xml sm 1108 Fri Jun 02 11:12:02 CEST 2017 Elevation/elevate.cmd sm 4023 Fri Jun 02 11:12:02 CEST 2017 Elevation/elevate.vbs sm 1565 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/entity/LHCSeries_Instance.class sm 452 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/entity/RefStatus.class sm 2259 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/entity/RefStatus$Status.class sm 6239 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/entity/LHCSeries_Transfer.class sm 1880 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/entity/TransferType.class sm 2367 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/gui/JWSTrayIcon.class sm 916 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/gui/JWSTrayIcon$1.class sm 870 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/exception/SystemTrayUnsupportedException.class sm 1404 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/http/HttpServer$DefaultTempFileManagerFactory.class sm 3633 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/http/HttpServer$ClientHandler.class sm 10900 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/http/HttpServer.class sm 1715 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/http/HttpServer$MimeType.class sm 263 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/server/http/HttpServer$1.class sm 1506 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/actions/list/ListFiles$1.class sm 15039 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/actions/list/ListFiles.class sm 3100 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/main/ServiceMessageContainer.class sm 652 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/main/ServiceMessage.class sm 1739 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/main/TransferProgressUpdateMessage.class sm 17313 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/main/Main.class sm 742 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/main/Main$1.class sm 1922 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/thread/CompanyThreadManager.class sm 21190 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/thread/LHCSeries_TransferThread.class sm 3101 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/thread/LHCSeries_TransferThread$1.class sm 862 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/thread/LHCSeries_TransferThread$2.class sm 14261 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/thread/JobUpdaterThread.class sm 6683 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/SevenZipUtil.class sm 2612 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/SevenZipUtil$MyBZ2CreateCallback.class sm 2343 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/SevenZipUtil$MyExtractCallback.class sm 5733 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/CompanyConfiguration.class sm 2071 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/SevenZipUtil$MyBZ2TARExtractCallback.class sm 2328 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/SevenZipUtil$MyBZ2TARExtractCallback$1.class sm 2796 Fri Jun 02 11:12:02 CEST 2017 com/companygroup/companyclient/util/SevenZipUtil$MyExtractCallback$1.class sm 3864 Fri Jun 02 11:12:02 CEST 2017 STAR_companygroup_com2.jks sm 3128 Fri Jun 02 11:12:02 CEST 2017 keystore.jks sm 5413 Fri Jun 02 11:12:02 CEST 2017 JNLP-INF/APPLICATION_TEMPLATE.jnlp sm 1804 Fri Jun 02 11:12:02 CEST 2017 truststore.jks sm 636 Fri Jun 02 11:12:02 CEST 2017 images/bulb.gif sm 1656 Fri Jun 02 11:12:02 CEST 2017 log4j.properties sm 3023 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/UnlimitedJCEPolicyJDK8/US_export_policy.jar sm 3035 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/UnlimitedJCEPolicyJDK8/local_policy.jar sm 2487 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/UnlimitedJCEPolicyJDK7/US_export_policy.jar sm 2500 Fri Jun 02 11:12:02 CEST 2017 unlimitedJCE/UnlimitedJCEPolicyJDK7/local_policy.jar sm 4149 Fri Jun 02 11:12:02 CEST 2017 STAR_companygroup_com2.pkcs12 sm 9657 Fri Jun 02 11:12:02 CEST 2017 modules/rampart-1.6.2.mar If I remove the Trusted-Only: true in the manifest.MF of my jars, I get the following error: java.lang.SecurityException: attempted to open sandboxed jar https://example.com/jnlp/lib/bcprov-jdk15on.jar as a Trusted-Library on the bouncycastle provider re-signed with my certificate. This jar is also correctly signed according to the jarsigner. I am at loss and have no idea how to move forward from here.
There are similar issues faced by users. Please refer Some users gets Security Exception: Attempted to to open a sandboxed jar as a Trusted-Library Security Exception: Attempted to to open a sandboxed jar as a Trusted-Library
Keeping most recent date from a list of objects
I have an ordered list which is ordered by date, I want to keep the most recent date for each name in the list, for example there may be multiple entries for a name with different dates i want to keep only the most recent for that name, how can i achieve this for the following list? I mean a TreeMap which is ordered which maps dates to names, how can i remove for example, there is "Sun Feb 21 00:35:54 GMT 2016=Finley" then there is another "Sun Feb 21 01:03:41 GMT 2016=Finley" at a later date and so on, how could i remove all ones at later dates and only keep the recent ones? but for each name? Sharks: {Sun Feb 21 00:27:53 GMT 2016=Freo, Sun Feb 21 00:35:54 GMT 2016=Finley, Sun Feb 21 01:03:41 GMT 2016=Finley, Sun Feb 21 01:09:28 GMT 2016=Finley, Sun Feb 21 01:20:19 GMT 2016=Buddy , Sun Feb 21 01:35:51 GMT 2016=Finley, Sun Feb 21 01:53:30 GMT 2016=Buddy , Sun Feb 21 02:01:18 GMT 2016=Finley, Sun Feb 21 02:28:46 GMT 2016=Freo, Sun Feb 21 02:59:50 GMT 2016=Finley, Sun Feb 21 05:10:09 GMT 2016=Maroochy, Sun Feb 21 05:14:11 GMT 2016=Maroochy, Sun Feb 21 08:42:36 GMT 2016=Buddy , Mon Feb 22 01:54:28 GMT 2016=Finley, Mon Feb 22 02:31:59 GMT 2016=Buddy , Mon Feb 22 02:34:21 GMT 2016=Catalina, Mon Feb 22 02:45:31 GMT 2016=Buddy , Mon Feb 22 02:45:47 GMT 2016=Finley, Mon Feb 22 03:13:26 GMT 2016=Buddy , Mon Feb 22 05:05:20 GMT 2016=Maroochy, Mon Feb 22 05:15:45 GMT 2016=Freo, Mon Feb 22 07:51:13 GMT 2016=Mary Lee, Mon Feb 22 07:53:44 GMT 2016=Jax, Mon Feb 22 08:21:42 GMT 2016=Finley, Mon Feb 22 09:24:41 GMT 2016=Jax, Mon Feb 22 09:25:08 GMT 2016=Mary Lee, Tue Feb 23 00:58:46 GMT 2016=Katharine, Tue Feb 23 01:20:20 GMT 2016=Catalina, Tue Feb 23 02:23:06 GMT 2016=Katharine, Tue Feb 23 02:35:47 GMT 2016=Cathy , Tue Feb 23 02:37:01 GMT 2016=Mary Lee, Tue Feb 23 02:58:57 GMT 2016=Katharine, Tue Feb 23 03:17:37 GMT 2016=Katharine, Tue Feb 23 03:21:20 GMT 2016=Katharine, Tue Feb 23 03:39:36 GMT 2016=Cathy , Tue Feb 23 04:23:30 GMT 2016=Maroochy, Tue Feb 23 08:07:00 GMT 2016=Finley, Tue Feb 23 09:12:31 GMT 2016=Finley, Wed Feb 24 00:21:19 GMT 2016=Katharine, Wed Feb 24 01:10:39 GMT 2016=Freo, Wed Feb 24 01:12:05 GMT 2016=Buddy , Wed Feb 24 01:18:03 GMT 2016=Katharine, Wed Feb 24 02:25:28 GMT 2016=Buddy , Wed Feb 24 03:51:03 GMT 2016=Katharine, Wed Feb 24 04:50:55 GMT 2016=Katharine, Wed Feb 24 07:33:22 GMT 2016=Katharine}
I would put the data into a HashMap (name->date). If an entry for the name already exists, overwrite it if the date is more recent. In case you have trouble comparing the dates, use DateFormat to convert the strings into Date objects which you can compare.
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())); } }
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.
How to get folder paths inside a jar file?
Okay, so in the IDE it runs great and says the file exists, but once I pack it into a jar this code: File levelFolder = new File(getClass().getResource("data/level").getPath()); System.out.println("exists = " + levelFolder.exists()); says the folder doesn't exist. any idea why? edit: jar file listing. G:\java>jar tvf phantasyblade.jar 6574 Wed Nov 10 22:36:34 PST 2010 META-INF/MANIFEST.MF 6334 Wed Nov 10 22:36:34 PST 2010 META-INF/CYPRI.SF 992 Wed Nov 10 22:36:34 PST 2010 META-INF/CYPRI.RSA 0 Wed Nov 10 22:31:32 PST 2010 META-INF/ 717 Mon Nov 08 00:08:30 PST 2010 Switch.class 935 Wed Nov 10 22:21:14 PST 2010 Sword1.class 803 Tue Nov 09 13:42:38 PST 2010 SwordBlock.class 2674 Tue Nov 09 13:42:38 PST 2010 Thing.class 0 Wed Nov 10 22:32:56 PST 2010 data/ 0 Wed Nov 10 22:32:56 PST 2010 data/audio/ 108669 Mon Nov 30 22:32:02 PST 2009 data/audio/boss1.ogg 30866 Wed Nov 25 13:40:12 PST 2009 data/audio/edie.wav 11440 Wed Dec 02 15:22:00 PST 2009 data/audio/ehit.wav 191532 Fri Apr 16 07:32:46 PDT 2010 data/audio/itemget.wav 154856 Mon Nov 30 21:55:18 PST 2009 data/audio/map1.ogg 18572 Wed Aug 19 02:16:30 PDT 2009 data/audio/pdie.wav 30924 Wed Dec 02 15:02:54 PST 2009 data/audio/pget.wav 10044 Wed Aug 19 02:13:52 PDT 2009 data/audio/phit.wav 24920 Wed Dec 02 15:08:44 PST 2009 data/audio/plife.wav 17399 Mon Aug 24 17:40:00 PDT 2009 data/audio/sword.wav 71946 Mon Nov 30 22:36:08 PST 2009 data/audio/title.ogg 0 Wed Nov 10 22:32:56 PST 2010 data/graphics/ 5486 Mon Dec 07 23:15:46 PST 2009 data/graphics/alienzaku1.png 1372 Mon Dec 14 02:05:44 PST 2009 data/graphics/ammo15.png 888 Wed Nov 10 20:07:38 PST 2010 data/graphics/block.png 1841 Mon Dec 07 16:50:00 PST 2009 data/graphics/bluegem.png 101871 Mon Dec 07 22:59:30 PST 2009 data/graphics/boss1.png 9206 Mon Dec 14 13:21:26 PST 2009 data/graphics/bossblock1.png 280 Tue Nov 18 08:13:44 PST 2008 data/graphics/bullet.png 2831 Wed Dec 16 14:11:30 PST 2009 data/graphics/chargeshot.png 277 Tue Nov 18 16:12:32 PST 2008 data/graphics/ebullet.png 1928 Wed Dec 16 14:05:14 PST 2009 data/graphics/echargeshot.png 3573 Wed Dec 02 15:07:06 PST 2009 data/graphics/ehealth.png 6158 Mon Dec 14 22:17:06 PST 2009 data/graphics/gameover.png 1594 Mon Dec 07 16:49:32 PST 2009 data/graphics/greengem.png 5279 Mon Dec 07 16:49:44 PST 2009 data/graphics/health.png 5591 Wed Dec 16 22:37:20 PST 2009 data/graphics/hexcontainer.png 23037 Tue Dec 15 13:03:32 PST 2009 data/graphics/hud.png 8173 Thu Dec 03 00:22:14 PST 2009 data/graphics/hud1.png 280 Tue Nov 18 08:13:44 PST 2008 data/graphics/hudbullet.png 606 Wed Dec 02 04:58:50 PST 2009 data/graphics/hudgem.png 3527 Wed Dec 02 15:07:02 PST 2009 data/graphics/hudhealth.png 13726 Wed Dec 16 14:40:36 PST 2009 data/graphics/hunter.png 666 Wed Nov 10 21:09:54 PST 2010 data/graphics/key.png 11010 Thu Nov 26 11:14:02 PST 2009 data/graphics/levelclear.png 1306 Wed Nov 10 20:08:42 PST 2010 data/graphics/lockedblock.png 2340 Mon Dec 14 16:32:26 PST 2009 data/graphics/mapsword.png 1448 Wed Nov 10 20:20:58 PST 2010 data/graphics/moveblock.png 1660 Sun Nov 07 12:54:42 PST 2010 data/graphics/neblock.png 30258 Mon Dec 07 16:50:28 PST 2009 data/graphics/neoscout1.png 9569 Mon Dec 07 23:25:08 PST 2009 data/graphics/player.png 5903 Mon Dec 07 16:36:02 PST 2009 data/graphics/playerdead.png 3910 Fri Apr 16 07:23:12 PDT 2010 data/graphics/playerget.png 11966 Mon Dec 14 00:07:32 PST 2009 data/graphics/playerroll.png 1316 Wed Nov 10 20:12:18 PST 2010 data/graphics/stepswitch.png 2972 Mon Dec 07 23:22:08 PST 2009 data/graphics/sword.png 2972 Mon Dec 07 23:22:08 PST 2009 data/graphics/sword2.png 1450 Sun Nov 07 12:51:22 PST 2010 data/graphics/swordblock.png 10860 Fri Apr 16 07:29:08 PDT 2010 data/graphics/swordget.png 289531 Sun Dec 13 00:28:56 PST 2009 data/graphics/tilemap.png 134821 Tue Dec 15 00:28:38 PST 2009 data/graphics/title.png 6044 Wed Nov 25 17:39:50 PST 2009 data/graphics/win.png 1511 Wed Nov 10 10:38:02 PST 2010 data/graphics/zbutton.png 0 Wed Nov 10 22:32:56 PST 2010 data/level/ 2132 Wed Nov 10 20:59:58 PST 2010 data/level/map1.lv 949 Wed Nov 10 22:23:24 PST 2010 data/level/map2.lv 813 Wed Nov 10 21:07:10 PST 2010 data/level/map3.lv 1370 Sun Nov 07 12:37:42 PST 2010 Ammo15.class 1369 Sun Nov 07 12:37:42 PST 2010 BlueGem.class 4789 Sun Nov 07 18:26:34 PST 2010 Boss1.class 825 Mon Nov 08 05:34:02 PST 2010 BossBlock1.class 6159 Sun Nov 07 18:30:54 PST 2010 Bullet.class 3487 Sun Nov 07 12:37:42 PST 2010 ChargeShot.class 8425 Wed Nov 10 22:01:54 PST 2010 Enemy.class 5837 Wed Nov 10 22:01:54 PST 2010 Enemy1.class 6164 Wed Nov 10 22:01:54 PST 2010 Enemy2.class 4902 Sun Nov 07 18:26:34 PST 2010 Enemy3.class 7780 Sun Nov 07 18:26:34 PST 2010 Enemy4.class 30632 Wed Nov 10 22:19:38 PST 2010 Game1.class 656 Tue Nov 09 13:42:32 PST 2010 GrabBlock1.class 1372 Sun Nov 07 12:37:42 PST 2010 GreenGem.class 1074 Tue Nov 09 13:42:34 PST 2010 HexContainer.class 1372 Sun Nov 07 12:37:42 PST 2010 Item.class 811 Wed Nov 10 20:13:46 PST 2010 Key.class 609 Mon Nov 08 20:10:04 PST 2010 Level.class 1368 Sun Nov 07 12:37:42 PST 2010 Life.class 656 Wed Nov 10 16:41:50 PST 2010 LockedBlock.class 2004 Sun Nov 07 18:26:34 PST 2010 Map.class 751 Tue Nov 09 13:42:36 PST 2010 NEBlock.class 659 Tue Nov 09 13:42:36 PST 2010 NormalBlock1.class 18722 Wed Nov 10 22:02:28 PST 2010 Player.class 1726 Mon Nov 08 05:34:06 PST 2010 StepSwitch.class G:\java>
generally it's because the class you getClass()'d is in package com.something.app, and so with a relative path your data has to be in com/something/app/data/level. Otherwise use an absolute path. To see where things are in your jarfile: jar tvf myapp.jar [ok, after a lot of back-and-forth and some testing]... jcomeau#intrepid:/tmp$ cat test.java; java -cp test.jar test; jar tvf test.jar import java.io.*; public class test { public static void main(String[] args) { //System.out.println(test.class.getResource("data/level")); try { System.out.println(new File(test.class.getResource("data/level").getPath())); System.out.println(test.class.getResourceAsStream("data/level/test").read()); } catch (Exception whatever) { System.err.println("error: " + whatever); } } } file:/tmp/test.jar!/data/level 116 0 Thu Nov 11 00:36:14 PST 2010 META-INF/ 40 Thu Nov 11 00:36:14 PST 2010 META-INF/MANIFEST.MF 1362 Thu Nov 11 00:35:46 PST 2010 test.class 0 Wed Nov 10 07:53:18 PST 2010 data/ 0 Wed Nov 10 07:53:28 PST 2010 data/level/ 5 Wed Nov 10 07:53:28 PST 2010 data/level/test jcomeau#intrepid:/tmp$ I'm too tired to continue, but main() prints 116, which is the ASCII value of "t", the result of read() which reads in the first byte. That should be enough to prove that getResourceAsStream() will enable you to access your resources. There ought to be a way to do it with File() also, but the path returned is strange with that '!' separating the path to the jarfile with the path inside the jarfile. I've never dealt with that before.
Enumeration<URL> resources = getClass().getClassLoader().getResources("data/level"); System.out.println("exists = " + resources.hasMoreElements());