我整天都在尝试运行JSF应用程序的JMeter测试.我知道ViewState,但这似乎是一个非常简单的问题.我准备了正则表达式提取器:
Reference Name: jsfViewState
Regular expression: id=\"javax.faces.ViewState\" value=\"(.+?)\"
Template $1$
Match No. 1
Run Code Online (Sandbox Code Playgroud)

使用代理和记录创建以下采样器.
第一个请求/TourJSF/pages/protected/admin/addTourPage.xhtml.这是GET从中提取ViewState的请求.

该POST请求/TourJSF/pages/protected/admin/addTourPage.xhtml在哪里.${jsfViewStete}传入javax.faces.ViewState

第二个GET请求,现在在这种情况下非常重要.

结果:
首先GET.在右边我们可以看到ViewState的值.

Debug Sampler这表明jsfViewState值是正确的.我们可以将它与之前的屏幕进行比较.

javax.faces.application.ViewExpiredException: viewId:/pages/protected/admin/addTourPage.xhtml - View /pages/protected/admin/addTourPage.xhtml could not be restored.
Run Code Online (Sandbox Code Playgroud)

我找到了一些关于这个问题的博客和主题,但其中很多都没有解决.如果需要,我可以链接到这些主题.我真的很困惑......
问题在哪里?也许有些东西
jsessionid?HTTP Header Manager在每一个HTTP Request?我删了HTTP Header Manager但没有改变.com.sun.faces.enableRestoreView11Compatibility到web.xml,有没有ViewExpiredException,但返回的页面的内容是不正确的.我创建了一个非常简单的应用程序,使用持久化上下文(hibernate as provider)从数据库中读取一些值.我将Eclipse与Maven一起使用.
首先,我明白了
Caused by: org.apache.openejb.OpenEJBException: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider:
Run Code Online (Sandbox Code Playgroud)
并根据这个主题 http://openejb.979440.n4.nabble.com/problem-with-hibernate-persistence-provider-td980429.html 我排除了hibernate-jpa-2.0-api.现在,我的依赖项看起来
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.3.Final</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
现在,我不知道为什么......
Caused by: java.lang.ClassNotFoundException: org.hibernate.transaction.TransactionManagerLookup
Run Code Online (Sandbox Code Playgroud)
但是TransactionManagerLookup处于hibernate核心.请问,任何人都可以告诉我,在TomEE中如何看待pom.xml使用hibernate?
我用多个键搜索地图实现。我了解Apache Commons,但它并不能令我满意。
我希望能够传递一个密钥并获取包含所传递密钥的所有条目,例如
MultiKeyMap mkm = new MultiKeyMap();
mkm.put("key1", "key2", "key3", "1");
mkm.put("key1", "key22", "key33", "2");
mkm.put("key12", "key22", "key32", "3");
mkm.get("key1");
Run Code Online (Sandbox Code Playgroud)
返回 null 但在这种情况下我想得到“1”和“2”我自己的实现不是一个选项。我想使用我可以信任的东西。
使用JMeter,我想测试页面.填写并提交表格后,执行一些插入数据库(添加新行程).
Path: /ProjectName/admin/addTrip.html
Method: POST
Parameters:
basePrice 500.0
hotelId 2
description Some text
Run Code Online (Sandbox Code Playgroud)
主要问题是该页面在登录后可用.我不知道如何j_spring_security_check使用JMeter 登录.
我尝试使用Login Config Element作为HTTP RequestaddTrip页面的父级.结果View Result Tree -> Response data我得到了登录表单.当然这不是预期的结果.
接下来我尝试使用HTTP Request登录页面.
Path: /ProjectName/j_spring_security_check
Method: POST
Parameters:
j_password mypassword
j_login mylogin
Run Code Online (Sandbox Code Playgroud)
结果似乎很好.View Result Tree -> Response data显示正确的(登录后)页面.在线程组的同一级别,我添加Http Request了addTrip.结果与前一个案例相同 - 登录页面.在addTrip页面之后没有,没有插入数据库.
我需要从Country到Superclass Place(@MappedSuperclass)的OneToMany关联.它可以是双向的.我需要像@OneToAny这样的东西......
@MappedSuperclass
public class Place {
private String name;
private Country country;
@Column
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@ManyToOne
@JoinColumn(name="country_id")
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
}
Run Code Online (Sandbox Code Playgroud)
国家:
@Entity
public class Country {
private long id;
private String name;
private List<Place> places;
@Any(metaColumn = @Column(name = "place_type"), fetch = FetchType.EAGER)
@AnyMetaDef(idType = "integer", metaType = "string", metaValues …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用@Produces,@Consumes注释和JAXB 创建和运行JAX-RS的简单示例.
@Stateless
@LocalBean
@Path("/hotel")
public class RestMain {
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("{hotelId}")
public HotelRESTInfo read(@PathParam("hotelId") long hotelId) {
HotelDataSourceFake hotelDataSourceFake = new HotelDataSourceFake();
HotelRESTInfo hotelInfo = hotelDataSourceFake.getFakePlaceById(hotelId);
return hotelInfo;
}
}
Run Code Online (Sandbox Code Playgroud)
web.xml中:
<servlet>
<servlet-name>REST App</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
第二个应用程序是客户端.现在我有以下客户端代码:
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
...
Client client = Client.create();
String uri ="http://localhost:8080/RESTJEE/rest/hotel/" + hotelId;
WebResource resource = client.resource(uri);
ClientResponse response = resource.accept("application/xml").get(ClientResponse.class);
HotelRESTInfo hotelRestInfo = response.getEntity(HotelRESTInfo.class);
Run Code Online (Sandbox Code Playgroud)
但我不想使用jersey的Client,ClientResponse和WebResource.我想这样做@Consumes …
我的GWT服务返回LinkedList<VisualData>.这是VisualData看起来如何:
import javax.xml.bind.annotation.XmlRootElement;
import com.google.gwt.user.client.rpc.IsSerializable;
@XmlRootElement
public class VisualData implements IsSerializable {
private Number value;
private long timestamp;
public VisualData() {
}
public VisualData(Number value, long timestamp) {
this.value = value;
this.timestamp = timestamp;
}
public long getTimestamp() {
return timestamp;
}
public Number getValue() {
return value;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public void setValue(Number value) {
this.value = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我得到以下与场地相关的例外情况private Number value.
SEVERE: The exception …Run Code Online (Sandbox Code Playgroud) 基于http://www.subshell.com/en/subshell/blog/article-Publishing-Webservices-with-Java-6-and-Spring-WS100.html我尝试在Tomcat 7上使用SimpleJaxWsServiceExporter运行Webservice.
浏览器中的localhost:8081/WSTest/TourWS?wsdl导致错误404.
TourWS.java
@WebService
@SOAPBinding(style=Style.DOCUMENT)
public interface TourWS {
@WebMethod
public void declareTours(ArrayList<TourWSEntity> tours);
@WebMethod
public void declareTour(TourWSEntity tour);
@WebMethod
public String whoAmI();
Run Code Online (Sandbox Code Playgroud)
}
TourWSImpl.java
@WebService(serviceName="TourWS")
public class TourWSImpl implements TourWS {
public TourWSImpl(){}
@Override
public void declareTours(ArrayList<TourWSEntity> tours) {
// impl
}
@Override
public void declareTour(TourWSEntity tour) {
// impl
}
@Override
public String whoAmI(){
return "JAX-WS Web Service - TourWS";
}
Run Code Online (Sandbox Code Playgroud)
弹簧-WS-servlet.xml中
<beans ...>
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
<property name="baseAddress" value="http://localhost:8081/" />
</bean>
<bean id="tourWSImpl" class="tour.spring.ws.impl.TourWSImpl" /> …Run Code Online (Sandbox Code Playgroud) 这条线
jq("#description" + tourId).html('<b>Opis: </b> '+ data);
Run Code Online (Sandbox Code Playgroud)
在IE,Firefox和Opera中运行良好.
但是这个
jq("#images" + tourId).html('<img src=\"img\\gbflag.png\"/>');
Run Code Online (Sandbox Code Playgroud)
仅适用于IE.Firefox和Opera不显示图像.你知道为什么吗?
这是我的其余代码:
<script type="text/javascript">
var jq = jQuery.noConflict();
function showImages(tourId) {
jq(function() {
jq.post("/TourWebSpring/tourImages.html",
{tourId: tourId},
function(data) {
...
...
jq("#images" + tourId).html('<img src=\"img\\gbflag.png\"/>');
});
});
}
function showDetails(tourId) {
jq(function() {
jq.post("/TourWebSpring/tourDetail.html",
{tourId: tourId},
function(data) {
...
jq("#description" + tourId).html('<b>Opis: </b> '+ data);
});
});
}
Run Code Online (Sandbox Code Playgroud)
java ×7
hibernate ×2
jmeter ×2
web-services ×2
annotations ×1
apache-tomee ×1
collections ×1
dictionary ×1
firefox ×1
forms ×1
gwt ×1
html ×1
jackson ×1
java-ee ×1
javascript ×1
jax-rs ×1
jax-ws ×1
jpa ×1
jquery ×1
jsf ×1
json ×1
key ×1
load-testing ×1
observable ×1
one-to-many ×1
openejb ×1
rest ×1
rx-java ×1
spring ×1
viewstate ×1