StreamCorruptedException when reading from an ObjectInputStream
Hello folks!
I hope there's someone out there who can help me.
I try to write a client-server-communication (via sockets). When starting the application I get the following exception:
java.io.StreamCorruptedException: Type code out of range, is -84
at java.io.ObjectInputStream.peekCode(Unknown Source)
at java.io.ObjectInputStream.refill(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.sap.swf.protegecontrol.mcd.communication.StateTestClient.connect(StateTestClient.java:86)
at com.sap.swf.protegecontrol.mcd.communication.StateTestClient.run(StateTestClient.java:42)
at java.lang.Thread.run(Unknown Source)
I tried several suggestions from several other threads, but nothing worked for me.
Here's the excerpt of my coding:
public void connect() {
while (newConnectionRequested) {
listening = true;
Socket client = null;
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
Object input = null;
try {
client = new Socket(this.server, this.port);
oos = new ObjectOutputStream(client.getOutputStream());
catch (Exception e) {
e.printStackTrace();
System.exit(1);
System.out.println("New connection requested by client");
try {
oos.writeObject(new StateRequestInfo());
oos.flush();
catch (Exception e) {
e.printStackTrace();
try {
ois = new ObjectInputStream(client.getInputStream());
catch (Exception e) {
e.printStackTrace();
while (listening) {
try {
input = ois.readObject();
catch (Exception e) {
e.printStackTrace();
System.exit(0);
if (input != null) {
Display display = Mcd.getDisplay();
if (input instanceof String) {
System.out.println((String)input);
if (input instanceof StateInfo) {
this.state = (StateInfo)input;
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
Mcd.getGUIInstance().setState(state);
packagesReceived++;
if (packagesReceived == this.END_VAL) {
listening = false;
packagesReceived = 0;
try {
oos.close();
ois.close();
client.close();
catch (Exception e) {
e.printStackTrace();
System.out.println("Connection terminated by client");
toLive++;
if (toLive == this.END_APP) {
newConnectionRequested = false;
System.out.println("Client loop ended!");
Comment: The method opens a new client socket, connects to the server and sends a StateRequestInfo-object to inform the server which type of communication is preferred. The "state"-communication should work as follows: the server sends StateInfo-objects until the client closes (when received a certain amount of packages) and re-opens connection -
this runs in an endless loop in a separate threaad.
The State-Info Object is quite large, because it contains a Vector which contains multiple objects of state-information concerning another part of the application. All self-written objects are serializable.
I hope that's enough info. Thanks in advance.
The solution for me was to create a new
ObjectInputStream for each read, which will then
expect:
header | bob | header | dougThanks for the hint, but I tried this already and it didn't fix anything.
An alternative is to skip 4 bytes (the length of the
header) after each read, but that may not work well
with socket streams.This can't be the solution because the StreamCorruptedException is also thrown when receiving the first object - that's why I think skipping the header after receiving the first StateInfo wouldn't fix anything.
But thanks for your efforts!
By the way, that's an excerpt of the server-code:
public void run() {
ObjectOutputStream out = null;
long currtime;
while (sending) {
out = null;
try {
out = new ObjectOutputStream(client.getOutputStream());
catch (Exception e) {
// e.printStackTrace();
if (out == null) {
System.out.println("Connection terminated by client");
break;
currtime = System.currentTimeMillis();
if (currtime > (reftime + this.TIME_INC)) {
System.out.println("Sending data...");
try{
out.writeObject(theManagerInfo.getStateManager().getStateInfo());
out.flush();
catch(Exception e){
reftime = currtime;
try {
if(out != null){
out.close();
client.close();
catch (Exception e) {
e.printStackTrace();
Comment: the server runs in a separate thread and sends periodically StateInfo-Objects to the client that requestet the socket communication.
Having received a certain amount of StateInfos the client automatically curts the link and requests a new communication
Similar Messages
-
Lightroom encountered and error when reading from it preview cache and needs to quit
A power outage caused my Lightroom 5.2 to shut down without closing. When I powered back up and opened lightroom it gives me an error "Lightroom encountered and error when reading from it preview cache and needs to quit" and then it says it will try to fix it the next time it opens. I have opened it 20 times and it is not fixing it. I removed the program completely and upgraded to 5.5 AND it is still giving me the same error. Is my catalog corrupt or something? I had it set to automatically load the most currently used catalog, so it is not allowing me to open or start a new catalog either. HELP!!!
Search the forum, this has been answered many times.
-
I'm unable to open up Lightroom 5, I get this message in a pop up box: "Lightroom encountered an error when reading from it's preview cache and needs to quit" Underneath that is "Lightroom will attempt to fix this problem the next time when it launches." It hasn't, what should I do? Thanks Shawn (Irish Se7en) .
Can you try to rename (not delete!) the folder named "YOUR_CATALOG_NAME Previews.lrdata" and restart Lightroom?
-
"Lightroom encountered and error when reading from its preview cache and needs to quit"
I keep receiving this error every time I open LR, "Lightroom encountered and error when reading from its preview cache and needs to quit" and the app won't open. It said LR would try and fix this error next time I opened it but the error remains. I tried uninstalled and installing the app and the error remains.
Any Ideas here? Is there another app that may be telling it where to look for the cache and it no longer there? I was using a ramdisk for a bit but ditched it. Not sure if that has something to do with it but it seems suspect.
Your thoughts?
--Kenny Brandon WilsonTalked to Adobe support this morning, this is their response in case anyone else is looking for help. I'm running a Windows 7 box, LR 5.6.
Gokul: Click on start and type %appdata%, then open roaming folder.
Edward: ok
Gokul: Open Adobe folder.
Gokul: Open Lightroom folder.
Gokul: Open Lightroom folder> Preferences.
Edward: ok
Gokul: Rename Lightroom 5 Preferences.agprefs file as Lightroom 5 Preferences.agprefsOLD.
Edward: OK
Gokul: Please check if you can launch Lightroom without any error.
Edward: it shows me a welcome screen and is asking me to select my country
Edward: aka, register the software
Gokul: You can skip and launch it.
Edward: LR catalog not found
Gokul: Please select the catalog.
Edward: my original catalog?
Gokul: Yes.
Edward: testing integrity of catalog
Edward: loaded just fine
Gokul: Okay.
Gokul: Please check if you can re-launch it again.
Edward: yes, it worked!
Gokul: Excellent!
Gokul: Since your preferences were corrupted you were facing issue so we renamed the preferences file to reset it.
Edward: aha....ok
All of my import/export presets were intact along with develop user presets. I'm happy as a clam for my $10/month! -
LR encountered an error when reading from its preview cache and needs to quit.
I have the 30 day trial version of Lightroom. I was able to use it for one week, but the past 1.5-2 weeks, it has been locked up and giving this error message. How do I resolve the problem? And how do I reset the 30 day free trial? I would like to have time using the product, before deciding on the annual contract.
"LR encountered an error when reading from its preview cache and needs to quit. Lightroom will attempt to fix this problem the next time it launches."
Thank you.Delete the preview cache from the Lightroom folder in your Pictures folder if you used the default placement. It has the extension .lrdata.
You cannot reset the trial period. -
I keep receiving this error every time I open LR, "Lightroom encountered and error when reading from its preview cache and needs to quit" and the app won't open. It said LR would try and fix this error next time I opened it but the error remains. I tried uninstalled and installing the app and the error remains. I have windows 8. Can anyone please help???
Use Windows Explorer to open the folder containing your catalog. The normal location is Pictures\Lightroom. Locate a folder with the extension .lrdata and delete that folder. Then you should be able to start Lightroom again, and Lightroom will begin building and new previews folder. Do not delete anything else.
-
how do i fix this. It says Lightroom encountered an error when reading from a previous cache and needs to quit. Light room will attempt to to fix the problem the next time it launches.
Have a look at this thread.
Lightroom encountered an error when reading from its preview cache and needs to quit. Lightroom will attempt to fix this problem the next time it launches"." -
Error Launching LR 5: "Lightroom encountered an error when reading from its preview cache and needs to quit. Lightroom will attempt to fix this problem the next time it launches."
I've tried renaming my catalog.lrcat file. I've copied over my most recent backup of the catalog.lrcat and that didn't work either.On Mac:
PS - to open the previews "folder" (a "package" is just a "special" folder) on Mac, ctrl-click and choose "Show package contents.." - same way you open any other special folder, like .app or .lrplugin..
Rob -
Upgraded to 5.4 when opening lightroom get a message "encountered an error when reading from its preview cache and need to quite" tried this several time but get the same error message. Says Lightroom will attempt to fix the problem the next time it launches but that is not happening. How do it fix this?
Delete the preview cache using your operating system. It is a folder whose name ends with Previews.LRDATA. Do not delete the Lightroom catalog, which ends with .LRCAT
-
lightroom 5 is not opening it gives me an error message there is an error when reading from its preview cache and needs to quite
it also says it will attempt to to fix the next time it opens it doesn't do anythingCheck this thread. Your Previews Cache files are corrupted.
Re: preview cache? -
I recently updated my HP laptop's OS from WIndows8 to WIndows8.1. When I went attempted to open Lightroom5 I got the following message:
"Lightroom encountered an error when reading from its preview cache and needs to quit. "
"Lightroom will attempt to fix the problem the next time it launches"
Every time I relaunch I get the same message. I'd like to understand what might be causing the problem so I can remedy and get back to my photo editing. Any clue as to how to fix this problem would be greatly appreciated.
JPMreset your preferences, Resetting (or 'Trashing') the Lightroom Preferences file - Lightroom Forums
-
Recently updated to Windows8.1 got the message: "Lightroom encountered an error when reading from its preview cache and needs to quit. Lightroom will attempt to fix the error the next time it launches" Get the same message on multiple launches. Anyone know how to fix this?
Re: "Lightroom encountered and error when reading from its preview cache and needs to quit"
-
i upgraded from lightroom 4 to lightroom 5 and installed it on a separate hard drive. Initially had no problems util my computer crashed due to the failure of the drive on which Lightroom 5 was installed. Since having my computer rectified, i am unable to use lightroom 5 getting the message "lightroom encountered an error when reading from its preview cache and needs to quit"
I can still use lightroom 4, however, i get the same message when i try to backup the catalog. This occurs during the optimisation phase of backup.
I suspect it is related to Lightroom 5 creating a catalog from the Lightroom 4 files and cannot now locate those files or that they have been corrupted.
Would appreciate any solutions / suggestions.You need to delete your preview cache and have Lightroom rebuild it. Cache location can be found here.
https://helpx.adobe.com/lightroom/kb/preference-file-locations-lightroom-41.html
Why And How To Clear Your Lightroom Cache - Lightroom Fanatic -
Lightroom encountered an error when reading from its preview cache and needs to quit. Lightroom will attempt to fix this problem the next time it launches"."Help
PleaseStan Blumberg wrote:
I have deleted the file but the message persists even after restarting the computer....any advice??...I am using LR 5
You don't delete a file, you have to delete a folder. Is that what you did?
If you deleted the folder specified above, and you still get the message, then it's the wrong folder. Use your operating system's search function and find ALL folders on ALL disks whose name ends with Previews.LRDATA, delete each one found, and then try opening Lightroom. -
I have a question about Lightroom 5... I used it last night, I go to get on it today and its will not open. I have an error msg "Lightroom encountered an error when reading from its preview cache and needs to quit" Lightroom will attempt to fix the problem when reopened
https://forums.adobe.com/message/6219922#6219922
See if the issue in the thread above helps you to solve your problem.
Maybe you are looking for
-
HP Photosmart 7350 will not print color with my new MAC OSX 10.9.4. Tried loading printer driver but get the message that Power PC applications no longer supported. Does this mean I need to get a new printer to work with my MAC.
-
I just got a message on my computer and my phone that an ex girlfriend of mine's phone was just added to my imessage account. For obvious reasons, I'm not okay with that. I just messaged her on facebook and double checked if the name of the phone sen
-
Connection​s questions - Pavillion desktop and Samsung LCD TV
I have a Pavillion a1487c with a radeon X1650 series video card. It has 512 MB and two DVI connections, (NO VGA). My television is a Samsung LN-S4051DX with 2 HDMI, Component, and a PC VGA connection. I think the Sansung Manual says I can not connect
-
Want report title on the same page above the column names
Hi, I have given report title in the report header but for some reason it displays title on first page and data from next page on wards. I have also given a page break for the groups, is this the reason for getting title on one page and dtata from n
-
Change backend system of portal
Hi, We want our EP7 portal to point to a different backend system. We want no references to the old backend system. I know the following steps: 1) create new system 2) Change the Webdynrpo Jco connections Please let me know the other steps that needs