I have a spring boot app which is giving the below error on creating Persistence EntityManager factory.
Persistence.createEntityManagerFactory
The war file is available under
/opt/test/app/app.war
and WEB-INF/classes also present in this war file.
But classloader is failing with the below error.
Is there any permission missing?
oggerName="org.hibernate.orm.url" threadName="main" txnId="" HHH10000002: File or directory named by URL [file:/opt/test/app/app.war!/WEB-INF/classes] could not be found. URL will be ignored
java.io.FileNotFoundException: /opt/test/app/app.war!/WEB-INF/classes (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.resolveJarFileReference(JarFileBasedArchiveDescriptor.java:165)
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:51)
at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:47)
at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:75)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:114)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:71)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:52)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
Docker file reference,
FROM alpine/jdk1.8:latest
RUN mkdir -p /opt/test/app
COPY app.war /opt/test/app/app.war
CMD java -jar /opt/test/app/app.war
In the pom.xml, change the packaging to jar
Related
Description: I have built an application that fetches a HDFS(Hadoop Distributed File System) File from a Remote Cluster on which Kerberos Authentication is applied. I could executed HDFS.copyToLocalFile(path1, path2) from Eclipse and it worked fine. But when I export the project as a runnable jar and try to run it through command line, it throws the below error. Note: I've followed the steps mentioned #https://sourceforge.net/p/jsch/mailman/message/26939797/ and was successful in running the project from Eclipse. I've checked for additional files in Eclipse but couldn't find any. I have Kerberos V5 MIT installed along with Network Identity Manager (4.0 version)
Caused by: java.io.IOException: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]
at org.apache.hadoop.ipc.Client$Connection$1.run(Client.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Unknown Source)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.ipc.Client$Connection.handleSaslConnectionFailure(Client.java:643)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:730)
at org.apache.hadoop.ipc.Client$Connection.access$2800(Client.java:368)
at org.apache.hadoop.ipc.Client.getConnection(Client.java:1521)
at org.apache.hadoop.ipc.Client.call(Client.java:1438)
... 70 more
Caused by: org.apache.hadoop.security.AccessControlException: Client cannot authenticate via:[TOKEN, KERBEROS]
at org.apache.hadoop.security.SaslRpcClient.selectSaslClient(SaslRpcClient.java:172)
at org.apache.hadoop.security.SaslRpcClient.saslConnect(SaslRpcClient.java:396)
at org.apache.hadoop.ipc.Client$Connection.setupSaslConnection(Client.java:553)
at org.apache.hadoop.ipc.Client$Connection.access$1800(Client.java:368)
at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:722)
at org.apache.hadoop.ipc.Client$Connection$2.run(Client.java:718)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Unknown Source)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:717)
... 73 more
Note: I've configured the eclipsed related parameters into a Configuration.xml and bundled it into the classpath.
<property>
<name>java.security.auth.login.config</name>
<value>./Configuration/login.conf</value>
</property>
<property>
<name>java.security.krb5.conf</name>
<value>./Configuration/krb5.conf</value>
</property>
<property>
<name>javax.security.auth.useSubjectCredsOnly</name>
<value>false</value>
</property>
I think that the Kerberos authentication fails, because your login.conf and krb5.conf files can't be found on runtime when using the JAR.
I had a similar problem, when I tried to access a file in my assets folder from the JAR file. The point is, that the paths change somehow when exporting the package as JAR. Do you have an opportunity to check the file paths somehow in your code, e.g.
String resourceFile = YourClass.class.getResource("/krb5.conf").getFile();
// check if resourceFile is null!
If this class.getResource(...) command works on running via IDE, but won't in your JAR, the problem is the difference in the file location.
I think this post could help you: How to get a path to a resource in a Java JAR file
C:\Users\sunka\Desktop\CS DEPT\fall 2k16\information structures>jar
-xvf week2.zip
java.io.FileNotFoundException: week2.zip (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.tools.jar.Main.run(Main.java:307)
at sun.tools.jar.Main.main(Main.java:1288)
When I am trying to unzip using jar -xvf, I am getting file not found exception. I used the same command in my office, it was working. I made sure that zip file and jar file are present in the directory.
Check if you in same directory where you have zip file placed.
Because if JAVA path is set properly and your are giving right zip file name with correct path it works fine.
I wrote a Puppet to install Play 2.1.1 on Virtual Machine running CentOS 6.2.
The Puppet executed the following two commands:
/usr/bin/wget http://downloads.typesafe.com/play/2.1.1/play-2.1.1.zip
/usr/bin/unzip play-2.1.1.zip
When I run play command inside the package, it shows the following error message:
java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
at java.io.FileWriter.<init>(FileWriter.java:90)
at xsbt.boot.Update.<init>(Checks.java:51)
at xsbt.boot.Launch.update(Launch.scala:275)
at xsbt.boot.Launch$$anonfun$jnaLoader$1.apply(Launch.scala:120)
at scala.Option.getOrElse(Option.scala:108)
at xsbt.boot.Launch.jnaLoader$2f324eef(Launch.scala:115)
at xsbt.boot.Launch.<init>(Launch.scala:94)
at xsbt.boot.Launcher$.apply(Launch.scala:290)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:31)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
I didn't change a single line of code in the play-2.1.1 directory. I googled around for the error message, but did not find any useful answer. Could anyone point out what is the problem?
If the file does not exist and cannot be created,FileOutputStream will raise a FileNotFoundException (yes, this seems weird, but see the javadoc).
This error probably means that the user that started play does not have the proper permissions to create ~/play-2.1.1/framework/sbt/boot/update.log or its parent directories.
I am running selenium script using ant task..it is working fine using command prompt..but from ant task, it is not working..How to solve this?
<testcase classname="junit.framework.TestSuite" name="com.openbravo.test.integration.erp.testsuites.regression.MRC0000_Logging" time="0.0010">
<error message="config/OpenbravoERPTest.properties (No such file or directory)" type="java.io.FileNotFoundException">java.io.FileNotFoundException: config/OpenbravoERPTest.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at com.openbravo.test.integration.erp.testscripts.OpenbravoERPTest.loadProperties(OpenbravoERPTest.java:117)
at com.openbravo.test.integration.erp.testscripts.OpenbravoERPTest.setUpBeforeClass(OpenbravoERPTest.java:105)
at org.eclipse.ant.internal.launching.remote.EclipseSingleCheckExecutor.executeTargets(EclipseSingleCheckExecutor.java:30)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
</error>
</testcase>
<system-out><![CDATA[asd
]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
Make sure that the directory containing your config directory is in the classpath.
The path name is relative: config/OpenbravoERPTest.properties
Are you sure that you're executing the script from command line in the right directory?
I exported a project that reads 2 configuration files. However, when I execute the jar, it gets this error:
Error: java.io.FileNotFoundException: config/dbConnection.config (No such file or directory)
Error: java.io.FileNotFoundException: config/test.config (No such file or directory)
com.smart.ets.services.ServiceException: com.smart.ets.services.ConfigErrorException
at com.smart.ets.services.TransactionServiceImpl.getConfigData(TransactionServiceImpl.java:30)
at com.smart.ets.controllers.Simulator.getTransactionSimulationResults(Simulator.java:41)
at com.smart.ets.controllers.Simulator.main(Simulator.java:26)
Caused by: com.smart.ets.services.ConfigErrorException
... 3 more
mickey91#mickey-espiritu:~/Documents/Dropbox$ java -jar ETS.jar
Error: java.io.FileNotFoundException: config/dbConnection.config (No such file or directory)
Error: java.io.FileNotFoundException: config/test.config (No such file or directory)
com.smart.ets.services.ServiceException: com.smart.ets.services.ConfigErrorException
at com.smart.ets.services.TransactionServiceImpl.getConfigData(TransactionServiceImpl.java:30)
at com.smart.ets.controllers.Simulator.getTransactionSimulationResults(Simulator.java:41)
at com.smart.ets.controllers.Simulator.main(Simulator.java:26)
Caused by: com.sm
art.ets.services.ConfigErrorException
... 3 more
Any way to fix this? It works if I run the project(not the jar file of the project)
You neglect to mention how you're accessing the files, but from the error it looks like you're trying to access them as files--but they're not, they're resources on the classpath.
As such, you should be using getResourceAsStream. The name of the resource would be the package-relative path.