SecurityException: Can not initialize cryptographic mechanism - java

I need to fix the problem of
SecurityException: Can not initialize cryptographic mechanism
Following up on OpenJDK 11 error "Can not initialize cryptographic mechanism", as its answer is unable to solve my problem
inspecting java.security.properties from within running JVM:
System.getProperty("java.security.properties");
It should be present and pointing at a file. Inspect that file and make sure it has the following property crypto.policy=unlimited and the folder called unlimited is available from where the policy file is.
However, I got null output for both java under Windows and Linux.
The above answer said that
it is <jre_home>/conf/security/policy/
and my situation is that I don't have jre however I do have the /conf/security/policy/ directory under java_home, for both java under Windows and Linux.
Directory of C:\Program Files\OpenJDK\jdk-18.0.1.1\conf\security\policy
04/25/2022 04:59 PM <DIR> .
04/25/2022 04:59 PM <DIR> ..
04/25/2022 04:59 PM <DIR> limited
04/25/2022 04:59 PM 2,390 README.txt
04/25/2022 04:59 PM <DIR> unlimited
1 File(s) 2,390 bytes
$ ls -l /home/foo/.sdkman/candidates/java/17.0.3-oracle/conf/security/policy
total 4
-rw-r----- 1 foo foo 2390 2022-03-09 17:40 READfoo.txt
drwxrwx--x 1 foo foo 4096 2022-06-03 12:45 limited
drwxrwx--x 1 foo foo 4096 2022-06-03 12:45 unlimited

See Cryptographic Strength Configuration ...and build the path with $JAVA_HOME.
On Linux the default paths are:
JDK8: $JAVA_HOME/jre/lib/security/java.security
JDK11: $JAVA_HOME/conf/security
JDK14: $JAVA_HOME/conf/security, mostly sym-linked to /etc/java-14-openjdk/security.
"Jurisdiction Policy File" java.security should have crypto.policy = unlimited set from JDK9 onwards; policies can be found $JAVA_HOME/conf/security/unlimited/default_US_export.policy.

Related

Why does System.getProperty("java.io.tmpdir") return a read-only directory on Mac OS X Catalina 10.15

This method used to return a writable directory until Mac OS X Mojave. Starting with Catalina.
Is there a way to add writability to the permissions of this temporary dir returned?
ls -larth
/var/folders/qx/045nmsxx55575_gqycvvs1480000gp/T/1579829982927-0 total 16
drwxr-xr-x 4 me staff 128B Jan 23 17:39 .
drwx------# 118 me staff 3.7K Jan 23 17:39 ..
It IS writable; that line means it is a directory, and the directory's owner can write to it just fine (which, would be you, and by extension, all processes you invoke).
The problem with the old /tmp solution is that everyone and everything can write to it, so using it for just about anything is a security issue.

Netbeans set root as author

I'm running Linux Mint 18.3 cinnamon 64 bits
I just downloaded Apache NetBeans IDE 9.0
It wasn't necessary to run any script to install it, i just had to run the following command to launch it: sudo /opt/netbeans/bin/netbeans
Then enter my password and netbeans opens.
Then i made a launcher for the program because i didn't want to type the command and my password every time i open netbeans.
But the launcher didn't worked.
I realize that i didn't put "sudo" in the command that the launcher would execute so i put it. And didn't work.
I thought that it wasn't working because the launcher executes sudo /opt/netbeans/bin/netbeans but don't put the password.
After some research i end up adding star_man ALL=(ALL) NOPASSWD: /opt/netbeans/bin/netbeans at the end of /etc/sudoers and it finally works. But when i create a new project Netbeans sets root as the author of every file it creates.
For example, when i type ls -l in my project directory it outputs this:
-rw-r--r-- 1 root root 3527 sep 15 20:01 build.xml
-rw-r--r-- 1 root root 82 sep 15 20:01 manifest.mf
drwxr-xr-x 3 root root 4096 sep 15 20:01 nbproject
drwxr-xr-x 3 root root 4096 sep 15 20:01 src
Root is the group and the owner of every file an directory.
This causes that when Netbeans generates documentation files it put "root" instead my username.
Update:
I only can start neatbeans as root (sudo ./netbeans).
when i run neatbean without sudo from the terminal it looks like it's starting:screen shot
but then it closes.
This is the output:
>Log Session: Sunday, September 16, 2018 at 12:58:20 PM Eastern Daylight Time
>System Info:
Product Version = Apache NetBeans IDE 9.0 (Build incubator-netbeans-release-334-on-20180708)
Operating System = Linux version 4.15.0-34-generic running on amd64
Java; VM; Vendor = 10.0.1; Java HotSpot(TM) 64-Bit Server VM 10.0.1+10; Oracle Corporation
Runtime = Java(TM) SE Runtime Environment 10.0.1+10
Java Home = /opt/java/jdk-10.0.1
System Locale; Encoding = es_DO (nb); UTF-8
Home Directory = /home/star_man
Current Directory = /opt/netbeans
User Directory = /home/star_man/.netbeans/9.0
Cache Directory = /home/star_man/.cache/netbeans/9.0
Installation = /opt/netbeans/nb
/opt/netbeans/ide
/opt/netbeans/extide
/opt/netbeans/java
/opt/netbeans/apisupport
/opt/netbeans/websvccommon
/opt/netbeans/profiler
/opt/netbeans/harness
/opt/netbeans/javafx
/opt/netbeans/platform
Boot & Ext. Classpath =
Application Classpath = /opt/netbeans/platform/lib/boot.jar:/opt/netbeans/platform/lib/org-openide-modules.jar:/opt/netbeans/platform/lib/org-openide-util.jar:/opt/netbeans/platform/lib/org-openide-util-lookup.jar:/opt/netbeans/platform/lib/org-openide-util-ui.jar
Startup Classpath = /opt/netbeans/platform/core/core-base.jar:/opt/netbeans/platform/core/org-netbeans-libs-asm.jar:/opt/netbeans/platform/core/asm-all-5.0.1.jar:/opt/netbeans/platform/core/org-openide-filesystems.jar:/opt/netbeans/platform/core/org-openide-filesystems-compat8.jar:/opt/netbeans/platform/core/core.jar:/opt/netbeans/nb/core/org-netbeans-upgrader.jar:/opt/netbeans/nb/core/locale/core_nb.jar
-------------------------------------------------------------------------------
INFO [org.netbeans.modules.netbinox]: Install area set to file:/opt/netbeans/
!SESSION 2018-09-16 12:58:21.698 -----------------------------------------------
eclipse.buildId=unknown
java.version=10.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=es_DO
!ENTRY org.eclipse.osgi 4 0 2018-09-16 12:58:21.706
!MESSAGE Error reading configuration: Permission denied
!STACK 0
java.io.IOException: Permission denied
at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.base/java.io.File.createTempFile(File.java:2090)
at org.eclipse.osgi.storagemanager.StorageManager.initializeInstanceFile(StorageManager.java:188)
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:708)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initFileManager(BaseStorage.java:226)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initialize(BaseStorage.java:160)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:123)
at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:192)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:67)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:37)
at org.eclipse.osgi.launch.Equinox.init(Equinox.java:178)
at org.netbeans.modules.netbinox.Netbinox.init(Netbinox.java:61)
at org.netbeans.core.netigso.Netigso.prepare(Netigso.java:145)
at org.netbeans.NetigsoHandle.turnOn(NetigsoHandle.java:115)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1331)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1148)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315)
at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251)
at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:156)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:125)
at org.netbeans.core.startup.Main.start(Main.java:282)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
at java.base/java.lang.Thread.run(Thread.java:844)
java.lang.RuntimeException: Permission denied
at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:194)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:67)
at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:37)
at org.eclipse.osgi.launch.Equinox.init(Equinox.java:178)
at org.netbeans.modules.netbinox.Netbinox.init(Netbinox.java:61)
at org.netbeans.core.netigso.Netigso.prepare(Netigso.java:145)
at org.netbeans.NetigsoHandle.turnOn(NetigsoHandle.java:115)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1331)
at org.netbeans.ModuleManager.enable(ModuleManager.java:1148)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315)
at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251)
at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:156)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:125)
at org.netbeans.core.startup.Main.start(Main.java:282)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.io.IOException: Permission denied
at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.base/java.io.File.createTempFile(File.java:2090)
at org.eclipse.osgi.storagemanager.StorageManager.initializeInstanceFile(StorageManager.java:188)
at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:708)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initFileManager(BaseStorage.java:226)
at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initialize(BaseStorage.java:160)
at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:123)
at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:192)
... 16 more
I find out that every file and directory under ~/.netbeans has root as owner and group. I thought that might be the problem so i changed the owner and group with ~/.netbeans $ sudo chown -R myusername: .netbeans/. And still i'm only able to run netbeans as root.
This is a basic unix permissions problem.
For reasons that escape me, you used sudo to launch the netbeans IDE.
- You should not have done that.
- You should not have needed to do that!
When you use sudo to run something, you are typically running as the root user. (That is what sudo does!)
So, naturally, the something (in this case, the netbeans application run using sudo) will create files and directories owned by the "root" user. So when you try to update them as a normal user, the operating system says "Nope: you don't own those files / directories, so you can't modify them.".
Solution: use the chown command to change the ownership of the files and the directories as required.
How? Read man chown, or look for a tutorial on how to change the ownership of a file.
Hint: you will need to use sudo when chowning ...
Hint 2: be very, very careful when you use sudo, because sudo has the power to trash your system if you make a mistake.

how do i find where JAVA_OPTS data is stored?

A CentOS 7 server has Java 7 and tomcat 8 installed. I need to set the permgen space, but typing printenv on the command line does not include JAVA_OPTS in the list of environmental variables. I typed ps to get the list of running processes, and then I typed jmap -heap <pid> with the pid from the running java process, which listed values for MaxPermSize and PermSize among other values.
How do I set new values for these properties in a way that will persist when the system is rebooted, etc.? I hesitate to just create a JAVA_OPTS variable if the server in question has another place where it stores these persistent values.
EDIT:
As per #ChrisRobak's suggestion, I went searching for tomcat conf files. There is no /etc/tomcat directory, but /etc has directories called /etc/java, /etc/.java, /etc/jvm, and /etc/jvm-common. Also, the tomcat conf is as follows:
[root#myserver tomcat]# cd /opt/tomcat/conf
[root#myserver conf]# ls -al
total 280
drwxrwx---. 3 root root 4096 Oct 30 20:02 .
drwxr-xr-x. 14 root root 4096 Oct 30 20:58 ..
drwxrwx---. 7 root root 4096 Oct 30 21:00 Catalina
-rwxrwx---. 1 root root 12624 Nov 2 2014 catalina.policy
-rwxrwx---. 1 root root 6560 Nov 2 2014 catalina.properties
-rwxrwx---. 1 root root 1852 Jan 2 2015 context.xml
-rwxrwx---. 1 root root 3451 Nov 2 2014 logging.properties
-rwxr-x--- 1 root root 5018 Oct 30 21:52 server.xml
-rwxrwx---. 1 root root 1783 Nov 2 2014 tomcat-users.xml
-rwxrwx---. 1 root root 1888 Nov 2 2014 tomcat-users.xsd
-rwxrwx---. 1 root root 168082 Nov 2 2014 web.xml
[root#myserver conf]#
Which file should I look in?
Alternatively, is there a command line way of setting the Java options which will not only be persistent, but also not cause side effects due to conflicts with config files? I would just create a JAVA_OPTS variable if I thought the rest of the server would go to the JAVA_OPTS as the default.
ANSWER?
When none of the config files and scripts seemed to have JAVA_OPTS set, I finally just decided to type the following in the CENTOS 7 terminal:
export JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"
The result is that the MaxPermSize has been reset. If anyone else has a specific answer to CentOS 7 that is better than this, please alert me.
I think you can persist those in
/etc/tomcat8/tomcat8.conf
or a similar variant, the server i had access to was /etc/tomcat5/tomcat5.conf but i don't know about your version in particular

Why is Tomcat throwing FileNotFoundExceptions for existing JAR files?

I'd like to know what could cause Tomcat or the native Java ZipFile.open
method to claim that a file does not exist when it actually does? This
has been a blocking issue for some of my work for the past month. It's
happening when attempting to run the tomcat7-maven-plugin. It works fine
on most machines, including mine (OSX), but fails on our build server
(LINUX) and one of my co-workers' boxes (OSX, same model laptop as mine).
Here's the error as seen in a Maven build:
[INFO] --- tomcat7-maven-plugin:2.2:run (start-tomcat) # PROJECT ---
[INFO] Running war on http://localhost:8080/contentmain
[INFO] Using existing Tomcat server configuration at
/WORKSPACE/PROJECT/tomcat7
Feb 05, 2015 11:17:53 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path:
/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Feb 05, 2015 11:17:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Feb 05, 2015 11:17:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Feb 05, 2015 11:17:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8443"]
Feb 05, 2015 11:17:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 651 ms
Feb 05, 2015 11:17:54 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Catalina
Feb 05, 2015 11:17:54 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Feb 05, 2015 11:17:54 PM org.apache.tomcat.util.scan.StandardJarScanner
scan
WARNING: Failed to scan JAR
[file:/WORKSPACE/tomcat7/webapps/../../target/PROJECT/WEB-INF/lib/openws-1.
5.1.jar] from WEB-INF/lib
java.io.FileNotFoundException:
/WORKSPACE/PROJECT/tomcat7/webapps/../../target/PROJECT/WEB-INF/lib/openws-
1.5.1.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.jar.JarFile.<init>(JarFile.java:154)
at java.util.jar.JarFile.<init>(JarFile.java:91)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122
)
at
sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:
89)
at org.apache.tomcat.util.scan.FileUrlJar.<init>(FileUrlJar.java:41)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:34)
at
org.apache.catalina.startup.ContextConfig$FragmentJarScannerCallback.scan(C
ontextConfig.java:2612)
at
org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.j
ava:259)
at
org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java
:178)
at
org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(Contex
tConfig.java:1868)
at
org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1256
)
at
org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java
:873)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java
:371)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppo
rt.java:117)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.jav
a:90)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java
:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1
559)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1
549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1
145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
615)
at java.lang.Thread.run(Thread.java:745)
This error repeats for every JAR file in the project which was pulled in
from Maven dependencies. There are hundreds of these.
Note that I've placed a breakpoint at the ZipFile.open call on one of the
failing machines and performed the following in a separate terminal:
cd /WORKSPACE/PROJECT/tomcat7/webapps/../../target/PROJECT/WEB-INF/lib/
ls -la
I can confirm that all of the "missing" JAR files were there immediately
before the native open method is called and the exceptions are thrown
which claim that the files aren't there. This led me to suspect that the
JAR files may be corrupted, so I copied one of the failing JAR files from
my co-workers' machine and performed a diff with a local copy I had
following a successful build and execution. They were identical, so it
appears that the "corrupt JAR" theory is out.
I've also tried the following (without success):
Shortening the path used (I read somewhere that there might be a 256
character limit).
Moving the JAR files to a different directory and changing the Tomcat
configuration to point to the new location (they were under resources and
I moved them to the project base.dir).
Setting various JVM heap sizes from Xmx256 to Xmx4096 (I read in a few
posts that memory issues can cause Tomcat to claim that files are missing).
Removing the permgen settings that we normally use for our webapp.
Setting the "jarScanAllDirectories" option to either false or true for
the tomcat7-maven-plugin.
Downloading the sources for the tomcat-maven-plugin (this includes the
tomcat7-maven-plugin) from Apache SVN, attaching them with a remote
debugger to Maven and stepping through the execution (everything seems
identical right up until the native ZipFile.open call).
Playing around with various Jenkins job settings for Maven on the build
server (probably irrelevant since this also fails on a coworker's machine
without Jenkins being involved).
Comparing all of the environment variables used by our webapp to those
used by my coworker (they're identical).
Comparing JDK versions (our entire org is standardized on 1.7.0_45).
Comparing Tomcat versions (we have explicit pom.xml file dependencies for
the tomcat7-maven-plugin on version 7.0.53).
Waiting and hoping that the problem solves itself.
Asking all of my co-workers to take a look (this led to trying some of
the above, but the problem still has not been solved).
I'm at my wit's end here. I've been up past midnight for several days
just trying to get this thing to work. What's left to look at?
UPDATE (2/10/2015): It's been suggested that this is caused by missing file permissions on the Jenkins machine where this is running. I don't have access to the server where this is happening, but I did get a script to run there:
echo Displaying JAR files with current permissions...
ls -la ./target/MyProject/WEB-INF/lib/
echo Adding read, write, and execute permissions to JAR files...
chmod -R 777 ./target/MyProject/WEB-INF/lib/
echo Displaying JAR files with updated permissions...
ls -la ./target/MyProject/WEB-INF/lib/
This produces output like the following:
[INFO] --- exec-maven-plugin:1.3.2:exec (update_jar_file_permissions) #
MyProject ---
Displaying JAR files with current permissions...
total 124556
drwxr-xr-x 2 jenkins users 20480 Feb 10 17:26 .
drwxr-xr-x 6 jenkins users 4096 Feb 10 17:26 ..
-rw-r--r-- 1 jenkins users 62983 Jan 22 00:11 activation-1.1.jar
-rw-r--r-- 1 jenkins users 351656 Jan 22 00:25 amqp-client-3.1.3.jar
-rw-r--r-- 1 jenkins users 74080 Jan 22 00:25 annotations-2.0.0.jar
-rw-r--r-- 1 jenkins users 445288 Jan 22 00:25 antlr-2.7.7.jar
-rw-r--r-- 1 jenkins users 895124 Jan 22 00:25 antlr-3.2.jar
Adding read, write, and execute permissions to JAR files...
Displaying JAR files with updated permissions...
total 124556
drwxrwxrwx 2 jenkins users 20480 Feb 10 17:26 .
drwxr-xr-x 6 jenkins users 4096 Feb 10 17:26 ..
-rwxrwxrwx 1 jenkins users 62983 Jan 22 00:11 activation-1.1.jar
-rwxrwxrwx 1 jenkins users 351656 Jan 22 00:25 amqp-client-3.1.3.jar
-rwxrwxrwx 1 jenkins users 74080 Jan 22 00:25 annotations-2.0.0.jar
-rwxrwxrwx 1 jenkins users 445288 Jan 22 00:25 antlr-2.7.7.jar
-rwxrwxrwx 1 jenkins users 895124 Jan 22 00:25 antlr-3.2.jar
As you can see, there were missing permissions. However, this hasn't
solved the problem:
Feb 10, 2015 5:27:54 PM org.apache.tomcat.util.scan.StandardJarScanner scan
WARNING: Failed to scan JAR [file:/opt/jenkins/workspace/MY_JENKINS_JOB/tomcat7/webapps/../../target/MY_PROJECT/WEB-INF/lib/activation-1.1.jar] from WEB-INF/lib
java.io.FileNotFoundException: /opt/jenkins/workspace/MY_JENKINS_JOB/tomcat7/webapps/../../target/MY_PROJECT/WEB-INF/lib/activation-1.1.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
The script was run right before tomcat7-maven-plugin. The permissions should have been in place and the JAR files should have been extractable. I still don't understand why this isn't working.
It turns out this wasn't a permissions issue at all. For some reason copying the JAR files out of the directory and back into it caused them to be picked up (I read this in a suggestion somewhere). Reading the 'man' entry for cp I see that it doesn't preserve "Access Control Lists (ACLs) and Extended Attributes (EAs), including resource forks" unless the -p flag is set (this is on by default when using mv). My guess is that removing this "access control" information somehow made the files accessible to the tomcat7-maven-plugin. It seems a little sketchy that I don't really know the root cause of the problem, but I'm happy that it's now fixed.
If somebody can definitively explain why this worked then I'll accept that as an answer instead of this one.

Embedding Java JApplet in HTML page when using Sockets

I am having trouble with getting and applet to work on an HTML page. When I remove the socket connection from the applet class and test the applet on an HTML page the applet displays but when I add the socket connection back in the class file the applet doesn't display and the Java console appears with no stack trace. I'm sure this is a security reason because I'm using socket connections so what I did was create a signed jar file and placed that in the applet tag as so:
<APPLET codebase="classes" archive="captureaudio/AppletTest.jar" code="captureaudio/AppletTest.class" width=350 height=200></APPLET>
But creating this signature has not worked.
Can somebody help me with this?
UPDATED
In response to Andrew Thompson
No im not prompted to accept digital signed code
No the applet im currently testing is locally
Yes the applet is trying to connect back to the server, ther server is running locally
Im not sure the java console isnt showing me any exceptions.
HOW I CREATED THE SIGNED JAR FILE
The namespace of my Applet is captureaudio.AppletTest class
At cmd prompt, where teh class file is located:
You need to use the keytool.exe here is where i found how to create a jar signature for applets www.xinotes.org/notes/note/434/
jar -cf AppletTest.jar AppletTest.class
>jarsigner AppletTest.jar MyCert Warning: This jar contains entries whose signer certificate will expire within six months
4.>jarsigner -verify -verbose -certs AppletTest.jar
s k 153 Thu Oct 13 11:28:38 BST 2011 META-INF/MANIFEST.MF
X.509, CN=xxxxx, OU=None, O=None, L=xxxxx, ST=xxxxx, C=GB (myce
rt)
[certificate will expire on 10/01/12 20:55]
315 Thu Oct 13 11:28:40 BST 2011 META-INF/MYCERT.SF
1352 Thu Oct 13 11:28:40 BST 2011 META-INF/MYCERT.RSA
0 Thu Oct 13 11:28:10 BST 2011 META-INF/
smk 11015 Thu Oct 13 10:49:08 BST 2011 AppletTest.class
X.509, CN=xxxxxx, OU=None, O=None, L=xxxxxxxx, ST=xxxxx, C=GB (myce
rt)
[certificate will expire on 10/01/12 20:55]
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
jar verified.
JAVA CONSOLE
Java Plug-in 10.0.0.147
Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM
User home directory = C:\Users\xxxxxxx
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to
Detected from bootclasspath: C:\PROGRA~1\Java\jre7\lib\deploy.jar
UPDATE
Folder locations
web root>
------AppletTest.jar
------classes>
-----------captureaudio>
---------------------AppletTest.class
Use the Java Network Launching Protocol (JNLP). That is the right way to distribute you applet. And yes, it must be signed, to access the socket functionality.
http://en.wikipedia.org/wiki/Java_Web_Start#Java_Network_Launching_Protocol_.28JNLP.29
http://www.oracle.com/technetwork/articles/javase/jnlp-142088.html

Categories