- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个动态 Web 项目,并在我的 eclipse mars 中添加了 JPA 方面。在我的构建路径中,我有:jdk8、EclipseLink 2.6、JPA 2.1、Tomcat 8、Oracle 瘦驱动程序(ojdbc14.jar);
有一个奇怪的问题,因为同一个项目在某些机器上可以运行,但在其他机器上却不能运行。
出于这个目的,我认为 tomcat 并不是必需的,因为我只想从一个简单的 jpa 项目中的实体生成表。
我创建了两个 jpa 实体,并将 persistence.xml
设置为指向我的 Oracle 数据库(Ping 成功):
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="question" transaction-type="RESOURCE_LOCAL">
<class>it.corsojava.question.domain.Student</class>
<class>it.corsojava.question.domain.Question</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@192.168.14.111:1521:ORCL"/>
<property name="javax.persistence.jdbc.user" value="fede"/>
<property name="javax.persistence.jdbc.password" value="fede"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
<property name="eclipselink.jdbc.bind-parameters" value="false"/>
<property name="eclipselink.jdbc.exclusive-connection.is-lazy" value="true"/>
<property name="eclipselink.jdbc.exclusive-connection.mode" value="Transactional"/>
<property name="eclipselink.jdbc.batch-writing" value="Oracle-JDBC"/>
</properties>
</persistence-unit>
</persistence>
问题.java 包 it.corsojava.question.domain;
import java.io.Serializable;
import java.lang.Long;
import java.lang.String;
import javax.persistence.*;
/**
* Entity implementation class for Entity: Question
*
*/
@Entity
public class Question implements Serializable {
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String text;
private static final long serialVersionUID = 1L;
public Question() {
super();
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getText() {
return this.text;
}
public void setText(String text) {
this.text = text;
}
}
学生.java
package it.corsojava.question.domain;
import java.io.Serializable;
import java.lang.Long;
import java.lang.String;
import javax.persistence.*;
/**
* Entity implementation class for Entity: Student
*
*/
@Entity
public class Student implements Serializable {
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String name;
private String username;
private String password;
private String email;
private static final long serialVersionUID = 1L;
public Student() {
super();
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
}
不幸的是,当我运行 JPA 工具>从实体创建表时...我收到以下错误:
[EL Fine]: server: Configured server platform: org.eclipse.persistence.platform.server.NoServerPlatform
[EL Config]: metadata: The access type for the persistent class [class it.corsojava.question.domain.Question] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class it.corsojava.question.domain.Student] is set to [FIELD].
[EL Config]: metadata: The alias name for the entity class [class it.corsojava.question.domain.Question] is being defaulted to: Question.
[EL Config]: metadata: The table name for entity [class it.corsojava.question.domain.Question] is being defaulted to: QUESTION.
[EL Config]: metadata: The column name for element [id] is being defaulted to: ID.
[EL Config]: metadata: The column name for element [text] is being defaulted to: TEXT.
[EL Config]: metadata: The alias name for the entity class [class it.corsojava.question.domain.Student] is being defaulted to: Student.
[EL Config]: metadata: The table name for entity [class it.corsojava.question.domain.Student] is being defaulted to: STUDENT.
[EL Config]: metadata: The column name for element [password] is being defaulted to: PASSWORD.
[EL Config]: metadata: The column name for element [name] is being defaulted to: NAME.
[EL Config]: metadata: The column name for element [id] is being defaulted to: ID.
[EL Config]: metadata: The column name for element [email] is being defaulted to: EMAIL.
[EL Config]: metadata: The column name for element [username] is being defaulted to: USERNAME.
[EL Severe]: ejb: Local Exception Stack:
Exception [EclipseLink-7107] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered during string decryption.
Internal Exception: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at org.eclipse.persistence.exceptions.ValidationException.errorDecryptingPassword(ValidationException.java:894)
at org.eclipse.persistence.internal.security.JCEEncryptor.decryptPassword(JCEEncryptor.java:114)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateLogins(EntityManagerSetupImpl.java:2404)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:2716)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:710)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:183)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:528)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:150)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68)
Caused by: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:913)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
at com.sun.crypto.provider.DESCipher.engineDoFinal(DESCipher.java:314)
at javax.crypto.Cipher.doFinal(Cipher.java:2165)
at org.eclipse.persistence.internal.security.JCEEncryptor.decryptPassword(JCEEncryptor.java:109)
... 12 more
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-7107] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered during string decryption.
Internal Exception: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:815)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:183)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:528)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:150)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68)
Caused by: Exception [EclipseLink-7107] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Error encountered during string decryption.
Internal Exception: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at org.eclipse.persistence.exceptions.ValidationException.errorDecryptingPassword(ValidationException.java:894)
at org.eclipse.persistence.internal.security.JCEEncryptor.decryptPassword(JCEEncryptor.java:114)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateLogins(EntityManagerSetupImpl.java:2404)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:2716)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:710)
... 9 more
Caused by: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:913)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
at com.sun.crypto.provider.DESCipher.engineDoFinal(DESCipher.java:314)
at javax.crypto.Cipher.doFinal(Cipher.java:2165)
at org.eclipse.persistence.internal.security.JCEEncryptor.decryptPassword(JCEEncryptor.java:109)
... 12 more
最佳答案
这与已知的 bug 相关2.6.5-RC1 版本已修复此问题。它还可以按预期与最新的 2.6.5-RC2 候选版本(自 2017 年 6 月起提供)配合使用。
如果您有 Maven 项目,请更改 EclipseLink 依赖项的版本字符串,如下所示:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.5-RC2</version>
</dependency>
如果这是一个独立项目,请查找最新的2.6.5-RC2 jar file on Maven Central 。只需删除旧的 jar 文件并将新的文件放入应用程序的类路径中即可。
希望有帮助。
关于java - 无法使用 eclipse link 和 oracle db 生成表 - IllegalBlockSizeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42068678/
我在使用以下代码时遇到了一些问题 - 我似乎收到了 IllegalBlocksizeException 并且不确定我在这里可能做错了什么?可以获得一些建议/指示吗? 谢谢 public cla
我在 JRE 1.6 上使用 AES 128 位加密。 我在尝试解密由 encrypt() 生成的字符串时不断收到此异常: 2014-11-19 14:40:10.831 28 javax.c
我编写了一个加密和解密函数。加密工作正常,但我总是在解密时遇到 IllegalBlockSizeException。 public static String aes_encrypt (String
我在处理解密方法时遇到了问题。加密产生了正确的输出,但是当我解密完全相同的加密字符串时(应该返回明文字符串),它不起作用。 import javax.crypto.Cipher; import jav
String key = "my_own_key_which_should_be_quite_long"; byte[] keyData = key.getBytes(); SecretKeySpec
我当前编写的解密算法如下, public String decrypt(String enc) throws Exception { Key key = k;
我的加密方法是: private static final String ALGORITHM = "AES/ECB/PKCS5Padding"; private static final byte[]
我在使用 Cipher 时观察到以下情况. 加密代码: Cipher aes = Cipher.getInstance("AES"); aes.init(Cipher.ENCRYPT_MODE, ge
我写了一些聊天内容,消息是类似的对象 {type="message",sender="userA",content="plaintextmessage",recipient="userB"} 发送到服
我正在使用 Java 的加密库并收到 IllegalBlockSizeException。 我目前正在尝试以 XML 文件格式提取数据库内容。在数据转储期间,我正在创建一个 list 文件,其中包含一
我已经使用 RSA 的公钥加密成功地加密了我的 AES key 。在使用 RSA 的私钥解密时,我得到: javax.crypto.IllegalBlockSizeException 适用于我的加密逻
我有一个硬编码 key ,我想在将字符串存储在 SharedPreferences 中之前使用它对其进行加密。这是我到目前为止的代码: public class TokenEncryptor {
我有一个硬编码 key ,我想在将字符串存储到 SharedPreferences 之前用它加密字符串。这是我到目前为止的代码: public class TokenEncryptor { p
我在java中使用AES/CBC/PKCS5Padding填充标准,我的 friend 在c#.NET中使用PKCS7标准如果我的 friend 使用 AES 加密数据并向我发送 key ,那么我就可
我目前正在开展一个夏季项目,该项目使用 AES 加密或解密文件。但是,当使用与加密对象相同的 key 时,我在尝试解密时收到非法 block 大小异常。我对密码学很陌生,但也是一位经验丰富的 Java
我正在尝试加密/解密文件中的文本,但收到以下错误: Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input l
我正在尝试使用 jks Keystore 文件加密和解密字符串。但是在解密时出现以下错误... 这是我的加密和解密类(class): package com.Encrypt; import java.
我使用DES 算法来加密/解密我的文本。它与拉丁文本完美搭配。 但是当我开始加密/解密西里尔文本时,解密的文本显示为 ?????? ???????? 在我的 TextField 表单和控制台中。我该如
RSA key 是使用以下代码生成的: RSAKeyGenParameterSpec rsaSpec = new RSAKeyGenParameterSpec(2048, RSAKeyGenParam
我使用 aes-256-cbc 进行数据加密/解密。 当使用 php 代码解密数据时,我没有收到错误。 PHP 代码如下: $key = 'd7df7d66bc110ba2e03a3a647ecd8c
我是一名优秀的程序员,十分优秀!