When I tried to do SVN synchronize I got this error. I wonder why it has happen, any ideas? It works great after restarting eclipse, but I wonder what could cause it and how its possible that the jar was not found.
!ENTRY org.eclipse.team.svn.core.svnnature 4 0 2011-12-09 14:22:15.534
!MESSAGE SVN: '0x00000107: Synchronizing' operation finished with error
!SUBENTRY 1 org.eclipse.team.svn.core.svnnature 4 0 2011-12-09 14:22:15.534
!MESSAGE Synchronize operation failed.
!STACK 0
java.lang.InternalError
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:755)
at sun.misc.URLClassPath.getResource(URLClassPath.java:169)
at sun.misc.URLClassPath.getResource(URLClassPath.java:221)
at java.lang.ClassLoader.getBootstrapResource(ClassLoader.java:1151)
at java.lang.ClassLoader.getResource(ClassLoader.java:1000)
at java.lang.ClassLoader.getResource(ClassLoader.java:998)
at java.lang.ClassLoader.getSystemResource(ClassLoader.java:1101)
at javax.crypto.SunJCE_b.i(DashoA13*..)
at javax.crypto.SunJCE_b.g(DashoA13*..)
at javax.crypto.SunJCE_b$1.run(DashoA13*..)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.SunJCE_b.<clinit>(DashoA13*..)
at javax.crypto.KeyAgreement.getInstance(DashoA13*..)
at com.sun.net.ssl.internal.ssl.JsseJce.getKeyAgreement(JsseJce.java:241)
at com.sun.net.ssl.internal.ssl.JsseJce.isEcAvailable(JsseJce.java:158)
at com.sun.net.ssl.internal.ssl.CipherSuite$KeyExchange.isAvailable(CipherSuite.java:271)
at com.sun.net.ssl.internal.ssl.CipherSuite.isAvailable(CipherSuite.java:143)
at com.sun.net.ssl.internal.ssl.CipherSuiteList.buildAvailableCache(CipherSuiteList.java:210)
at com.sun.net.ssl.internal.ssl.CipherSuiteList.getDefault(CipherSuiteList.java:233)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.init(SSLSocketImpl.java:508)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:451)
at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:56)
at org.tmatesoft.svn.core.internal.util.SVNSocketFactory.createSSLSocket(SVNSocketFactory.java:73)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.connect(HTTPConnection.java:186)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:327)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:275)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:263)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:516)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:98)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:999)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.getRepositoryUUID(DAVRepository.java:146)
at org.tmatesoft.svn.core.wc.SVNBasicClient.createRepository(SVNBasicClient.java:342)
at org.tmatesoft.svn.core.wc.SVNBasicClient.createRepository(SVNBasicClient.java:330)
at org.tmatesoft.svn.core.wc.SVNStatusClient.doStatus(SVNStatusClient.java:338)
at org.tmatesoft.svn.core.javahl.SVNClientImpl.status(SVNClientImpl.java:300)
at org.tmatesoft.svn.core.javahl.SVNClientImpl.status(SVNClientImpl.java:282)
at org.polarion.team.svn.connector.svnkit.SVNKitConnector.status(SVNKitConnector.java:341)
at org.eclipse.team.svn.core.extension.factory.ThreadNameModifier.status(ThreadNameModifier.java:608)
at org.eclipse.team.svn.core.operation.local.RemoteStatusOperation$2.run(RemoteStatusOperation.java:147)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doSubTask(ProgressMonitorUtility.java:118)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.protectStep(AbstractActionOperation.java:154)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.protectStep(AbstractActionOperation.java:149)
at org.eclipse.team.svn.core.operation.local.RemoteStatusOperation.runImpl(RemoteStatusOperation.java:145)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.run(AbstractActionOperation.java:81)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTask(ProgressMonitorUtility.java:104)
at org.eclipse.team.svn.core.operation.CompositeOperation.runImpl(CompositeOperation.java:95)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.run(AbstractActionOperation.java:81)
at org.eclipse.team.svn.core.operation.LoggedOperation.run(LoggedOperation.java:39)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTask(ProgressMonitorUtility.java:104)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTaskExternal(ProgressMonitorUtility.java:90)
at org.eclipse.team.svn.core.synchronize.AbstractSVNSubscriber.findChanges(AbstractSVNSubscriber.java:314)
at org.eclipse.team.svn.core.synchronize.AbstractSVNSubscriber$UpdateStatusOperation$2.run(AbstractSVNSubscriber.java:349)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doSubTask(ProgressMonitorUtility.java:118)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.protectStep(AbstractActionOperation.java:154)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.protectStep(AbstractActionOperation.java:149)
at org.eclipse.team.svn.core.synchronize.AbstractSVNSubscriber$UpdateStatusOperation.runImpl(AbstractSVNSubscriber.java:347)
at org.eclipse.team.svn.core.operation.AbstractActionOperation.run(AbstractActionOperation.java:81)
at org.eclipse.team.svn.core.operation.LoggedOperation.run(LoggedOperation.java:39)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTask(ProgressMonitorUtility.java:104)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTaskExternal(ProgressMonitorUtility.java:90)
at org.eclipse.team.svn.core.utility.ProgressMonitorUtility.doTaskExternal(ProgressMonitorUtility.java:81)
at org.eclipse.team.svn.core.synchronize.AbstractSVNSubscriber.refresh(AbstractSVNSubscriber.java:186)
at org.eclipse.team.svn.core.synchronize.UpdateSubscriber.refresh(UpdateSubscriber.java:73)
at org.eclipse.team.core.subscribers.Subscriber.refresh(Subscriber.java:466)
at org.eclipse.team.core.subscribers.SubscriberMergeContext.refresh(SubscriberMergeContext.java:85)
at org.eclipse.team.core.mapping.provider.SynchronizationContext.refresh(SynchronizationContext.java:109)
at org.eclipse.team.internal.ui.synchronize.RefreshModelParticipantJob.doRefresh(RefreshModelParticipantJob.java:69)
at org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.run(RefreshParticipantJob.java:309)
at org.eclipse.team.internal.ui.synchronize.RefreshModelParticipantJob.run(RefreshModelParticipantJob.java:117)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.io.FileNotFoundException: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jce.jar
at sun.misc.URLClassPath$JarLoader.getJarFile(URLClassPath.java:644)
at sun.misc.URLClassPath$JarLoader.access$600(URLClassPath.java:540)
at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:607)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:599)
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:753)
... 69 more
no, it always works. just one time it did not.
Looking at the JDK source code of sun.misc.URLClassPath and sun.misc.FileURLMapper, there is code in FileURLMapper.exists() that does the following:
public boolean exists() {
String path = getPath();
File f = new File (path);
return f.exists();
}
Assuming nothing crazy has happened like the jce.jar file was actually deleted (such as through upgrading version of Java while Eclipse is running), the File.exists() call might fail because of some other reason (out of memory / file descriptors possibly? On Unix file.exists() eventually calls the stat/stat64 function)
Drilling down to the code found here the things I can see: Invocation of sun.misc.URLClassPath.JarLoader.ensureOpen() at line 753 leads to InternalError raised at line 755.
The method is like as below:
private void ensureOpen() throws IOException {
if (jar == null) {
try {
java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
public Object run() throws IOException {
....
}
});
} catch (java.security.PrivilegedActionException pae) {
throw (IOException) pae.getException(); // this exception is thrown
}
}
}
Here java.security.AccessController.doPrivileged(PrivilegedExceptionAction<T>) is a native method. Documentation is here.
As it can be understood from document, that error is thrown possibly for chekced exception that occur while processing public Object run() throws IOException {.
Check this file
/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jce.jar
probably your eclipse tries to authenticate with repository but lacks classes needed to process and perform auth.
Related
I have the following code. After compilation I delete the MyClassToLoad.class file and run the code.
public class ClassLoadersTest {
public static void main(String[] args) {
MyClassToLoad c = new MyClassToLoad();
}
}
I get the following stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError:
classloaders/MyClassToLoad at
classloaders.ClassLoadersTest.main(ClassLoadersTest.java:9) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException:
classloaders.MyClassToLoad at
java.net.URLClassLoader$1.run(URLClassLoader.java:200) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) at
java.lang.ClassLoader.loadClass(ClassLoader.java:303) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at
java.lang.ClassLoader.loadClass(ClassLoader.java:248) at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 6
more
As far as I understand, this stacktrace means that there was a ClassNotFoundException, that was caught and rethrown as a NoClassDefFoundError.
The questions are:
1) How can I understand at which line the rethrow happened?
2) Who cuts the stacktrace with "... 6 more" - Java or Idea? How can I see it full?
3) As far as I understand to force the rethrown exception contain the full stacktrace we need to rethrow it as
throw new SomeRethrownException("some text", exceptionWhichIsTheReason)
But the NoClassDefFoundError doesn't have such a constructor. So in fact it shouldn't print the full stacktrace.. or may be they just put it as Error message as a String?
classloaders.ClassLoadersTest.main(ClassLoadersTest.java:9) at <-- here
The runtime system. Try
public static void main(String[] args) {
try {
MyClassToLoad c = new MyClassToLoad();
} catch (java.lang.NoClassDefFoundErro e) {
e.getCause().printStackTrace();
}
}
As for 3, see my answer to 2.
I have written a Java code that must run only after successful shutting down of weblogic server.
The code shuts down the weblogic server and performs the required operations and then restarts the servers.
My question now is .. Is there a way by which 1 can keep a tab on the weblogic console to see if the shutdown proceess is over or not or if there were some exceptions thrown by the server during startup or shut down(not manually but programmatically)??
In my local machine I had made the thread to sleep until the server was shutdown completely by keeping the average time to shut (manually).
The code goes as under:
static final String DOMAIN_NAMES = "domainNames";
static final String DOMAIN_HOME="domainHome";
public static void main(String[] argss)
{
AbstractApplicationContext context=new FileSystemXmlApplicationContext(new String[]{"src/main/resources/redeployconfig.xml"});
StepOneRedeploy stepOne=(StepOneRedeploy) context.getBean("stepOneRedeploy");
stepOne.setProperties();
Properties prop=stepOne.getProperties();
String domainNames = prop.getProperty(DOMAIN_NAMES);
System.out.println(domainNames);
String domainHome = prop.getProperty(DOMAIN_HOME);
StringTokenizer domainNamesTokens= new StringTokenizer(domainNames,",");
StringTokenizer domainNamesTokens2=domainNamesTokens;
ArrayList<String> serverIPListArray = new ArrayList<String>();
while (domainNamesTokens.hasMoreElements())
{
String domainName=domainNamesTokens.nextToken();
System.out.println(domainName);
serverIPListArray.add(domainName);
}
while(domainNamesTokens2.hasMoreElements())
{
String domainName=domainNamesTokens2.nextToken();
/** Stopping weblogicserver **/
String domainPathToShutServer = domainHome + domainName+"/stopWebLogic.cmd";
String commandToShutServer="cmd /C start "+domainPathToShutServer;
try
{
Process p = Runtime.getRuntime().exec(commandToShutServer,null);
}
catch (Exception e)
{
e.printStackTrace();
}
/**Putting thread to sleep for 1 minute**/
try {
Thread.sleep(20000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
/** Deleting temp folder **/
try
{
File delTmpFile=new File("");
boolean isTmpDelete=delTmpFile.delete();
System.out.println(isTmpDelete);
if(!isTmpDelete)
{
throw new TempDeleteFailedException("Could not delete Tmp folder for "+domainName);
}
}
catch(TempDeleteFailedException tdfe)
{
tdfe.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
/** Deleting stage folder **/
try
{
File delStgFile=new File("");
boolean isStgDelete=delStgFile.delete();
System.out.println(isStgDelete);
if(isStgDelete)
{
throw new StageDeleteFailedException();
}
}
catch (StageDeleteFailedException stgDelEileException)
{
stgDelEileException.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
/** Starting weblogicserver **/
String domainPath = domainHome + domainName+"/startWebLogic.cmd";
String command="cmd /C start "+domainPath;
try
{
Process p = Runtime.getRuntime().exec(command,null);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
I have tried ProcessBuilder to start weblogic server.
But it says that
java.io.IOException: Cannot run program "startWebLogic.cmd" (in directory "D:\Oracle\Middleware\user_projects\domains\ass1"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
at TestMain.main(TestMain.java:35)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:177)
at java.lang.ProcessImpl.start(ProcessImpl.java:28)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 1 more
So if I were to refactor the Question...
How can 1 catch the exceptions thrown by the executable run using Java code?
Is there a way by which 1 can keep a tab on the weblogic console to see if the shutdown proceess is over or not or if there were some exceptions thrown by the server during startup or shut down(not manually but programmatically)??
Weblogic logs are written to disk. By default they ae in DOMAIN_NAME\servers\SERVER_NAME\logs\SERVER_NAME.log(see: Understanding WebLogic logging files).
Just monitor the server log for exceptions. Take a look at Commons IO - Tailer.
By the way, you can use WLST and JMX to stop, start, restart and monitor the health of Weblogic (see ServerRuntimeMBean and ServerLifeCycleRuntimeMBean), no need to fire standalone processes.
You can either:
Use MBeanServerConnection (see: This Example)
Use an Embbeded WLST interpreter to Manage the server Life Cycle.
"Waiting enough" is a bad idea as it will easily break when the situation changes, and using a process builder is very limiting (not to mention that, these startup scripts typically spawn the main process as a separate process so you don't get to watch them to start with).
I'd look into hooks that the WebLogic server provides. WebLogic has lots of hooks so I don't know which one would be appropriate for you, but for example if it's a servlet you could do your shutdown process from a ServletContextListener.
I've just switched my java program to use openjdk6 from java 1.7 and now it wont compile. Can anyone help, im a long time developer but newish in Java.
Abnormal build process termination:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at org.jetbrains.jps.cmdline.Launcher.main(Launcher.java:51)
Caused by: java.lang.NoSuchFieldError: family
at sun.nio.ch.ServerSocketChannelImpl.initIDs(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.<clinit>(ServerSocketChannelImpl.java:346)
at sun.nio.ch.SelectorProviderImpl.openServerSocketChannel(SelectorProviderImpl.java:51)
at java.nio.channels.ServerSocketChannel.open(ServerSocketChannel.java:92)
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:89)
at java.security.AccessController.doPrivileged(Native Method)
at sun.nio.ch.PipeImpl.<init>(PipeImpl.java:140)
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:45)
"main" looks like
import app.Controller;
import quickfix.ConfigError;
import static libs.Library.log;
public class Main
{
public static void main(String[] args)
{
try {
log("Starting...");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Controller client = new Controller();
client.login();
synchronized (client)
{
try {
client.wait();
}
catch (Exception e) {}
}
}
catch (ConfigError e) {
log("Config error: " + e.getMessage());
}
catch (Exception e) {
log(e.getMessage());
}
}
}
Stacktrace is showing that you are trying to run it from inside Intellij IDEA. Injellij IDEA doesn't guarantee that it will work on OpenJDK. A quote from https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under
Using OpenJDK is not recommended, it has known visual and performance problems that affect some users. Use on your own risk if Oracle JDK has more severe issues on your system.
Try compiling and running from command line. But if you want to keep using Intellij IDEA switch to Oracle JDK.
I am trying to make a connection with database from a class called ConnectionProvider.
I call ConnectionProvider.getConnection() inside Servlet which return Connection refrence.
But I get exception during execution of this class:
java.io.FileNotFoundException: db.properties (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
code of ConnectionProvider:
public class ConnectionProvider {
static Properties prop;
static {
try{
prop= new Properties();
prop.load(new FileInputStream("db.properties"));
}catch(Exception e){
e.printStackTrace();
}
}
public static Connection getConnection() {
Connection con=null;
try{
Class.forName(prop.getProperty("driver"));
con=DriverManager.getConnection(prop.getProperty("url"),prop.getProperty("user"),prop.getProperty("pass"));
}catch(Exception e){
e.printStackTrace();
}
return con;
}
}
I cannot use ServletContext.getResourceAsStream() bcause code is not called from servlet.
I have tried to put property file in each and every location inside public folder (root) of web app but that doesn't help.
I also donot want to hardcode the connectivity code inside Servlet and want some helper class to perform the connectivity code for me.
Just put it in the classpath and load it from the classpath. The below example assumes that you've dropped db.properties in the root of the classpath (e.g. the root of your package structure; in Eclipse for example that would be straight in the src folder):
Properties properties = new Properties();
InputStream input = null;
try {
input = Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties");
properties.load(input);
} finally {
if (input != null) try { input.close(); } catch (IOException ignore) {}
}
See also:
getResourceAsStream() vs FileInputStream
Unrelated to the problem, your code style of ignoring the exception and just printing its trace and then continuing the code flow is a very bad practice. Your code would return a null connection and the calling code would break with NullPointerException. You should really handle the exception in a sensible manner. In this particular case, just throw it or rethrow it in another exception.
Loading the driver class everytime in the getConnection() is also unnecessary. One time is enough during application's lifetime. You could do it in for example that static block. Don't forget to rethrow any caught exception as ExceptionInInitializerError.
I am trying to get a rmi connection going. I have ran into many security issues but have been unable to find a way past all this. I execute my jar file with:
java -Djava.security.policy=java.security.AllPermission -jar "myjarfile"
The code I have been using to create this is:
public class server
{
public static void main(String args[])throws Exception
{
if (System.getSecurityManager() == null)
System.setSecurityManager ( new RMISecurityManager() {
public void checkConnect (String host, int port) {}
public void checkConnect (String host, int port, Object context) {}
});
try
{
sampleserverimpl server = new sampleserverimpl();
System.out.println("SERVER IS WAITING");
LocateRegistry.createRegistry(2020);
//Runtime.getRuntime().exec("rmiregistry 2020");
Naming.rebind("//localhost:2020/SERVER", server);
}
catch(Exception e)
{
System.out.println(e);
}
}
};
The error trace I am receiving is:
Exception in thread "RMI TCP Connection(idle)" java.security.AccessControlExcept
ion: access denied (java.net.SocketPermission 127.0.0.1:31199 accept,resolve)jav
a.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
I have tried different ways to get around this, can anyone see the issue here?
Thanks
-Djava.security.policy accepts a URL which points to a policy file which in turn contains the permissions. So you should have: -Djava.security.policy=/some/path/my.policy as the JVM argument where the my.policy file contains:
grant {
permission java.security.AllPermission;
};
Also, in order to avoid the NULL check present in your code and the manual creation of a SecurityManager, you can request a SecurityManager be automatically installed for your application by passing the JVM switch: -Djava.security.manager.
Your final JVM invocation should look like:
java -Djava.security.manager -Djava.security.policy=/some/path/my.policy
This is two separate exceptions. The first is a permission problem. The second one, the EOFException, could have any of a number of causes. I would need to see java -version and the complete stack trace to assist further.