我在命名空间Domain中有B类及其父类A.
然后我在名称空间Reflect中有一个Reflection Util.如果我使用这一行
instanceOfB.GetType().GetFields(BindingFlags.NonPublic
| BindingFlags.Public | BindingFlags.Instance );
Run Code Online (Sandbox Code Playgroud)
要查找所有字段(a和b),我只得到b.但是,当我a受到保护或公开时,我也会发现它们.
我还需要做些什么才能找到基类的私有字段?
我希望在arquillian.xml中有不同的容器配置,并在我的测试中选择它们.但我无法加载任何容器,但默认加载.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://www.jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="weld" default="false">
</container>
</arquillian>
Run Code Online (Sandbox Code Playgroud)
测试用例:
@Deployment(name="depl1")
@TargetsContainer("weld")
public static JavaArchive createTestArchive() throws UnsupportedEncodingException {
return ShrinkWrap
.create(JavaArchive.class, "test.jar")
.addClasses(SomeOtherCdiService.class)
.addAsManifestResource(new ByteArrayAsset(beansXmlContent.getBytes("utf-8")), ArchivePaths.create("beans.xml"));
}
@Test
@OperateOnDeployment("depl1")
public void shouldBeAbleToInjectInject() {
assertNotNull(someOtherCdiService);
}
Run Code Online (Sandbox Code Playgroud)
但测试没有开始,因为Arquilian找不到容器
org.jboss.arquillian.container.test.impl.client.deployment.ValidationException:DeploymentScenario包含与注册表中任何已定义Container不匹配的目标.焊接.可能的原因是:在Classpath上找不到可部署的容器,或者您已经使用@ org.jboss.arquillian.container.test.api.TargetsContainer值定义了@ org.jboss.arquillian.container.test.api.Deployment.任何找到/配置的容器(请参阅arquillian.xml容器@限定符)
我查看了源代码,发现Aquilian只找到了_DEFAULT_Container.
当我@TargetsContainer("weld")从部署方法中删除时,测试工作正常.所以我认为一般测试都没问题.
如果我将容器配置修改为default="true"(<container qualifier="weld" default="ture">)然后测试工作,测试也有效,所以我认为配置文件已加载.
有没有人知道出了什么问题?
细节
完成Stacktrace:
org.jboss.arquillian.container.test.impl.client.deployment.ValidationException:
DeploymentScenario contains targets not matching any defined Container in the registry. weld.
Possible causes are: No Deployable …Run Code Online (Sandbox Code Playgroud) 我有一个maven项目,我想使用Cargo-Maven-Plugin(1.1.1)来启动和停止tomcat服务器来运行集成测试.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<type>installed</type>
<containerId>tomcat6x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip</url>
</zipUrlInstaller>
</container>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
启动服务器工作正常,但停止总是失败.
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop (stop-container) on project test: Execution stop-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop failed: Failed to stop the Tomcat 6.x container. Server port 8080 did not shutdown within the timeout period [120000] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.1:stop (stop-container) on project test: …Run Code Online (Sandbox Code Playgroud) 我是Hibernate的新手.在使用它创建一个小应用程序时,我遇到以下异常:
线程"main"中的异常java.lang.IllegalArgumentException:未知实体:
在controller.Main.main(Main.java:50)的org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:223)中的model.Students
有人可以帮帮我吗?
实体类如下:
Other details:
NetBeans Version: 6.7.1
Hibernate : 3.2.5
Run Code Online (Sandbox Code Playgroud)
实体学生
package model;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
@Entity
public class Students implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@OneToOne(cascade=CascadeType.ALL)
private Address address;
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public String getName() { …Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有spring的soap web服务客户端.
我在用 webServiceTemplate
如何指定使用哪种类型的肥皂?
我可以看到它默认使用soap 1.1.
我想强迫它使用肥皂1.2
我怎样才能做到这一点?
我e.fillInStacktrace()在创建异常后直接发现了一个显式调用Exception e = new Exception().
我认为这是多余的,因为Throwable已经调用的构造函数fillInStacktrace().
但也许我忽略了一些东西,这条线很有用:
Exception e = new Exception();
e.fillInStackTrace();
creationInfo = new CreationInfo(e.getStackTrace());
Run Code Online (Sandbox Code Playgroud)
(public CreationInfo(StackTraceElement[] aStackTrace){...})
我认为
e.fillInStackTrace();在创建异常之后直接额外调用是多余的并且会浪费大量资源,因为这种方法很昂贵.
它接缝这个构造只需要获取当前的栈跟踪,因此:
creationInfo = Thread.currentThread().getStackTrace();
Run Code Online (Sandbox Code Playgroud)
是更好的方法.
在填写问题报告之前,我想问你是否忽略了一些问题?
我有一个Spring 3.0应用程序,带有Web控制器方法.此方法通常在http响应中返回一个文件,因此我使用了返回类型org.springframework.http.HttpEntity.但现在有第二个要求:如果文件大于1MB并且在10点之后,则应显示HTML页面.
所以我的问题是,该方法有时应该返回a HttpEntity<byte[]>,有时候是a ModelAndView.但是如何才能拥有这两种不同类型的返回类型呢?
(好的是要求不是10点,它要复杂得多,但关键是,这种干扰只能在控制器中进行.)
(此应用程序使用经典JSPX呈现HTML页面.)
在基于Spring Security 3.2的应用程序中,我有一个显式配置UsernamePasswordAuthenticationFilter,需要引用sessionAuthenticationStrategy(以便调用.onAuthentication).*
这sessionAuthenticationStrategy是<security:http>(HttpSecurityBeanDefinitionParser)创建的默认值.
我的问题:如何在SessionAuthenticationStrategy不配置完整的SessionAuthenticationStrategyexplicite 的情况下获得对引用的引用,以便我可以在XML配置中注入此引用?
<security:http auto-config="false" use-expressions="true"
entry-point-ref="loginUrlAuthenticationEntryPoint"
access-decision-manager-ref="httpAccessDecisionManager">
...
<security:custom-filter
ref="usernamePasswordAuthenticationFilter"
position="FORM_LOGIN_FILTER"/>
...
</security:http>
...
<bean id="usernamePasswordAuthenticationFilter"
class=" o.s.scurity.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="sessionAuthenticationStrategy" ref="????"> <!-- ?? ->
...
</bean>
Run Code Online (Sandbox Code Playgroud)
*我的真实UsernamePasswordAuthenticationFilter是一个定制的子类,但这对于这个问题无关紧要
我尝试将Jasypt与Bouncy Castle一起使用,在Spring应用程序中提供(128Bit AES)解密实体属性,同时使用Hibernate保存它们.但是org.jasypt.exceptions.EncryptionOperationNotPossibleException当我试图保存这个委托时,我总是得到这个.
org.jasypt.exceptions.EncryptionOperationNotPossibleException
Encryption raised an exception. A possible cause is you are using strong encryption
algorithms and you have not installed the Java Cryptography Extension (JCE) Unlimited
Strength Jurisdiction Policy Files in this Java Virtual Machine
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.handleInvalidKeyException(StandardPBEByteEncryptor.java:1073)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.encrypt(StandardPBEByteEncryptor.java:924)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.encrypt(StandardPBEStringEncryptor.java:642)
at org.jasypt.hibernate4.type.AbstractEncryptedAsStringType.nullSafeSet(AbstractEncryptedAsStringType.java:155)
at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:158)
Run Code Online (Sandbox Code Playgroud)
(下面的完整堆栈跟踪)
我不使用Java Cryptography Extension(JCE),这就是我尝试使用Bouncy Castle的原因
我认为弹簧配置有问题,是否有人发现问题?
我的春季配置是:
<bean id="bouncyCastleProvider" class="org.bouncycastle.jce.provider.BouncyCastleProvider"/>
<bean class="org.jasypt.hibernate4.encryptor.HibernatePBEStringEncryptor" depends-on="bouncyCastleProvider">
<property name="provider" ref="bouncyCastleProvider"/>
<property name="providerName" value="BC"/>
<property name="saltGenerator">
<bean class="org.jasypt.salt.RandomSaltGenerator"/>
</property>
<property …Run Code Online (Sandbox Code Playgroud) 我花了几天的时间来弄清楚如何通过JNDI在Tomcat中配置javax.mail.Session并进行身份验证,现在我得到了它,但只是在深入研究代码之后.
在这段时间里,我看到了有史以来最糟糕的代码:javax.mail.Service #connect(String,String,String,String)Version 1.4.1
if (user == null) {
user = url.getUsername();
if (password == null) // get password too if we need it
password = url.getPassword();
} else {
if (password == null && user.equals(url.getUsername()))
// only get the password if it matches the username
password = url.getPassword();
}
Run Code Online (Sandbox Code Playgroud)
密码何时分配?为什么两次检查null? - 然后意识到其他不属于如果以上.(这是原始的缩进).回到主题.
至少我发现正确的资源定义是:
<Resource name="email/session"
type="javax.mail.Session"
auth="Container"
password="secret"
mail.debug="false"
mail.transport.protocol="smtp"
mail.smtp.auth="true"
mail.smtp.user="testi"
mail.smtp.host="smtp.xxx.org"
mail.smtp.from="test@example.com"
/>
Run Code Online (Sandbox Code Playgroud)
请注意它是"password"和"mail.smtp.user"或"mail.user"但不是"mail.smtp.password"或"user".
至少神奇是在雄猫队完成的org.apache.naming.factory.MailSessionFactory.javax.mail.Authenticator如果属性password和属性mail.smtp.user或mail.user退出,此工厂将添加到邮件会话. …
java ×7
spring ×4
hibernate ×2
java-ee ×2
tomcat ×2
bouncycastle ×1
c# ×1
cargo ×1
cdi ×1
jasypt ×1
javax.mail ×1
jndi ×1
jpa ×1
maven ×1
reflection ×1
soap ×1
spring-ws ×1
stack-trace ×1
testing ×1
visibility ×1
web-services ×1