Я получаю следующую ошибку и трассировку стека при попытке сохранить / создать пакет в моем методе сохранения groovy controller.
Error 500: Executing action [save] of controller [se.accumulate.wizard.SubmissionController] caused exception:
could not deserialize; nested exception is
org.hibernate.type.SerializationException: could not deserialize java.io.StreamCorruptedException
at java.util.Hashtable.reconstitutionPut(Hashtable.java:889)
at java.util.Hashtable.readObject(Hashtable.java:861)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at se.accumulate.wizard.PackagingService$$EnhancerByCGLIB$$2b5048f.createPackage(<generated>)
Любые идеи / советы по решению этой проблемы. Я проверил наличие каких-либо несоответствий домена с базой данных и т. Д. Все выглядит хорошо для меня.
пример кода:
def createPackage(Submission submission){
logger.info("Creating submission package");
def xml = createZip(submission);
}
def createZip(Submission submission){
def sw = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(sw);
Customer customer = Customer.get(submission.customerId);
String custDir = customer.ftpCustomerTempDirectory
logger.info("Zip file: " + submission.fileName);
final int BUFFER = 2048;
try {
String tmpFileName = custDir+"/" + java.util.UUID.randomUUID().toString().replaceAll("-", "") + ".zip";
FileOutputStream fos = new FileOutputStream(tmpFileName);
BufferedOutputStream dest;
ZipOutputStream zos = new ZipOutputStream(fos);
FileInputStream fis = new FileInputStream(custDir+"/" + submission.fileName);
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
while((entry = zis.getNextEntry()) != null) {
//System.out.println("Extracting: " +entry);
if (!entry.isDirectory()) {
if((entry.getName().toLowerCase().endsWith(".jar") || entry.getName().toLowerCase().endsWith(".jad") || entry.getName().toLowerCase().endsWith(".apk"))){
int count;
byte[] data = new byte[BUFFER];
String name = entry.getName();
if (name.indexOf('/') >= 0) {
String[] parts = name.split('/');
name = parts[parts.length - 1];
}
zos.putNextEntry(new ZipEntry("Applications/" + name));
while ((count = zis.read(data, 0, BUFFER))!= -1) {
zos.write(data, 0, count);
}
zos.closeEntry();
}
}
}
zis.close();
if (submission.applicationImage != null) {
zos.putNextEntry(new ZipEntry("thumbnail_60x60.png"));
zos.write(submission.applicationImage);
zos.closeEntry();
}
zos.putNextEntry(new ZipEntry("Submission.xml"));
zos.write(createXml(submission).toString().getBytes("UTF-8"));
zos.close();
FtpClientService fcs = new FtpClientService();
fcs.putFile(customer.ftpUser, customer.ftpPassword, customer.ftpHost, customer.ftpPackagedDirectory, tmpFileName, submission.outputFileName);
logger.info("check 1")
if (!new File(tmpFileName).delete()) {
logger.info("Could not delete tmp file " + tmpFileName);
}
logger.info("check 2")
if (!new File(custDir+"/" + submission.fileName).delete()) {
logger.info("Could not delete submission file " + submission.fileName);
}
logger.info("check 3")
} catch(Exception e) {
e.printStackTrace();
}
logger.info("check 4")
return "sw";
}
Были показаны все проверки журналов с 1 по 4, и был создан ожидаемый вывод / файл, но было сгенерировано это исключение ...
Мой класс домена: (Submission.groovy, который создал мастер)
package se.accumulate.wizard
class Submission extends Wizard {
long operatingSystemId
long deploymentId
int newOrExisting
String applicationName
String applicationShortName
String reportingName
byte[] applicationImage
long contentProviderId
String fileName
String outputFileName
Properties deviceMapping
long applicationId
int overwriteExistingApplicationDetails
static constraints = {
operatingSystemId (nullable:true)
deploymentId (nullable:true)
newOrExisting (nullable:true)
applicationName (nullable:true)
applicationShortName (nullable:true)
reportingName (nullable:true)
applicationImage (nullable:true, maxSize: 1048576)
contentProviderId (nullable:true)
fileName (nullable:true)
deviceMapping (nullable:true, maxSize: 5242880)
outputFileName (nullable:true)
}
}
package se.accumulate.wizard
abstract class Wizard {
Date dateCreated
Date lastUpdated
long createdByUserId
long customerId
Boolean isConfirmed = false
int pageTracker
}
Описание представления моей таблицы БД, как показано ниже: (извините за неправильное форматирование)
Тип поля Null Key По умолчанию
'application_id', 'bigint (20)', 'NO', '', NULL, ''
'application_image', 'blob', 'YES', '', NULL, ''
'application_name', 'varchar (255)', 'YES', '', NULL, ''
'cms_id', 'varchar (255)', 'YES', '', NULL, ''
'content_provider_id', 'bigint (20)', 'NO', '', NULL, ''
'create_by_user_id', 'bigint (20) unsigned', 'NO', '', NULL, ''
'date_created', 'datetime', 'NO', '', NULL, ''
'deploy_id', 'bigint (20)', 'NO', '', NULL, ''
'device_mapping', 'blob', 'YES', '', NULL, ''
'file_name', 'varchar (255)', 'YES', '', NULL, ''
'is_confirmed', 'tinyint (1)', 'NO', '', NULL, ''
'last_updated', 'datetime', 'NO', '', NULL, ''
'new_or_existing', 'int (11)', 'NO', '', NULL, ''
'operating_system_id', 'bigint (20)', 'NO', '', NULL, ''
'overwrite_existing_application_details', 'int (11)', 'NO', '', NULL, ''
'customer_id', 'bigint (20)', 'YES', 'MUL', NULL, ''
'output_file_name', 'varchar (255)', 'YES', '', NULL, ''
'reports_name', 'varchar (255)', 'YES', '', NULL, ''
'application_short_name', 'varchar (255)', 'YES', '', NULL, ''
'page_tracker', 'int (11)', 'YES', '', NULL, ''
часть другого метода, который вызывается из createPackage (после изменения этого метода появляется ошибка) - я только что отфильтровал «?» из имени файла
def createXml(Submission submission){
Application application = Application.get(submission.getApplicationId());
ContentProvider contentProvider = ContentProvider.get(submission.getContentProviderId());
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element rootElement = doc.createElement("game");
rootElement.setAttribute("title", submission.applicationName);
rootElement.setAttribute("short", submission.applicationShortName);
rootElement.setAttribute("externalRef", application.cmsId);
rootElement.setAttribute("contentPartner", contentProvider.name);
if (submission.applicationImage != null) {
Element image = doc.createElement("image");
image.setAttribute("type", "thumbnail");
image.setAttribute("mime-type", "image/png");
image.setAttribute("width", "60");
image.setAttribute("height", "60");
image.setTextContent("thumbnail_60x60.png");
rootElement.appendChild(image);
}
Properties ps = submission.deviceMapping;
Properties dm = (Properties) ps;
for (def device : dm) {
device.key = device.key.split("\\?")[0];
logger.debug("key=${device.key}, value=${device.value}")
if (!(device.value == null || "null".equalsIgnoreCase(device.value))) {
logger.info("Adding handset: " + device.value);
Element handset = doc.createElement("handset");
handset.setAttribute("name", device.value);
String name = device.key;
if (name.indexOf('/') >= 0) {
String[] parts = name.split('/');
name = parts[parts.length - 1];
}
if (name.toLowerCase().endsWith(".jad")) {
// java and blackberry
Element jadFile = doc.createElement("jadfile");
jadFile.setTextContent("Applications/" + name);
handset.appendChild(jadFile);
/*
name = getJarFileName();
if (name.indexOf('/') >= 0) {
String[] parts = name.split('/');
name = parts[parts.length - 1];
}*/
Element jarFile = doc.createElement("jarfile");
jarFile.setTextContent("Applications/" + name.replace(".jad", ".jar"));
handset.appendChild(jarFile);
}
else {
// android
Element jarFile = doc.createElement("jarfile");
jarFile.setTextContent("Applications/" + name);
handset.appendChild(jarFile);
}
rootElement.appendChild(handset);
}
}
doc.appendChild(rootElement);
StringWriter xmlString = new StringWriter();
try{
Result result = new StreamResult(xmlString);
Source source = new DOMSource(doc);
// Write the DOM document to the file
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result);
} catch (Exception e){
e.printStackTrace();
}
logger.info("XML: " + xmlString.toString());
return xmlString;
}