小编Bet*_*sta的帖子

Tomcat没有从Eclipse部署我的Web项目

我正在开发Web应用程序.一切都很好,直到昨天.

昨天发生了一些事情(不知道到底是什么),Eclipse不再部署我的应用程序了.

我正在使用spring和maven,但它之前有效,所以我认为这没有问题.

当我启动我的应用程序时,在启动日志中有这个:

7.9.2012 12:39:23 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_31\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\CVSNT\;c:\Programs\apache-ant-1.8.1\bin;C:\Program Files (x86)\Common Files\Teleca Shared;C:\SSD\Oracle11g\product\11.2.0\dbhome_3\bin;C:\SSD\Oracle11g\product\11.2.0\dbhome_1\bin;C:\Program Files (x86)\Groovy\Groovy-1.8.6\bin;C:\Programs\TortoiseSVN-1.7.7\bin;c:\Programs\apache-ant-1.8.1\bin;c:\Program Files\Java\jdk1.6.0_31\bin;c:\Programs\cygwin\bin;c:\Programs\apache-maven-2.2.1\bin;C:\SSD\Mudrc\Eclipse;;.
7.9.2012 12:39:23 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MudrcWeb2' did not find a matching property.
7.9.2012 12:39:23 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-9091"]
7.9.2012 12:39:23 org.apache.coyote.AbstractProtocol init
INFO: Initializing …
Run Code Online (Sandbox Code Playgroud)

eclipse tomcat

24
推荐指数
4
解决办法
10万
查看次数

Maven部署到快照而不是发布

我正在尝试使用maven发布一个项目,但不是发布到Releases存储库,而是将它放在我们的Snapshots repo中.

我的pom看起来像:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                             http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.my.profiler</groupId>
<artifactId>profilerlib</artifactId>
<name>Profiler Lib</name>
<version>1.0.2-SNAPSHOT</version>
<description>Profiler Library</description>
<scm>
    <connection>scm:svn:https://svn.example.com/my-project/profilerlib/trunk
    </connection>
    <developerConnection>scm:svn:https://svn.example.com/my-project/profilerlib/trunk
    </developerConnection>
</scm>
<distributionManagement>
    <!-- Publish the versioned releases here -->
    <repository>
        <id>nexus</id>
        <name>nexus</name>
        <url>http://repo.example.com:8081/nexus/content/repositories/releases
        </url>
    </repository>
    <!-- Publish the versioned releases here -->
    <snapshotRepository>
        <id>nexus</id>
        <name>nexus</name>
        <url>http://repo.example.com:8081/nexus/content/repositories/snapshots
        </url>
    </snapshotRepository>
</distributionManagement>
<!-- download artifacts from this repo -->
<repositories>
    <repository>
        <id>nexus</id>
        <name>EXAMPLE Public Repository</name>
        <url>http://repo.example.com:8081/nexus/content/groups/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<dependencies>
    ...
</dependencies>
<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-release-plugin</artifactId> …
Run Code Online (Sandbox Code Playgroud)

java release snapshot maven

21
推荐指数
3
解决办法
2万
查看次数

403 - 验证后拒绝访问

问候!

当我尝试对我现有的数据库进行身份验证时,我正在通过身份验证但是我得到了403页面.如果我只是尝试了错误的密码,我会收到"错误的凭据"消息.我尝试对SpringSecurity附带的每个示例应用进行身份验证,并且运行正常.

安全的context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
    xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

    <global-method-security secured-annotations="enabled"></global-method-security>

    <http auto-config="true" >
        <intercept-url pattern="/admin/**" access="ROLE_TEST" />
        <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />

        <form-login
            login-page="/login/index.jsp"
            default-target-url="/admin/test.jsp"
            authentication-failure-url="/login/index.jsp?login_error=1" />  
    </http>

    <authentication-provider user-service-ref="jdbcUserService">      
        <password-encoder ref="passwordEncoder">
                <salt-source system-wide="n103df"/>
        </password-encoder>        
    </authentication-provider>


    <beans:bean id="jdbcUserService"  class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
        <beans:property name="rolePrefix" value="" />
        <beans:property name="dataSource" ref="dataSource" />
        <beans:property name="enableAuthorities" value="true"/>
        <beans:property name="enableGroups" value="false"/>
        <beans:property name="authoritiesByUsernameQuery" value="SELECT username,authority FROM authorities WHERE username = ?" />
        <beans:property name="usersByUsernameQuery" value="SELECT username,password,enabled as enabled FROM users WHERE username …
Run Code Online (Sandbox Code Playgroud)

spring-security

20
推荐指数
1
解决办法
3万
查看次数

m2e:使用exec-maven-plugin生成代码

我已经使用m2eclipse 2年左右,现在已经切换到m2e.

不幸的是,这已经破坏了我的一些功能.

在许多项目中,我生成了Java代码,通常是通过库项目中的主类生成的.这是一个典型的设置:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>generateDTOs</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>java</goal>
            </goals>
            <configuration>
                <classpathScope>test</classpathScope>
                <mainClass>com.somecompany.SomeCodeGenerator</mainClass>
                <arguments>
                    <argument>${project.build.directory}/generated-sources/foo</argument>
                    <argument>${project.basedir}/path/to/a/config/file</argument>
                    <argument>more arguments</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>addDtoSourceFolder</id>
            <goals>
                <goal>add-source</goal>
            </goals>
            <phase>process-sources</phase>
            <configuration>
                <sources>
                    <source>${project.build.directory}/generated-sources/foo</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

以前,我只需要使用eclipse作为maven项目导入该项目,代码将自动执行并将源文件夹添加到eclipse项目中.

现在,m2e已经为buildhelper插件安装了一个"连接器",因此创建了源文件夹,但我必须通过执行手动触发代码生成Run As > Maven > generate-sources.这真的很烦人,我想maven构建响应pom.xml更改Project > Clean ...,SVN更新,Eclipse启动等,就像以前一样.

我能做些什么让m2e像m2eclipse一样工作?

java eclipse m2eclipse maven m2e

20
推荐指数
1
解决办法
1万
查看次数

在Oracle 11g中创建触发器时出现问题

尝试使用SQL Developer在Oracle 11g数据库中创建触发器时,我遇到了一个奇怪的错误.这是我做的:

我的桌子:

CREATE TABLE COUNTRY_CODE(
   ID NUMBER(19,0)      PRIMARY KEY NOT NULL, 
   Code             VARCHAR2(2) NOT NULL,
   Description  VARCHAR2(50),
   created                  TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
   created_by                   VARCHAR2(40) DEFAULT USER, 
   last_updated                 TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
   last_updated_by          VARCHAR2(40) DEFAULT USER,
   archived CHAR(1) DEFAULT '0' NOT NULL );
Run Code Online (Sandbox Code Playgroud)

序列:

CREATE SEQUENCE COUNTRY_CODE_ID_SEQ START WITH 1 INCREMENT BY 1;
Run Code Online (Sandbox Code Playgroud)

触发:

CREATE OR REPLACE TRIGGER COUNTRY_CODE_TRIGGER
BEFORE INSERT ON COUNTRY_CODE
FOR EACH ROW
DECLARE
    max_id number;
    cur_seq number;
BEGIN
    IF :new.id IS NULL THEN
    SELECT COUNTRY_CODE_ID_SEQ.nextval
    INTO :new.id …
Run Code Online (Sandbox Code Playgroud)

triggers oracle11g

20
推荐指数
1
解决办法
1万
查看次数

BeanDefinitionParsingException:配置:元素[step2]无法访问

我有类似这个的春季批处理工作:

<batch:job id="job">
    <batch:step id="step1">
        ...
    </batch:step>
    <batch:step id="step2">
        ...
    </batch:step>
</batch:job>
Run Code Online (Sandbox Code Playgroud)

当我试图执行我得到的工作

BeanDefinitionParsingException: Configuration problem: The element [step2] is unreachable
Run Code Online (Sandbox Code Playgroud)

spring spring-batch

20
推荐指数
1
解决办法
6681
查看次数

使用jpa和hibernate在orm.xml中定义命名查询

我正在尝试将我的命名查询放在我的orm.xml中(使用persistence.xml放入META-INF)但是我的orm.xml似乎被hibernate/jpa忽略了.

当我尝试使用em.createNamedQuery("myQuery")创建我的命名查询时,它返回它无法找到此查询.

我使用注释,我想在orm.xml中外化我的命名查询(仅限于此).

这是我的persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
    <mapping-file>META-INF/orm.xml</mapping-file>

    <class>com.mysite.Account</class>

    <properties>
        <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" />
        <property name="hibernate.cache.use_query_cache" value="true" />
        <property name="hibernate.cache.use_second_level_cache" value="true" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
        <property name="use_sql_comments" value="false" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MYSQLDialect" />
        <property name="hibernate.c3p0.min_size" value="5" />
        <property name="hibernate.c3p0.max_size" value="20" />
        <property name="hibernate.c3p0.timeout" value="300" />
        <property name="hibernate.c3p0.max_statements" value="50" />
        <property name="hibernate.c3p0.idle_test_period" value="3000" />

        <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider" />
    </properties>

</persistence-unit>

</persistence>
Run Code Online (Sandbox Code Playgroud)

这是我的orm.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" …
Run Code Online (Sandbox Code Playgroud)

java orm hibernate jpa named-query

19
推荐指数
2
解决办法
5万
查看次数

Spring Security 3指定了多个intercept-url访问角色

我正在尝试使用JDBC身份验证设置Spring 3安全性.除了我尝试为拦截网址指定多个访问角色时,一切都工作正常.例如,我希望任何角色为ROLE_USER和ROLE_ADMIN的人能够访问所有页面,我在spring配置文件中使用了以下行 -

<security:intercept-url pattern="/**" access="ROLE_USER, ROLE_ADMIN" />
Run Code Online (Sandbox Code Playgroud)

但是这会引发以下错误 -

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unsupported configuration attributes: [ ROLE_ADMIN]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:558)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:852)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:422)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) …
Run Code Online (Sandbox Code Playgroud)

spring-security url-interception

18
推荐指数
4
解决办法
5万
查看次数

Maven没有正确设置依赖关系的类路径

操作系统名称:"linux"版本:"2.6.32-27-generic"arch:"i386"系列:"unix"

Apache Maven 2.2.1(r801777; 2009-08-06 12:16:01-0700)

Java版本:1.6.0_20

我试图在ubuntu中使用maven与maven相关联.如果我移动maven下载到我的$ JAVA_HOME/jre/lib/ext /文件夹中的"mysql-connector-java-5.1.14.jar"文件,那么当我运行jar时一切都很好.

我想我应该只能在pom.xml文件中指定依赖项,maven应该自动设置依赖项jar的类路径.这是不正确的?

我的pom.xml文件如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.ion.common</groupId>
  <artifactId>TestPreparation</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>TestPrep</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>

        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>com.ion.common.App</mainClass>
            </manifest>
          </archive>
        </configuration>

      </plugin>
    </plugins>
  </build>

  <dependencies>

    <!-- JUnit testing dependency -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <!-- MySQL database driver -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.14</version>
      <scope>compile</scope>
    </dependency>

  </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

命令"mvn package"构建它没有任何问题,我可以运行它,但是当应用程序尝试访问数据库时,会出现以下错误:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at …
Run Code Online (Sandbox Code Playgroud)

dependencies classpath maven

18
推荐指数
2
解决办法
6万
查看次数

创建一个Spring枚举bean并传递方法调用的值

我有这个Singleton:

   public enum Elvis {
       INSTANCE;
       private int age;

       public int getAge() {
           return age;
       }
   }
Run Code Online (Sandbox Code Playgroud)

我知道如何在spring中创建枚举bean:

   <bean id="elvis" class="com.xyz.Elvis" factory-method="valueOf">
           <constructor-arg>
               <value>INSTANCE</value>
           </constructor-arg>
   </bean> 
Run Code Online (Sandbox Code Playgroud)

如何将INSTANCE.getAge()返回的int传递给另一个bean构造函数?

java enums spring

17
推荐指数
1
解决办法
1万
查看次数